Latest 0.0.6
Homepage https://github.com/mattlisiv/StatefulView
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

An Overlay UIView For Managing UICollectionViews

Build Status
Swift 3.0
Platform

This small library was created when utilizing the framework IGListKit for displaying collections.
When adhering to the IGList protocol, there exists a method with the signature:

func emptyView(for listAdapter: ListAdapter) -> UIView?

This is called when no diffable items exists for the UICollectionView.

When generically loading data, there exists default states:

  1. Loading
  2. Empty (No Data)
  3. Error

This library attempts to simplify the transitions among thesese various state by creating a simple UIView that can handle
the generic states. It was influenced by StatefulViewController, but I found a single UIView was better for my particular use case than a view controller.

Getting Started

Install the library via CocoaPods by referencing in your Podfile.

  pod 'StatefulView'

Simple Example

Create a StatefulView Object:

var statefulView: StatefulView = StatefulView()

Set Views you would like to display for different states.

By class:

self.statefulView.setAvailableViews(loadingView: LoadingView())

by XIB name:

self.statefulView.setAvailableViewsByName(errorView: "ErrorView", emptyView: "EmptyView")

Change states when desired:

self.statefulView.setState(state: .loading)

Pass in a completion block to be executed when the view is tapped:

self.statefulView.setHandlers(loadingView: { print("Loading View Clicked")})

Example

See the StatefulViewExample project for a brief demo.

Additional

Feel free to make suggestions or provide feedback regarding the library. Thanks.

Latest podspec

{
    "name": "StatefulView",
    "platforms": {
        "ios": "8.0"
    },
    "summary": "StatefulView is an overlay UIView designed for managing states for UICollectionView.",
    "requires_arc": true,
    "version": "0.0.6",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Matt Lisivick": "[email protected]"
    },
    "homepage": "https://github.com/mattlisiv/StatefulView",
    "source": {
        "git": "https://github.com/mattlisiv/StatefulView.git",
        "tag": "0.0.6"
    },
    "frameworks": "UIKit",
    "source_files": "StatefulView/**/*.{swift}",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This