mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Add a logout option on the root of IdentityVerification screen.
This commit is contained in:
parent
904045f178
commit
32e1e1aa24
@ -18,6 +18,10 @@ import Combine
|
||||
import Foundation
|
||||
import SwiftState
|
||||
|
||||
enum OnboardingFlowCoordinatorAction {
|
||||
case logout
|
||||
}
|
||||
|
||||
class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private let userSession: UserSessionProtocol
|
||||
private let appLockService: AppLockServiceProtocol
|
||||
@ -52,6 +56,11 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
||||
// periphery: ignore - used to store the coordinator to avoid deallocation
|
||||
private var appLockFlowCoordinator: AppLockSetupFlowCoordinator?
|
||||
|
||||
private let actionsSubject: PassthroughSubject<OnboardingFlowCoordinatorAction, Never> = .init()
|
||||
var actions: AnyPublisher<OnboardingFlowCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(userSession: UserSessionProtocol,
|
||||
appLockService: AppLockServiceProtocol,
|
||||
analyticsService: AnalyticsService,
|
||||
@ -234,6 +243,8 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
||||
stateMachine.tryEvent(.nextSkippingIdentityConfimed)
|
||||
case .reset:
|
||||
presentEncryptionResetScreen()
|
||||
case .logout:
|
||||
actionsSubject.send(.logout)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
@ -185,6 +185,17 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
onboardingFlowCoordinator.actions
|
||||
.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
|
||||
switch action {
|
||||
case .logout:
|
||||
logout()
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func start() {
|
||||
@ -429,12 +440,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
guard isLastDevice else {
|
||||
ServiceLocator.shared.userIndicatorController.alertInfo = .init(id: .init(),
|
||||
title: L10n.screenSignoutConfirmationDialogTitle,
|
||||
message: L10n.screenSignoutConfirmationDialogContent,
|
||||
primaryButton: .init(title: L10n.screenSignoutConfirmationDialogSubmit, role: .destructive) { [weak self] in
|
||||
self?.actionsSubject.send(.logout)
|
||||
})
|
||||
logout()
|
||||
return
|
||||
}
|
||||
|
||||
@ -465,6 +471,15 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
presentSecureBackupLogoutConfirmationScreen()
|
||||
}
|
||||
|
||||
private func logout() {
|
||||
ServiceLocator.shared.userIndicatorController.alertInfo = .init(id: .init(),
|
||||
title: L10n.screenSignoutConfirmationDialogTitle,
|
||||
message: L10n.screenSignoutConfirmationDialogContent,
|
||||
primaryButton: .init(title: L10n.screenSignoutConfirmationDialogSubmit, role: .destructive) { [weak self] in
|
||||
self?.actionsSubject.send(.logout)
|
||||
})
|
||||
}
|
||||
|
||||
// MARK: Room Flow
|
||||
|
||||
private func startRoomFlow(roomID: String,
|
||||
|
@ -29,6 +29,7 @@ enum IdentityConfirmationScreenCoordinatorAction {
|
||||
/// Only possible in debug builds.
|
||||
case skip
|
||||
case reset
|
||||
case logout
|
||||
}
|
||||
|
||||
final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
||||
@ -64,6 +65,8 @@ final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.skip)
|
||||
case .reset:
|
||||
actionsSubject.send(.reset)
|
||||
case .logout:
|
||||
actionsSubject.send(.logout)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
@ -22,6 +22,7 @@ enum IdentityConfirmationScreenViewModelAction {
|
||||
/// Only possible in debug builds.
|
||||
case skip
|
||||
case reset
|
||||
case logout
|
||||
}
|
||||
|
||||
struct IdentityConfirmationScreenViewState: BindableState {
|
||||
@ -40,4 +41,5 @@ enum IdentityConfirmationScreenViewAction {
|
||||
/// Only possible in debug builds.
|
||||
case skip
|
||||
case reset
|
||||
case logout
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
|
||||
actionsSubject.send(.skip)
|
||||
case .reset:
|
||||
actionsSubject.send(.reset)
|
||||
case .logout:
|
||||
actionsSubject.send(.logout)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,9 @@ struct IdentityConfirmationScreen: View {
|
||||
} bottomContent: {
|
||||
actionButtons
|
||||
}
|
||||
.toolbar { toolbar }
|
||||
.background()
|
||||
.backgroundStyle(.compound.bgCanvasDefault)
|
||||
.navigationBarHidden(true)
|
||||
.navigationBarBackButtonHidden(true)
|
||||
.interactiveDismissDisabled()
|
||||
}
|
||||
@ -104,6 +104,15 @@ struct IdentityConfirmationScreen: View {
|
||||
.padding(.vertical, 14)
|
||||
}
|
||||
}
|
||||
|
||||
@ToolbarContentBuilder
|
||||
var toolbar: some ToolbarContent {
|
||||
ToolbarItem(placement: .destructiveAction) {
|
||||
Button(L10n.actionSignout) {
|
||||
context.send(viewAction: .logout)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
BIN
PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-en-GB.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-en-GB.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-pseudo.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-pseudo.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-en-GB.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-en-GB.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-pseudo.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-pseudo.1.png
(Stored with Git LFS)
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user