fix app lock hanging on macOS and blocking the photo picker
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build macOS ZIP (push) Canceled after 0s

- 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.
This commit is contained in:
wt committed 2026-08-30 01:14:23 +07:00
1 parent 8b86e33186
commit 6ed5cb3ce9
9 files changed
+86 -78

No files matched your search

+14 -29
View File
@@ -57,12 +57,15 @@ struct AppLockView: View {
.buttonStyle(.borderedProminent)
.disabled(passcode.isEmpty)
if biometricAvailable, model.appLockBiometricIsEnabled {
if model.biometricUnlockAvailable, model.appLockBiometricIsEnabled {
Button {
Task { await biometricUnlock() }
} label: {
Label("Войти по \(biometricName)", systemImage: biometricIcon)
.foregroundStyle(.white)
Label(
"Войти по \(model.biometricUnlockName)",
systemImage: model.biometricUnlockName == "Face ID" ? "faceid" : "touchid"
)
.foregroundStyle(.white)
}
}
}
@@ -73,35 +76,17 @@ struct AppLockView: View {
.onAppear {
isFocused = true
}
#if os(iOS)
.task {
// Auto-prompt biometrics once when the lock screen appears.
guard biometricAvailable, model.appLockBiometricIsEnabled else { return }
// Auto-prompt biometrics once when the lock screen appears. iOS
// only: on macOS the system Touch ID dialog blocks the window
// and freezes the lock screen.
guard model.biometricUnlockAvailable, model.appLockBiometricIsEnabled else {
return
}
await biometricUnlock()
}
}
private var biometricContext: LAContext {
LAContext()
}
private var biometricAvailable: Bool {
var error: NSError?
return biometricContext.canEvaluatePolicy(
.deviceOwnerAuthenticationWithBiometrics,
error: &error
)
}
private var biometryType: LABiometryType {
biometricContext.biometryType
}
private var biometricIcon: String {
biometryType == .faceID ? "faceid" : "touchid"
}
private var biometricName: String {
biometryType == .faceID ? "Face ID" : "Touch ID"
#endif
}
private func submit() {