diff --git a/CHANGELOG.md b/CHANGELOG.md index 37e3ad8..b0bea97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Tapping an exercise on iPhone now opens a paged workout run — the same Ready The exercise detail and edit screen moved behind an Edit swipe on the trailing edge; the leading swipe still completes a set. -The iPhone screen now stays awake while an exercise is open, so it no longer sleeps mid-set. +The iPhone screen now stays awake the whole time the app is open, so a propped-up phone never sleeps during a workout. The Apple Watch is now a focused workout runner: it opens on the active workout's exercises (or prompts you to start one on iPhone) and lists every in-progress workout at the root. diff --git a/Workouts/Views/WorkoutLogs/ExerciseProgressView.swift b/Workouts/Views/WorkoutLogs/ExerciseProgressView.swift index fe0a5b7..1058592 100644 --- a/Workouts/Views/WorkoutLogs/ExerciseProgressView.swift +++ b/Workouts/Views/WorkoutLogs/ExerciseProgressView.swift @@ -181,8 +181,6 @@ struct ExerciseProgressView: View { } } .onAppear { - // Keep the screen lit while logging — a mid-workout sleep is annoying. - UIApplication.shared.isIdleTimerDisabled = true guard !didRestorePage else { return } if startsResumed { // Resume on the first unfinished set. A paged TabView can settle on page 0 @@ -199,9 +197,6 @@ struct ExerciseProgressView: View { didRestorePage = true } } - .onDisappear { - UIApplication.shared.isIdleTimerDisabled = false - } } /// Move to the resume page without animation, only if we're not already there diff --git a/Workouts/Views/WorkoutLogs/ExerciseView.swift b/Workouts/Views/WorkoutLogs/ExerciseView.swift index d02ff2e..ee53136 100644 --- a/Workouts/Views/WorkoutLogs/ExerciseView.swift +++ b/Workouts/Views/WorkoutLogs/ExerciseView.swift @@ -10,7 +10,6 @@ import SwiftUI import SwiftData import Charts -import UIKit struct ExerciseView: View { @Environment(SyncEngine.self) private var sync @@ -68,13 +67,10 @@ struct ExerciseView: View { .onAppear { refreshDocIfNeeded() progress = log?.currentStateIndex ?? 0 - // Keep the screen lit while logging sets — a mid-workout sleep is annoying. - UIApplication.shared.isIdleTimerDisabled = true // Take over this run: the watch parks and locks it while we're editing here. services.watchBridge.setEditingWorkout(workout.id) } .onDisappear { - UIApplication.shared.isIdleTimerDisabled = false services.watchBridge.setEditingWorkout(nil) } // Reflect external changes (e.g. a set completed on the watch) live. Each edit diff --git a/Workouts/WorkoutsApp.swift b/Workouts/WorkoutsApp.swift index 3c96586..e5352d3 100644 --- a/Workouts/WorkoutsApp.swift +++ b/Workouts/WorkoutsApp.swift @@ -7,10 +7,12 @@ import SwiftUI import SwiftData +import UIKit @main struct WorkoutsApp: App { @State private var services = AppServices() + @Environment(\.scenePhase) private var scenePhase var body: some Scene { WindowGroup { @@ -24,6 +26,12 @@ struct WorkoutsApp: App { root #endif } + // Keep the screen lit for the whole app, not just while logging — the phone is + // often propped up across the room during a workout. iOS clears this flag when + // the app is backgrounded, so re-assert it each time the scene becomes active. + .onChange(of: scenePhase, initial: true) { _, phase in + UIApplication.shared.isIdleTimerDisabled = (phase == .active) + } } private var root: some View {