ios-template
ios-template copied to clipboard
Unbalanced calls to begin/end appearance transition
Currently the app coordinator launches the app with:
func start(animated: Bool, completion: VoidClosure?) {
// Configure window/root view controller
window.setRootViewController(rootController, animated: false, completion: {
self.window.makeKeyAndVisible()
// Spin off auth coordinator
This creates a warning about unbalanced calls to the rootController which is not guaranteed to have finished displaying.
I'm proposing that we fix this one of two ways:
// Simply
window.setRootViewController(rootController, animated: false, completion: {
self.window.makeKeyAndVisible()
DispatchQueue.main.async {
// Spin off auth coordinator
or
// a more complex but "more correct" solution, something like:
struct LaunchBehavior: ViewControllerLifecycleBehavior {
let onLaunch: VoidClosure
func afterAppearing(_ viewController: UIViewController, animated: Bool) {
onLaunch()
}
}
func start(animated: Bool, completion: VoidClosure?) {
let onLaunch = LaunchBehavior() { [weak self] in
// Spin off auth coordinator
}
rootController.addBehaviors([onLaunch])
window.setRootViewController(rootController, animated: false, completion: {
self.window.makeKeyAndVisible()
})
Addressed in part in #75
This approach to presenting different coordinator flows also has a side effect of showing a "flash" of the main UI before the on-boarding or login flows appear. Another approach to fix both problems might be to manage the variable UI with a container VC, maybe a UINavigationController, that can be created with a "stack" of VCs, without having to show/present each one...