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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user