Fix PrivacyOverlayView via NotificationCenter instead of using the .onChange handler (#13)
This commit is contained in:
parent
fe6cab4bb0
commit
280f086012
@ -13,6 +13,7 @@ struct ContentView: View {
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
@State private var lockVM = AppLockViewModel()
|
||||
@State private var showPrivacyScreen = false
|
||||
|
||||
private var hasActiveWallet: Bool {
|
||||
wallets.contains { $0.isActive }
|
||||
@ -41,9 +42,8 @@ struct ContentView: View {
|
||||
}
|
||||
|
||||
// Privacy screen — hides content in app switcher when app lock is enabled
|
||||
if appLockEnabled, scenePhase == .inactive, !shouldShowLock {
|
||||
if showPrivacyScreen, !shouldShowLock {
|
||||
PrivacyOverlayView()
|
||||
.transition(.opacity)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
@ -74,6 +74,7 @@ struct ContentView: View {
|
||||
}
|
||||
case .active:
|
||||
logger.info("Scene phase: active")
|
||||
showPrivacyScreen = false
|
||||
if appLockEnabled {
|
||||
lockVM.handleForeground(timeout: lockTimeout)
|
||||
}
|
||||
@ -83,6 +84,11 @@ struct ContentView: View {
|
||||
break
|
||||
}
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willResignActiveNotification)) { _ in
|
||||
if appLockEnabled {
|
||||
showPrivacyScreen = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user