MyApp/RetroPreviews.swift
2.4 KB · 48 lines · swift · Download from the repository page
import SwiftUI #if DEBUG@MainActorstruct RetroDevelopmentPreview: View { let screen: Int @State private var flow = GameFlowStore(game: GameSessionStore(persistenceEnabled: false), persist: false, requestPermissions: { true }) var body: some View { VStack(spacing: 0) { Text("DEVELOPMENT FIXTURE • NOT SAVED").font(.caption.monospaced().bold()) .padding(8).frame(maxWidth: .infinity).background(RetroTheme.pink) switch screen { case 0, 1: GuidedSetupView(flow: flow) case 2: ScrollView { HostDashboard(game: flow.game).padding(20) } .safeAreaInset(edge: .bottom) { GameActionBar(game: flow.game) } case 3: ScoreboardView(game: flow.game) case 4: GalleryView(game: flow.game) default: if let attempt = flow.game.current { ClipPlayerView(game: flow.game, attempt: attempt) } } }.retroAppearance() .task { flow.stage = screen == 0 ? .consent : screen == 1 ? .setup : .game flow.draft.recording = false let game = flow.game game.recordingMode = false game.phase = .ready let snapshot = ChallengeSnapshot(id: UUID(), sessionID: game.sessionID, player: game.players[0], host: game.players[1], promptID: "wave", instruction: "Simon says, wave.", simonSays: true, fingers: 3, responseDuration: 6, created: Date()) var attempt = Attempt(snapshot: snapshot) attempt.duration = 9 // An intentionally missing media fixture exercises the honest unavailable/retry state. attempt.rawFile = "development-missing.mov" attempt.history = [VerdictChange(verdict: .correct, date: Date())] game.attempts = [attempt]; game.current = attempt } }}#Preview("Consent • development fixture") { RetroDevelopmentPreview(screen: 0) }#Preview("Setup • development fixture") { RetroDevelopmentPreview(screen: 1) }#Preview("Game • development fixture") { RetroDevelopmentPreview(screen: 2) }#Preview("Scoreboard • development fixture") { RetroDevelopmentPreview(screen: 3) }#Preview("Clips • development fixture") { RetroDevelopmentPreview(screen: 4) }#Preview("Clip preview unavailable • development fixture") { RetroDevelopmentPreview(screen: 5) }#endif