Files
workouts/Workouts/WorkoutsApp.swift
rzen b911818587 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
2026-06-20 21:48:03 -04:00

46 lines
1.3 KiB
Swift

//
// WorkoutsApp.swift
// Workouts
//
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
//
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 {
#if DEBUG
if ScreenshotSeed.isActive {
ScreenshotRootView(services: services)
} else {
root
}
#else
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 {
RootGateView()
.environment(services)
.environment(services.syncEngine)
.environment(services.liveRunState)
.modelContainer(services.container)
.task { await services.bootstrap() }
}
}