Keep the iPhone screen awake for the whole app session

Move the idle-timer disable out of ExerciseView/ExerciseProgressView and
up to the app scene, re-asserting it whenever the scene becomes active
(iOS clears the flag on background). A propped-up phone now stays lit for
the entire workout, not just while an exercise is open.

Claude-Session: https://claude.ai/code/session_01SCv7zvGFcKy47KSTnTLxRe
This commit is contained in:
2026-06-20 21:48:03 -04:00
parent a16e8ec270
commit b911818587
4 changed files with 9 additions and 10 deletions
+8
View File
@@ -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 {