SPB Git

Repository Public MIT

doc-glass-sheet.md 3.3 KB 78 lines markdown

1# GlassSheet23| | |4|---|---|5| Identifier | `glass-sheet` |6| Module | `SPGlassComponents` |7| Kind | `native-wrapper` — the system `.sheet`; the system draws the sheet and its glass |8| Platforms | iOS 26, iPadOS 26, macOS 26 |9| Example | `Examples/Gallery/Containers/GlassSheetExample.swift` |1011## Minimal usage1213```swift14.glassSheet(isPresented: $showsFilters, title: "Filters") {15    FiltersForm()16}17```1819## Variants2021| Variant | Use |22|---|---|23| `isPresented:` | Presentation driven by a Boolean. |24| `item:` | Presentation driven by an optional `Identifiable` value. |25| `.standard` | Full height, drag indicator, close button. |26| `.halfAndFull` | Rests at half height, can be pulled to full height. |27| Custom detents | `.medium`, `.large`, `.fraction(0.1...1)`, `.height(≥ 44)`. |2829## Parameters3031| Parameter | Type | Default | Meaning |32|---|---|---|---|33| `isPresented` / `item` | `Binding<Bool>` / `Binding<Item?>` | — | Presentation state. |34| `title` | `LocalizedStringKey?` | `nil` | Title of the sheet's bar. |35| `configuration` | `GlassSheetConfiguration` | `.standard` | Options below. |36| `onDismiss` | `(@MainActor () -> Void)?` | `nil` | Called after dismissal. |37| `content` | `@ViewBuilder` | — | Content of the sheet. |3839`GlassSheetConfiguration`:4041| Field | Default | Meaning |42|---|---|---|43| `detents` | `[.large]` | Resting heights; an empty list means full height. Out-of-range values are normalised. |44| `showsDragIndicator` | `true` | Drag indicator visibility. |45| `showsCloseButton` | `true` | System close button (`ButtonRole.close`) in the bar. |46| `isInteractiveDismissDisabled` | `false` | Blocks swipe-to-dismiss; the close button still works. |47| `scrollDismissesKeyboard` | `true` | Scrolling inside the sheet dismisses the keyboard interactively. |4849## States5051Presented or not, owned by the host. The current detent is managed by the system.5253## Advanced example5455```swift56.glassSheet(item: $editedContact, title: "Edit contact",57            configuration: GlassSheetConfiguration(detents: [.fraction(0.45), .large], isInteractiveDismissDisabled: hasChanges)) { contact in58    ContactForm(contact: contact)59        .toolbar {60            ToolbarItem(placement: .confirmationAction) { Button("Save") { save(contact) } }61        }62}63```6465## Accessibility6667- The close button uses the system close role: the system provides its symbol and its localised label, and it sits in the cancellation placement where assistive technologies expect it.68- The title is a navigation title, announced as a heading.69- Keyboard avoidance, focus trapping and the Escape key are the system's.70- With `isInteractiveDismissDisabled`, keep `showsCloseButton` on (or provide your own way out) so the sheet can always be left.7172## Limits7374- When a title or the close button is requested, the content is wrapped in a `NavigationStack` so that it can also add toolbar items. Pass `title: nil` and `showsCloseButton: false` to present the content bare.75- GlassKit adds no background: at partial height the system draws the Liquid Glass sheet. Do not add a glass surface inside.76- Detents have no effect on macOS, where sheets are sized by their content.77- The mapping to `PresentationDetent` is tested; the presentation itself was compiled for iOS and macOS but not exercised in a running application by the automated tests.78
Files main
Menu

Theme