SPB Git

Repository Public MIT

example-glass-popover.txt 1.2 KB 31 lines text

1import SwiftUI2import SPGlassKit34public struct GlassPopoverExample: GlassExample {5    public static let componentID = "glass-popover"6    @State private var showsDetails = false7    @State private var showsHelp = false89    public init() {}1011    public var body: some View {12        HStack(spacing: 24) {13            GlassIconButton(systemImage: "info", accessibilityLabel: "Price details") { showsDetails = true }14                .glassPopover(isPresented: $showsDetails, title: "Price details", arrowEdge: .top, compactAdaptation: .popover) {15                    Text("Sample price, taxes included.")16                        .padding()17                        .frame(minWidth: 220, alignment: .leading)18                }19            GlassButton("Help", systemImage: "questionmark.circle") { showsHelp = true }20                .glassPopover(isPresented: $showsHelp, title: "Help", compactAdaptation: .sheet) {21                    Text("On a compact width this popover becomes a sheet with a close button.")22                        .padding()23                        .frame(maxWidth: .infinity, alignment: .leading)24                }25        }26        .padding()27    }28}2930#Preview("GlassPopover") { GlassPopoverExample() }31
Files main
Menu

Theme