#if DEBUG import SwiftUI import SwiftData /// DEBUG-only root used for App Store screenshot capture. Bypasses the iCloud gate and /// renders one fully-formed screen (chosen by `--screen`) against the seeded cache, so /// captures are deterministic with no UI automation. Never compiled into release. struct ScreenshotRootView: View { let services: AppServices private var activeWorkout: Workout? { let context = services.container.mainContext var descriptor = FetchDescriptor(sortBy: [SortDescriptor(\.start, order: .reverse)]) descriptor.fetchLimit = 25 let workouts = (try? context.fetch(descriptor)) ?? [] return workouts.first { $0.status == .inProgress } ?? workouts.first } var body: some View { content .environment(services) .environment(services.syncEngine) .modelContainer(services.container) } @ViewBuilder private var content: some View { if let workout = activeWorkout { switch ScreenshotSeed.screen(default: "workouts") { case "exercise": let logID = WorkoutDocument(from: workout).logs.first { $0.exerciseName == "Bench Press" }?.id NavigationStack { ExerciseView(workout: workout, logID: logID ?? "") } case "settings": SettingsView() default: NavigationStack { WorkoutLogListView(workout: workout) } } } else { Color(.systemBackground) } } } #endif