wip
This commit is contained in:
@ -12,9 +12,12 @@ import SwiftUI
|
||||
import SwiftData
|
||||
import CloudKit
|
||||
import CoreData
|
||||
import UIKit
|
||||
|
||||
@main
|
||||
struct WorkoutsApp: App {
|
||||
// Control whether to prevent device auto-lock
|
||||
@State private var preventAutoLock: Bool = true
|
||||
let container: ModelContainer
|
||||
@State private var cloudKitObserver: NSObjectProtocol?
|
||||
|
||||
@ -23,6 +26,9 @@ struct WorkoutsApp: App {
|
||||
|
||||
// Set up CloudKit notification observation
|
||||
setupCloudKitObservation()
|
||||
|
||||
// Disable screen auto-lock
|
||||
UIApplication.shared.isIdleTimerDisabled = true
|
||||
}
|
||||
|
||||
private func setupCloudKitObservation() {
|
||||
@ -61,6 +67,14 @@ struct WorkoutsApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.onAppear {
|
||||
// Ensure auto-lock is disabled when app appears
|
||||
UIApplication.shared.isIdleTimerDisabled = preventAutoLock
|
||||
}
|
||||
.onDisappear {
|
||||
// Re-enable auto-lock when app disappears
|
||||
UIApplication.shared.isIdleTimerDisabled = false
|
||||
}
|
||||
}
|
||||
.modelContainer(container)
|
||||
}
|
||||
|
Reference in New Issue
Block a user