ios: fix sheets dismissing during biometric authentication

This commit is contained in:
Levitating Pineapple
2024-10-16 15:15:14 +03:00
parent b5d8c65249
commit 0debe17a08
3 changed files with 13 additions and 6 deletions
+3 -1
View File
@@ -13,6 +13,7 @@ struct ContentView: View {
@EnvironmentObject var chatModel: ChatModel
@ObservedObject var alertManager = AlertManager.shared
@ObservedObject var callController = CallController.shared
@ObservedObject var appSheetState = AppSheetState.shared
@Environment(\.colorScheme) var colorScheme
@EnvironmentObject var theme: AppTheme
@EnvironmentObject var sceneDelegate: SceneDelegate
@@ -250,7 +251,8 @@ struct ContentView: View {
private func mainView() -> some View {
ZStack(alignment: .top) {
ChatListView(activeUserPickerSheet: $chatListUserPickerSheet).privacySensitive(protectScreen)
ChatListView(activeUserPickerSheet: $chatListUserPickerSheet)
.redacted(reason: appSheetState.redactionReasons(protectScreen))
.onAppear {
requestNtfAuthorization()
// Local Authentication notice is to be shown on next start after onboarding is complete
+8 -5
View File
@@ -10,7 +10,14 @@ import SwiftUI
class AppSheetState: ObservableObject {
static let shared = AppSheetState()
@Published var biometricAuth: Bool = false
@Published var scenePhaseActive: Bool = false
func redactionReasons(_ protectScreen: Bool) -> RedactionReasons {
!protectScreen || scenePhaseActive || biometricAuth
? RedactionReasons()
: RedactionReasons.placeholder
}
}
private struct PrivacySensitive: ViewModifier {
@@ -19,11 +26,7 @@ private struct PrivacySensitive: ViewModifier {
@ObservedObject var appSheetState: AppSheetState = AppSheetState.shared
func body(content: Content) -> some View {
if !protectScreen {
content
} else {
content.privacySensitive(!appSheetState.scenePhaseActive).redacted(reason: .privacy)
}
content.redacted(reason: appSheetState.redactionReasons(protectScreen))
}
}
@@ -63,9 +63,11 @@ func systemAuthenticate(_ reason: String, _ completed: @escaping (LAResult) -> V
var authAvailabilityError: NSError?
if laContext.canEvaluatePolicy(.deviceOwnerAuthentication, error: &authAvailabilityError) {
logger.debug("DEBUGGING: systemAuthenticate: canEvaluatePolicy callback")
AppSheetState.shared.biometricAuth = true
laContext.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason) { success, authError in
logger.debug("DEBUGGING: systemAuthenticate evaluatePolicy callback")
DispatchQueue.main.async {
AppSheetState.shared.biometricAuth = false
if success {
completed(LAResult.success)
} else {