SPB Git

Repository Public MIT

example-glass-sheet.txt 1.3 KB 40 lines text

1import SwiftUI2import SPGlassKit34public struct GlassSheetExample: GlassExample {5    public static let componentID = "glass-sheet"6    @State private var showsFilters = false7    @State private var showsTerms = false8    @State private var keyword = ""9    @State private var onlyAvailable = true1011    public init() {}1213    public var body: some View {14        VStack(spacing: 16) {15            GlassButton("Filters", systemImage: "line.3.horizontal.decrease") { showsFilters = true }16            GlassButton("Terms of use") { showsTerms = true }17        }18        .padding()19        .glassSheet(isPresented: $showsFilters, title: "Filters", configuration: .halfAndFull) {20            Form {21                TextField("Keyword", text: $keyword)22                Toggle("Only available", isOn: $onlyAvailable)23            }24        }25        .glassSheet(26            isPresented: $showsTerms,27            title: "Terms of use",28            configuration: GlassSheetConfiguration(detents: [.fraction(0.4), .large], isInteractiveDismissDisabled: true)29        ) {30            ScrollView {31                Text("Sample terms. This sheet cannot be swiped away: the close button is the way out.")32                    .frame(maxWidth: .infinity, alignment: .leading)33                    .padding()34            }35        }36    }37}3839#Preview("GlassSheet") { GlassSheetExample() }40
Files main
Menu

Theme