Top level navigation with NavigationSplitView #2009
Replies: 3 comments
-
If the state of each top level feature is persisted when switching between sections, the top level navigation could be represented as a enum with the state of each top level feature as an associated value, and presented with something like SwitchStore in the |
Beta Was this translation helpful? Give feedback.
-
The The following iOS 13 NavigationLink works without the need to nest Option3View inside a NavigationStack. However there is no navigation bar or animation. So, using a navigationDestination modifier in the content property above seems to be off the table.
IOW, in regards to TCA navigation, NavigationSplitView seems to have it's own context, compared with NavigationStackView. Attempts to treat columns like a navigation stack doesn't seem to work, etc. |
Beta Was this translation helpful? Give feedback.
-
Working thought this, it seems the problem is with SwiftUI. The new TCA augmented Apparently, when using a If so, each destination block may take several nested |
Beta Was this translation helpful? Give feedback.
-
I'm working on an application that uses NavigationSplitView and runs on an iPhone and iPad. At the top level, each feature has its own state which needs to be maintained when switching between each sidebar. As such, using the presence of optional state to switch between top level functions is problematic. While we would not want to create the state for each top level feature until the user selects that section, setting it to nil when navigating away from it would result in the loss of context.
What is the best way to approach this? Should each top level feature stash away that state via some effect before navigating way, then restore it when the user switches back?
In addition, while I'm sure I could split this out into separate views, my sidebar view currently looks the following.
I was using the NavigationDestination unwrapping case variant, but that caused console errors in 16.4 when nesting a NaviationStack in the destination. In addition there were cases where the top level state currentSelection property was set nil when switching sections. I know support for iOS 16 is in the works, but will those future tools include support for NavigationSplitView in scenarios like this?
Beta Was this translation helpful? Give feedback.
All reactions