In iOS 16, I have a 3-column Sidebar-Content-Detail view. When the Sidebar selection changes, I would like to refresh (clear) the detail view.
var body: some View {
NavigationSplitView {
List(Content.allCases, selection: $selectedContent) { content in
NavigationLink(content.localizedName, value: content)
}
.navigationTitle("Sidebar")
} content: {
List(
dataModel.details(in: selectedContent),
selection: $selectedDetail)
{ detail in
NavigationLink(detail.name, value: detail)
}
.navigationTitle(selectedContent?.localizedName ?? "")
} detail: {
MyDetail(recipe: selectedDetail)
}
}
I would guess that, upon a change in the Sidebar, I would need to set selectedDetail
to nil. But how do I capture a sidebar change?