Keep the screen awake during workouts; fix watch timers freezing
- iPhone: disable the idle timer while the exercise detail screen is open, so the display no longer sleeps mid-set. - Watch: the work/rest timers counted on a run-loop Timer that watchOS throttles in the Always-On (wrist-down) state, so they froze. Anchor both to a wall-clock Date rendered with SwiftUI's self-updating timer text; rest haptics + auto-advance now derive from the end time so they catch up after a stall instead of stalling.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
import Charts
|
||||
import UIKit
|
||||
|
||||
struct ExerciseView: View {
|
||||
@Environment(SyncEngine.self) private var sync
|
||||
@@ -66,6 +67,11 @@ 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
|
||||
}
|
||||
.onDisappear {
|
||||
UIApplication.shared.isIdleTimerDisabled = false
|
||||
}
|
||||
// Reflect external changes (e.g. a set completed on the watch) live. Each edit
|
||||
// rewrites the whole workout file, so the cache always holds the latest — pulling
|
||||
|
||||
Reference in New Issue
Block a user