SPB Git

Repository Public MIT

glass-map-panel.md 4.0 KB 84 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. |2728| Detent | Sheet | Side panel |29|---|---|---|30| `.peek` | 96 points: title only | Collapsed to the title |31| `.half` | System medium detent | Content up to 360 points high |32| `.full` | System large detent (map not interactive) | Full height |3334## Parameters3536| Parameter | Type | Default | Meaning |37|---|---|---|---|38| `title` | `LocalizedStringKey` | — | Heading of the panel. |39| `isPresented` | `Binding<Bool>` | — | Whether the panel is shown. |40| `detent` | `Binding<GlassMapPanelDetent>` | — | How far the panel is extended. |41| `isDismissable` | `Bool` | `true` | When false the sheet cannot be swiped away and the side panel has no close button. |42| `map` | `@ViewBuilder` | — | The map, any view. |43| `content` | `@ViewBuilder` | — | Search field, results, details. |4445`GlassMapResultList(results:selection:onSelect:)` is a ready-made content: rows with a symbol, a title and a subtitle, a checkmark on the selected row, the selection callback, and "No results" when the list is empty. `GlassMapResult` is `id`, `title`, `subtitle`, `systemImage`.4647## States4849Hidden, peek, half, full. In the result list: normal, selected, empty.5051## Advanced example5253```swift54GlassMapPanel("Listings", isPresented: .constant(true), detent: $detent, isDismissable: false) {55    Map(position: $engine.position, selection: $selection) { /* annotations */ }56        .overlay(alignment: .topTrailing) { GlassMapControls(engine: engine).padding() }57} content: {58    VStack(alignment: .leading) {59        TextField("Search this area", text: $query)60            .textFieldStyle(.roundedBorder)61        GlassMapResultList(results: model.results(matching: query), selection: selection) { result in62            selection = result.id63            detent = .peek                      // free the map to show the selected place64        }65    }66}67```6869## Accessibility7071- The title has the header trait. The side panel's buttons are labelled "Collapse" / "Expand" and "Close".72- Result rows are buttons combining title and subtitle; the selected row has the `.isSelected` trait and a checkmark.73- The sheet keeps the system's behaviour (drag indicator, VoiceOver detent actions, keyboard avoidance).74- With Reduce Transparency the side panel becomes an opaque themed surface.7576## Limits7778- The form is chosen from the horizontal size class and the platform (`GlassMapPanelLayout.form`); it changes when an iPad window becomes compact.79- A sheet is modal for assistive technologies even when the map behind it accepts touches.80- In the sheet form, while the map is interactive (`peek`, `half`), a tap on the map does not dismiss the sheet.81- The side panel is not resizable by dragging; it has three sizes.82- 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.83- 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.84
Files main
Menu

Theme