SPB Git

Repository Public MIT

example-glass-thinking-indicator.txt 1.9 KB 48 lines text

1import SwiftUI2import SPGlassKit34public struct GlassThinkingIndicatorExample: GlassExample {5    public static let componentID = "glass-thinking-indicator"67    /// Fictitious activity labels, written by the host — never text coming from a model.8    private let stages: [(kind: GlassActivityKind, label: String)] = [9        (.thinking, "Preparing the sample answer"),10        (.searching, "Searching the sample library"),11        (.reading, "Reading 3 sample documents"),12        (.writing, "Writing the summary"),13        (.waiting, "Waiting for your confirmation"),14    ]15    @State private var stage = 01617    public init() {}1819    public var body: some View {20        VStack(alignment: .leading, spacing: 16) {21            Text("Sample data · simulated activity")22                .font(.caption)23                .foregroundStyle(.secondary)2425            GlassThinkingIndicator(stages[stage].kind, label: stages[stage].label)26            GlassButton("Next activity", systemImage: "forward.end") {27                stage = (stage + 1) % stages.count28            }2930            Divider()31            ForEach(stages.indices, id: \.self) { index in32                GlassThinkingIndicator(stages[index].kind, label: stages[index].label, announcesChanges: false)33            }34            GlassThinkingIndicator(.custom(systemImage: "arrow.down.circle"), label: "Downloading the sample model, which has a long label that wraps on narrow screens", announcesChanges: false)35            GlassThinkingIndicator(announcesChanges: false)3637            Divider()38            Text("Reduce Motion (simulated): static symbol")39                .font(.caption)40            GlassThinkingIndicator(.searching, label: "Searching the sample library", announcesChanges: false)41                .glassSimulatedAccessibility(reduceMotion: true)42        }43        .padding()44    }45}4647#Preview("GlassThinkingIndicator") { GlassThinkingIndicatorExample().glassTheme(.crystal) }48
Files main
Menu

Theme