Band enables UIViewController to present placeholder views based on the state.
To run the example project, clone the repo, and run pod install
from the Example directory first.
- Swift 3.0
Band is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Band"
adopt BandViewControllerDelegate protcol to your ViewController.
class ViewController: UIViewController, BandViewControllerDelegate {
// ...
}
register ViewState you need to show on the ViewController into states property.
lazy var states: [ViewState] = {
return [Loading(), Empty(), Unstable()]
}()
Show Specific ViewState by calling show method.
self.show(Loading.state)
Specific the condition to present the view associated with the state.
lazy var states: [ViewState] = {
let empty = Empty(when: { () -> Bool in
return self.isEmpty()
})
let unstable = Unstable(when: { () -> Bool in
return !Reachability.isConnectedToNetwork()
})
return [Loading(), empty, unstable]
}()
Present a placeholder view if the state is satisfied the condition specificed at the when block.
self.updateViewIfNeeded([Unstable.state, Empty.state, Failure.state])
yayoc, n.yayoshi+github@gmail.com
Band is available under the MIT license. See the LICENSE file for more info.