Fix a regression where the forced logout indicator was presented on the hidden overlay window. (#2063)

This commit is contained in:
Doug
2023-11-10 17:21:02 +00:00
committed by GitHub
parent 5adbb3789e
commit b5cc2cbf61
20 changed files with 88 additions and 17 deletions
@@ -29,6 +29,8 @@ struct AppLockScreenViewState: BindableState {
/// The number of times the user attempted to enter their PIN.
var numberOfPINAttempts = 0
/// An overlay indicator shown when the user is being logged out.
var forcedLogoutIndicator: UserIndicator?
var bindings: AppLockScreenViewStateBindings
@@ -76,7 +76,7 @@ class AppLockScreenViewModel: AppLockScreenViewModelType, AppLockScreenViewModel
state.bindings.alertInfo = .init(id: .confirmResetPIN,
title: L10n.screenAppLockSignoutAlertTitle,
message: L10n.screenAppLockSignoutAlertMessage,
primaryButton: .init(title: L10n.actionOk) { self.actionsSubject.send(.forceLogout) },
primaryButton: .init(title: L10n.actionOk) { self.forceLogout() },
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
}
@@ -90,7 +90,12 @@ class AppLockScreenViewModel: AppLockScreenViewModelType, AppLockScreenViewModel
state.bindings.alertInfo = .init(id: .forcedLogout,
title: L10n.screenAppLockSignoutAlertTitle,
message: L10n.screenAppLockSignoutAlertMessage,
primaryButton: .init(title: L10n.actionOk) { self.actionsSubject.send(.forceLogout) })
primaryButton: .init(title: L10n.actionOk) { self.forceLogout() })
}
}
private func forceLogout() {
state.forcedLogoutIndicator = UserIndicator(type: .modal, title: L10n.commonSigningOut, persistent: true)
actionsSubject.send(.forceLogout)
}
}
@@ -58,6 +58,11 @@ struct AppLockScreen: View {
}
.background()
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
.disabled(context.viewState.forcedLogoutIndicator != nil)
.overlay {
context.viewState.forcedLogoutIndicator.map(UserIndicatorModalView.init)
.animation(.elementDefault, value: context.viewState.forcedLogoutIndicator)
}
.alert(item: $context.alertInfo)
}