1

Scenario I have a wizard that all work on the same data object which is passed from step to step.

Steps:

  1. Start
  2. Some input values
  3. 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.

Tobonaut
  • 2,245
  • 2
  • 26
  • 39
  • It is too wide, try to do some code and then show where you get problem, if any. – Asperi Jul 06 '22 at 15:32
  • Btw, novigationDestination can be at any navigation level inside NavigationStack. And this one should be helpful for multi-data path usage https://github.com/Asperi-Demo/4SwiftUI/blob/master/PlayOn_iOS/PlayOn_iOS/Findings/TestNavigationStackDynamicPath.swift. – Asperi Jul 06 '22 at 15:40

0 Answers0