Question re: nesting push-able `Coordinators` inside a `NavigationCoordinator`
chefnobody opened this issue · 1 comments
My app's root has a NavigationCoordinator
which is fine.
However, one of the Routes it responds to pushes a ViewController that has many possible Routes and is it self fairly complicated. I'd like to hide all of its Routes and complexity inside another Coordinator
that also pushes onto the root NavigationCoordinator
.
However I haven't sorted out to do this with either a RedirectionRouter
or some other type of Coordinator
. If I make my sub Coordinator a NavigationCoordinator
and then in response to a Route transition on the root-level NavigationCoordinator
return .push(subCoordinator)
I get the following UIKit exception for obvious reasons:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
What's the right/idimoatic way to do this with XCoordinator
? I can't find a precise example either in the sample project or the documentation.
Update:
If I do something like this my SubCoordinator's root screen is suddenly visible but w/o the push animation I'd expect. How might I ensure that push animation happens correctly? When I'm pushing a NavigationCoordinator
from inside a route handled by different NavigationCoordinator
?
case .subRoute:
addChild(SubCoordinator(rootViewController: rootViewController))
return .none()
}
Well, I've just discovered that if in my SubCoordinator: NavigationCoordinator<SubRoute>
initializer I change the super.init
call from this:
super.init(
rootViewController: rootViewController,
initialRoute: .someRoute
)
To this:
super.init(
rootViewController: rootViewController,
initialRoute: nil
)
trigger(.someRoute)
Everything works as expected. It's not yet clear to me why. Perhaps providing an initialRoute does not explicitly perform the animation and the trigger
ensures that it does.