QuickBirdEng / XCoordinator

🎌 Powerful navigation library for iOS based on the coordinator pattern
MIT License
2.27k stars 179 forks source link

Substitution of root view #146

Closed sanchezsanya closed 5 years ago

sanchezsanya commented 5 years ago

To switch between login, home screen and onboarding screens, I do the following (3 root views):

return .multiple(
            .dismissAll(), .presentFullScreen(coordinator, animation: animation))

But this does not work due to the fact that the .presentFullScreen begins to be executed before the animation of the dismissAll is completed, because of this transition

How i call dismissAll without animation (set animation to false)?

static func dismissAll() -> Transition { return Transition(presentables: [], animationInUse: nil) { rootViewController, options, completion in guard let presentedViewController = rootViewController.presentedViewController else { completion?() return } presentedViewController.dismiss(animated: options.animated) { Transition.dismissAll() .perform(on: rootViewController, with: options, completion: completion) } } }

Here we can see (animated: options.animated), how i can set options.animated to false from prepareTransition method in coordinator?

P.S. dismissAll need for logout from anywhere, if accessToken is invalid (dismiss all coordinators)

pauljohanneskraft commented 5 years ago

Hey.

You can change the TransitionOptions when triggering a route or by overriding them as specified in https://github.com/quickbirdstudios/XCoordinator/issues/136.

Keep in mind that dismissAll does not dismiss the rootViewController - only its presentedViewControllers. If you want to dismiss the rootViewController as well, you will need to perform .dismiss after .dismissAll. Also, if rootViewController is the rootViewController of your window, then .dismiss will not work. Instead, you will need to call setRoot or similar for the new coordinator.

sanchezsanya commented 5 years ago

Thank you!

pauljohanneskraft commented 5 years ago

I'm closing this now assuming that the provided solution solved the issue.