SPB Git

Repository Public MIT

example-glass-banner.txt 1.4 KB 38 lines text

1import SwiftUI2import SPGlassKit34public struct GlassBannerExample: GlassExample {5    public static let componentID = "glass-banner"6    @State private var showsWarning = true7    @State private var retryCount = 089    public init() {}1011    public var body: some View {12        ScrollView {13            VStack(spacing: 12) {14                GlassBanner(.information, title: "Maintenance on Sunday", message: "The sample service will be read-only from 2:00 to 4:00.")15                GlassBanner(.success, title: "Payment received")16                if showsWarning {17                    GlassBanner(18                        .warning,19                        title: "Your card expires soon",20                        message: "Update your payment method before the end of the month to avoid an interruption.",21                        action: GlassBannerAction("Update card") { showsWarning = false },22                        onDismiss: { showsWarning = false }23                    )24                }25                GlassBanner(26                    .error,27                    verbatim: "Synchronisation failed (attempt \(retryCount + 1))",28                    message: "The server did not answer.",29                    action: GlassBannerAction("Retry") { retryCount += 1 }30                )31            }32            .padding()33        }34    }35}3637#Preview("GlassBanner") { GlassBannerExample().glassTheme(.emerald) }38
Files main
Menu

Theme