Using SwiftUI on macOS, how can I add a toolbar item on the right-most (trailing) edge of the window's toolbar when an Inspector is used?
At the moment, the toolbar items are all left-of (leading) the split view tracking separator. I want the inspector toolbar item to be placed similar to where Xcode's Inspector toolbar item is placed: always as far right (trailing) as possible.
NavigationSplitView {
// ... snip
} detail: {
// ... snip
}
.inspector(isPresented: $isInspectorPresented) {
InspectorContentView()
}
.toolbar {
// What is the correct placement value here?
ToolbarItem(placement: .primaryAction) {
Button {
isInspectorPresented.toggle()
} label: {
Label("Toggle Inspector", systemImage: "sidebar.trailing")
}
}
}
See the attached screenshot. When the InspectorView is toggled open, the toolbar item tracks leading the split view tracking separator, which is not consistent with how Xcode works.