StatefulViewManager is a simple library that will make handling various states easy.
- We need to bind our current
UIViewControllerto stateful view manager. This can be done onviewDidLoad()
viewManager.attach(to: self)- Next we need to register our controllers to various states, the available states are:
.idle,loading,.loaded,.error,.emptyand.custom(key: String)
You do not have to register controllers for all of them unless you're going to use them
let myEmptyController = UIViewController()
viewManager.bind(myEmptyController: emptyController, to: .empty)
let authenticationController = AuthController()
viewManager.bind(authenticationController, to: .custom("auth")- Then simply call show to have that view switched out
viewManager.show(.empty)
viewManager.show(.custom("auth"))✌️