f06c4e996e
Watch root lists every in-progress workout; picking an exercise runs a paged Ready -> work/rest -> Finish flow (One More + auto-firing Done), with a phase-dot row and brand-tinted count-up/down timers. Includes the configurable rest and auto-finish settings synced over WatchConnectivity and the wrist-down timer fix.
62 lines
2.1 KiB
Swift
62 lines
2.1 KiB
Swift
#if DEBUG
|
|
import SwiftUI
|
|
import SwiftData
|
|
|
|
/// DEBUG-only root for App Store screenshot capture on the watch. Renders one
|
|
/// fully-formed screen (chosen by `--screen`) against the seeded cache so captures are
|
|
/// deterministic. Never compiled into release.
|
|
struct WatchScreenshotRoot: View {
|
|
let services: WatchAppServices
|
|
|
|
private var activeWorkout: Workout? {
|
|
let context = services.container.mainContext
|
|
var descriptor = FetchDescriptor<Workout>(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.bridge)
|
|
.modelContainer(services.container)
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var content: some View {
|
|
if let workout = activeWorkout {
|
|
switch ScreenshotSeed.screen(default: "list") {
|
|
case "work":
|
|
ProgressHost(workout: workout, exerciseName: "Lat Pulldown", page: 0)
|
|
case "rest":
|
|
ProgressHost(workout: workout, exerciseName: "Lat Pulldown", page: 1)
|
|
default:
|
|
NavigationStack { WorkoutLogListView(workout: workout) }
|
|
}
|
|
} else {
|
|
Color.black
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Hosts the progress view with a working-copy binding and a pinned page (which also
|
|
/// suppresses the Ready lead-in), so we can capture a specific work or rest phase that
|
|
/// the normal resume logic wouldn't land on.
|
|
private struct ProgressHost: View {
|
|
@State private var doc: WorkoutDocument
|
|
private let logID: String
|
|
private let page: Int?
|
|
|
|
init(workout: Workout, exerciseName: String, page: Int?) {
|
|
let document = WorkoutDocument(from: workout)
|
|
_doc = State(initialValue: document)
|
|
logID = document.logs.first { $0.exerciseName == exerciseName }?.id ?? document.logs.first?.id ?? ""
|
|
self.page = page
|
|
}
|
|
|
|
var body: some View {
|
|
ExerciseProgressView(doc: $doc, logID: logID, onChange: {}, debugInitialPage: page)
|
|
}
|
|
}
|
|
#endif
|