onmyway133 / blog

🍁 What you don't know is what you haven't learned
https://onmyway133.com/
MIT License
669 stars 33 forks source link

How to use NavigationSplitView and NavigationStack in SwiftUI #924

Open onmyway133 opened 1 year ago

onmyway133 commented 1 year ago

Note

NavigationSplitView

the navigation split view coordinates with the List in its first column, so that when people make a selection, the detail view updates accordingly. Programmatic changes that you make to the selection property also affect both the list appearance and the presented detail view

The selection in the first column affects the second, and the selection in the second column affects the third

NavigationStack

By default, a navigation stack manages state to keep track of the views on the stack

Reset NavigationStack when changing selection of NavigationSplitView

Even if no path parameter is provided to a NavigationStack, value-based navigation links will append to an implicit path tracked for you by the Navigation system. Where view-based navigation links will not. When selection changes in the sidebar, the navigation system pops value-based links off the stack.