Here are some code snapshots:
struct TopListState: Equatable {
var rows: IdentifiedArrayOf<Row> = [
.init(value: 1),
.init(value: 2),
.init(value: 3),
.init(value: 4),
.init(value: 5),
.init(value: 6),
.init(value: 7)
]
var selection: Identified<Row.ID, CategoriesState>? <--- For navigation
}
Then in my top list view:
var body: some View {
NavigationView {
WithViewStore(self.store) { viewStore in
List {
ForEach(viewStore.rows) { row in
NavigationLink(
destination: IfLetStore(
self.store.scope(
state: \.selection?.value,
action: TopListAction.categories),
then: CategoriesView.init(store:)
),
tag: row.id,
selection: viewStore.binding(
get: \.selection?.id,
send: TopListAction.setNavigation(selection:) <--- This will get call for nested navigation
)
) {
Text("\(row.value)")
}
}
}.navigationBarTitle("Top List")
}
}
}
Here is a child list cell navigation link:
NavigationLink( <---- When that navigation get pushed, the upper navigation get popped and
destination: CategoryListView(data: self.category.data),
tag: self.category.id,
selection: self.selection
) {
Text("See All".uppercased())
.font(.headline)
}
Here is a working version using Playground