SPB Git

Repository Public MIT

doc-glass-navigation-bar.md 3.5 KB 80 lines markdown

1# GlassNavigationBar23| | |4|---|---|5| Identifier | `glass-navigation-bar` |6| Module | `SPGlassNavigation` |7| Kind | `native-wrapper` — a `NavigationStack` configured with `.navigationTitle` and `.toolbar` |8| Platforms | iOS 26, iPadOS 26, macOS 26 |9| Example | `Examples/Gallery/Navigation/GlassNavigationBarExample.swift` |1011## Minimal usage1213```swift14GlassNavigationBar("Inbox") {15    MessageList()16}17```1819## Variants2021| Variant | Use |22|---|---|23| `titleDisplay: .large` | Large title that collapses on scroll (iOS). |24| `titleDisplay: .inline` | Compact title, for detail pages. |25| `subtitle:` | Secondary line under the title (`navigationSubtitle`). |26| `leading:` / `trailing:` | Actions described by `GlassToolbarAction` values. |27| `.glassNavigationBar(...)` modifier | Configures the bar of a page pushed on an existing stack. |2829## Parameters3031| Parameter | Type | Default | Meaning |32|---|---|---|---|33| `title` | `LocalizedStringKey` | — | Title of the page. |34| `subtitle` | `LocalizedStringKey?` | `nil` | Subtitle. |35| `titleDisplay` | `GlassNavigationTitleDisplay` | `.automatic` | `.automatic`, `.inline` or `.large`. |36| `path` | `Binding<NavigationPath>?` | `nil` | Navigation path when the host drives navigation. |37| `leading` | `[GlassToolbarAction]` | `[]` | Actions at the leading edge. One is shown; others go to a menu. |38| `trailing` | `[GlassToolbarAction]` | `[]` | Actions at the trailing edge. |39| `content` | `@ViewBuilder` | — | Root page of the stack. |4041`GlassNavigationBarConfiguration` carries the same values when the title is a `Text` built elsewhere.4243## States4445The back button, its title and the swipe-back gesture are the system's. A disabled action is `isEnabled: false`. Trailing actions that do not fit move to a "More actions" menu: two stay on a compact width, four on a regular one, one at accessibility text sizes (`GlassNavigationBarLayout.trailingCapacity`).4647## Advanced example4849```swift50@State private var path = NavigationPath()5152GlassNavigationBar("Projects", titleDisplay: .large, path: $path, trailing: [53    GlassToolbarAction(id: "new", title: "New project", systemImage: "plus",54                       shortcut: KeyboardShortcut("n"), priority: .high) { create() },55    GlassToolbarAction(id: "filter", title: "Filter", systemImage: "line.3.horizontal.decrease") { showFilter() },56]) {57    ProjectList()58        .navigationDestination(for: Project.ID.self) { id in59            ProjectView(id: id)60                .glassNavigationBar("Project", titleDisplay: .inline, trailing: [61                    GlassToolbarAction(id: "delete", title: "Delete", systemImage: "trash", role: .destructive) { delete(id) },62                ])63        }64}65```6667## Accessibility6869- Every action has a title: it is the VoiceOver label, the tooltip on macOS and the menu title when the action overflows.70- With an accessibility text size on a compact width, a large title is shown inline so that it does not fill the screen, and only one trailing action stays in the bar.71- Bar buttons get the system's large content viewer at accessibility sizes.72- Keyboard shortcuts of the actions work whether the action is in the bar or in the menu.7374## Limits7576- The bar, its glass and the back button cannot be restyled; the theme only supplies the tint.77- `titleDisplay` has no effect on macOS, which shows the title in the window toolbar.78- Do not nest a `GlassNavigationBar` inside another navigation stack; use the modifier on pushed pages.79- Behaviour at accessibility sizes was verified through the layout functions and compilation, not on a running device.80
Files main
Menu

Theme