- Lock only when the scene really backgrounds: transient inactive states (system photo picker, app switcher) no longer swap in the lock screen and break gallery selection on iOS. - Cache biometric availability once per session off the main thread instead of calling LAContext.canEvaluatePolicy in view bodies, which froze the macOS lock screen, and auto-prompt biometrics on iOS only. - Keep UI tests as an opt-in target and guard both fixes in verify.sh.
35 lines
1.1 KiB
Swift
35 lines
1.1 KiB
Swift
import SwiftUI
|
|
|
|
@main
|
|
@MainActor
|
|
struct LumaApp: App {
|
|
@StateObject private var model = AppModel()
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
RootView(model: model)
|
|
.tint(Color(red: 0.14, green: 0.56, blue: 0.96))
|
|
.onChange(of: scenePhase) { _, phase in
|
|
switch phase {
|
|
case .active:
|
|
model.setApplicationActive(true)
|
|
case .background:
|
|
model.setApplicationActive(false)
|
|
case .inactive:
|
|
// App switcher, Control Center and system pickers
|
|
// (photo gallery) make the scene briefly inactive;
|
|
// locking here would block the picker and the
|
|
// unlock screen would replace the app mid-flow.
|
|
break
|
|
@unknown default:
|
|
break
|
|
}
|
|
}
|
|
}
|
|
#if os(macOS)
|
|
.defaultSize(width: 1_080, height: 720)
|
|
#endif
|
|
}
|
|
}
|