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