2018-11-19 14:31:37 +01:00
|
|
|
import UIKit
|
|
|
|
|
|
|
|
final class AppController {
|
|
|
|
|
|
|
|
static let shared = AppController()
|
|
|
|
|
|
|
|
var window: UIWindow!
|
|
|
|
var rootViewController: UIViewController? {
|
|
|
|
didSet {
|
|
|
|
if let vc = rootViewController {
|
|
|
|
window.rootViewController = vc
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
init() {
|
|
|
|
NotificationCenter.default.addObserver(
|
|
|
|
self,
|
|
|
|
selector: #selector(handleAuthState),
|
|
|
|
name: .loginStatusChanged,
|
|
|
|
object: nil
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func show(in window: UIWindow?) {
|
|
|
|
guard let window = window else {
|
|
|
|
fatalError("Cannot layout app with a nil window.")
|
|
|
|
}
|
|
|
|
|
|
|
|
window.backgroundColor = .black
|
|
|
|
self.window = window
|
|
|
|
|
|
|
|
rootViewController = SplashViewController()
|
|
|
|
window.makeKeyAndVisible()
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc func handleAuthState() {
|
|
|
|
if AuthController.isSignedIn {
|
2018-11-19 16:58:23 +01:00
|
|
|
rootViewController = NavigationController(rootViewController: NoteBiometricViewController())
|
2018-11-19 14:31:37 +01:00
|
|
|
} else {
|
|
|
|
rootViewController = AuthViewController()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|