1 contributor
//
// SidebarToggleToolbar.swift
// USB Meter
//
import SwiftUI
extension View {
/// Adds a sidebar toggle button to the leading toolbar on Mac Catalyst.
/// No-op on other platforms. Apply to any top-level detail view reachable
/// from the sidebar so users can restore the sidebar if it was hidden.
func sidebarToggleToolbarItem() -> some View {
#if targetEnvironment(macCatalyst)
return self.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button {
UIApplication.shared.sendAction(
Selector(("toggleSidebar:")),
to: nil, from: nil, for: nil
)
} label: {
Image(systemName: "sidebar.left")
}
.help("Show Sidebar")
}
}
#else
return self
#endif
}
}