Scenario I have a wizard that all work on the same data object which is passed from step to step.
Steps:
- Start
- Some input values
- Finish (draft becomes a actual db entry)
Current solution
Currently I use the old but working NavigationLink(isActive: ...)
. Now, I try to port my app to the new SwiftUI alongside iOS 16. That means the "old" NavigationLink
is outdated. I tried NavigationStack
with or without a $path
, etc. pp
What's my actual problem?
All examples or great answers on SO I found (also from Apple) are "too simple" - I guess. I do not have a list, my navigation is "next"-Button-based. My "Destination view" is not just a TextField
and I do not have a strict navigation flow (in future, there will be optional steps in between) as in the WWDC22 sample.
A step (aka View) will be also used in another wizard, too. Is this a good idea?
What I think, I need
My "wizard container view" I call it "flow" which embeds all other steps has to have a NavigationStack($path) {}
component.
I have to make the path
isn e.g. an EnvironmentObject
that I can easily access and modify it during my wizard run from each child view.
I need a mapping using .navigationDestination(for: WizardNavigation.self) { switch ... }
to show the requested next step.
But, what do I miss?
It feels over complicated and, again, to strict in navigation. The parent has to know all possible navigation destinations?
Please tell me, that I miss a big point that simplifies my whole approach.