Repository Public MIT
1import SwiftUI2import SPGlassKit34public struct GlassBadgeExample: GlassExample {5 public static let componentID = "glass-badge"6 @State private var unread = 778 public init() {}910 public var body: some View {11 VStack(alignment: .leading, spacing: 16) {12 HStack(spacing: 12) {13 Text("Inbox")14 GlassBadge(count: unread)15 Spacer()16 Stepper("Unread", value: $unread, in: -1...150, step: 31).labelsHidden()17 }18 HStack(spacing: 12) {19 GlassBadge("New", tone: .accent)20 GlassBadge("Beta")21 GlassBadge("−12 %", tone: .critical)22 GlassBadge(count: 0, showsZero: true, tone: .neutral)23 }24 HStack(spacing: 12) {25 GlassBadge("Paid", tone: .success, style: .soft)26 GlassBadge("Due soon", tone: .warning, style: .soft)27 GlassBadge("Draft", style: .outline)28 GlassBadge(status: "Online", tone: .success, style: .soft)29 }30 Image(systemName: "bell")31 .font(.title2)32 .frame(width: 44, height: 44)33 .glassBadge(count: unread)34 .accessibilityLabel("Notifications")35 VStack(alignment: .leading, spacing: 8) {36 GlassBadge(status: "Online", tone: .success)37 GlassBadge(status: "Degraded", tone: .warning)38 GlassBadge(status: "Offline", tone: .critical)39 GlassBadge(status: "Unknown", tone: .neutral)40 }41 }42 .padding()43 }44}4546#Preview("GlassBadge") { GlassBadgeExample().glassTheme(.aurora) }47