SPB Git

Repository Public MIT

doc-glass-map-panel.md 4.6 KB 86 lines markdown

1# GlassMapPanel23| | |4|---|---|5| Identifier | `glass-map-panel` |6| Module | `SPGlassMaps` |7| Kind | `native-wrapper` on compact widths (the system sheet); on regular widths and macOS the panel is a `glassSurface` floating over the map |8| Platforms | iOS 26, iPadOS 26, macOS 26 |9| Example | `Examples/Gallery/Maps/GlassMapPanelExample.swift` |1011## Minimal usage1213```swift14GlassMapPanel("Nearby", isPresented: $showsResults, detent: $detent) {15    MapView()16} content: {17    GlassMapResultList(results: results) { result in select(result) }18}19```2021## Variants2223| Form | When | What |24|---|---|---|25| Sheet | Compact width on iOS and iPadOS (iPhone, narrow iPad windows) | `.sheet` with three detents and `presentationBackgroundInteraction(.enabled(upThrough: .medium))`: the map stays interactive at `peek` and `half`. |26| Side panel | Regular width, and always on macOS | A glass panel over the leading edge of the map, about a third of the width (280…380 points), with collapse and close buttons. The rest of the map stays interactive. |27| Docked | Only on request, with `form: .docked` | A glass panel at the bottom of the map's own bounds with a grabber: drag it, or activate it, to move between the three detents. For a map that takes only part of the screen, where a system sheet would cover content that is not the map. |2829| Detent | Sheet | Side panel | Docked |30|---|---|---|---|31| `.peek` | 96 points: title only | Collapsed to the title | 96 points: grabber and title |32| `.half` | System medium detent | Content up to 360 points high | 55 % of the map's height |33| `.full` | System large detent (map not interactive) | Full height | The map's height less a margin |3435## Parameters3637| Parameter | Type | Default | Meaning |38|---|---|---|---|39| `title` | `LocalizedStringKey` | — | Heading of the panel. |40| `isPresented` | `Binding<Bool>` | — | Whether the panel is shown. |41| `detent` | `Binding<GlassMapPanelDetent>` | — | How far the panel is extended. |42| `isDismissable` | `Bool` | `true` | When false the sheet cannot be swiped away and the side panel has no close button. |43| `form` | `GlassMapPanelForm?` | `nil` | Forces `.sheet`, `.side` or `.docked`. `nil` picks the sheet on compact widths and the side panel elsewhere. |44| `map` | `@ViewBuilder` | — | The map, any view. |45| `content` | `@ViewBuilder` | — | Search field, results, details. |4647`GlassMapResultList(results:selection:onSelect:)` is a ready-made content: rows with a tinted icon tile, a title, a subtitle and an optional trailing detail (a distance, a travel time), a tint and a checkmark on the selected row, the selection callback, and "No results" when the list is empty. `GlassMapResult` is `id`, `title`, `subtitle`, `systemImage`, `detail`.4849## States5051Hidden, peek, half, full. In the result list: normal, selected, empty.5253## Advanced example5455```swift56GlassMapPanel("Listings", isPresented: .constant(true), detent: $detent, isDismissable: false) {57    Map(position: $engine.position, selection: $selection) { /* annotations */ }58        .overlay(alignment: .topTrailing) { GlassMapControls(engine: engine).padding() }59} content: {60    VStack(alignment: .leading) {61        TextField("Search this area", text: $query)62            .textFieldStyle(.roundedBorder)63        GlassMapResultList(results: model.results(matching: query), selection: selection) { result in64            selection = result.id65            detent = .peek                      // free the map to show the selected place66        }67    }68}69```7071## Accessibility7273- The title has the header trait. The side panel's buttons are labelled "Collapse" / "Expand" and "Close".74- Result rows are buttons combining title and subtitle; the selected row has the `.isSelected` trait and a checkmark.75- The sheet keeps the system's behaviour (drag indicator, VoiceOver detent actions, keyboard avoidance).76- With Reduce Transparency the side panel becomes an opaque themed surface.7778## Limits7980- The form is chosen from the horizontal size class and the platform (`GlassMapPanelLayout.form`); it changes when an iPad window becomes compact.81- A sheet is modal for assistive technologies even when the map behind it accepts touches.82- In the sheet form, while the map is interactive (`peek`, `half`), a tap on the map does not dismiss the sheet.83- The side panel is not resizable by dragging; it has three sizes.84- Dense content inside the side panel sits on glass: keep it to a list of results or short details, as the system does in Maps.85- The interaction between a live map and the sheet was compiled but not exercised in a running application during verification; the form, detent and width decisions are unit-tested.86
Files main
Menu

Theme