I'm working on a two-pane SwiftUI app with a sidebar and detail pane in a DoubleColumnNavigationView
.
I would like to open a NavigationLink
from the toolbar of the sidebar into the detail pane, as seen in "open from sidebar" in the gif below).
However, the view opens as a stack instead, as seen in "open from toolbar" in the gif below.
Using isDetailLink(true)
appears to have no effect.
struct ContentView: View {
var body: some View {
NavigationView {
List {
NavigationLink(destination: Text("Opened from sidebar")) {
Text("Open from sidebar")
}
}.listStyle(SidebarListStyle())
.navigationTitle("Sidebar")
.toolbar {
ToolbarItem {
// This should open in detail pane
NavigationLink(destination: Text("Opened from toolbar")) {
Text("Open from toolbar")
}
}
}
Text("Detail pane")
}.navigationViewStyle(DoubleColumnNavigationViewStyle())
}
}