stinsen
stinsen copied to clipboard
Pushing from parent in nested NavigationCoordinatables
Hi there! I recently discovered Stinsen and really like it - thanks! However, I'm struggling to implement a specific flow.
Let's say that I have a parent NavigationCoordinatable, SetupCoordinatable
. It provides many sequential routes, akin to the common "wizard" flow:
- a profile setup view,
- a password setup view,
- a couple of setup views about the user's "interests":
- view A,
- view B,
- view C,
- a final, "congrats"-type view.
So nothing out of the ordinary for a lot of mobile apps.
Now, I'd like to make this last set of views reusable, so I move it to its own NavigationCoordinatable, InterestsSetupCoordinatable
. How can I push the last, "congrats" view, which belongs to the parent NavigationCoordinatable, without having to dismiss the whole child NavigationCoordinatable? Just calling .route
on the parent unfortunately doesn't push anything.
I guess that's because the NavigationStack which is displayed is the child's, not the parent, but I'm not sure how to go to implement this flow.
Any ideas?
Hi! Your assumption is correct. Hmm, a bit of a tricky layout, but should be doable. I haven't tried this solution, but by adding a third coordinator I think it should work. So you have the reusable flow as one flow (profile as root, password, interests as routes if I understand you correctly), and a third tutorial-flow (as root, it has the reusable flow, as a route, it uses the congrats view) which gets pushed from the initial coordinator when you start the app for the first time. You can then from the reusable flow, when it is finished, check if you can find the tutorial coordinator in the view, and if it is present, push the "congrats" view.
Works like a charm indeed. But I admit that I don't really get why it works. Care to explain, if you have time ?
This might actually be a bug. When I designed this, I didn't think anyone would ever push something to a coordinator which isn't the one at top of the stack, but your use-case makes sense. I'll do some investigation and decide if it needs to be fixed...
I think it's an interesting use case – let me know if I can help in any way!
This might actually be a bug. When I designed this, I didn't think anyone would ever push something to a coordinator which isn't the one at top of the stack, but your use-case makes sense. I'll do some investigation and decide if it needs to be fixed...
I'm facing this exact issue as well, in my flow I also want the "middle steps" to be reusable. It would be nice to fix. (So I have a coordinator as one "Route" of another, I want to push a screen from parent coordinator after this middle coordinator finishes its steps, that I expect a coordinator should be able to handle this)
This might actually be a bug. When I designed this, I didn't think anyone would ever push something to a coordinator which isn't the one at top of the stack, but your use-case makes sense. I'll do some investigation and decide if it needs to be fixed...
Is any updated on this matter