An Overlay UIView For Managing UICollectionViews
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:
- Loading
- Empty (No Data)
- 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.
Install the library via CocoaPods by referencing in your Podfile.
pod 'StatefulView'
Create a StatefulView Object:
var statefulView: StatefulView = StatefulView()
self.statefulView.setAvailableViews(loadingView: LoadingView())
self.statefulView.setAvailableViewsByName(errorView: "ErrorView", emptyView: "EmptyView")
self.statefulView.setState(state: .loading)
self.statefulView.setHandlers(loadingView: { print("Loading View Clicked")})
See the StatefulViewExample project for a brief demo.
Feel free to make suggestions or provide feedback regarding the library. Thanks.