Swiftpack.co - john-crossley/StatefulViewManager as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by john-crossley.
john-crossley/StatefulViewManager 1.0.1
StatefulViewManager for iOS
⭐️ 1
🕓 4 years ago
iOS
.package(url: "https://github.com/john-crossley/StatefulViewManager.git", from: "1.0.1")

StatefulViewManager

Basic usage

StatefulViewManager is a simple library that will make handling various states easy.

  1. We need to bind our current UIViewController to stateful view manager. This can be done on viewDidLoad()
viewManager.attach(to: self)
  1. Next we need to register our controllers to various states, the available states are: .idle, loading, .loaded, .error, .empty and .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")
  1. Then simply call show to have that view switched out
viewManager.show(.empty)

viewManager.show(.custom("auth"))

✌️

GitHub

link
Stars: 1
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics