diff --git a/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift index fb5c0ec26..d94a6ed30 100644 --- a/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift @@ -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 = .init() + var actions: AnyPublisher { + 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) diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index e1091ae57..eb73424ab 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -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, diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenCoordinator.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenCoordinator.swift index 6911fb067..69aa4578a 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenCoordinator.swift @@ -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) diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenModels.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenModels.swift index 4e5e9bca8..1e98ea512 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenModels.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenModels.swift @@ -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 } diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenViewModel.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenViewModel.swift index 29c9c38f4..25094f56f 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenViewModel.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenViewModel.swift @@ -61,6 +61,8 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy actionsSubject.send(.skip) case .reset: actionsSubject.send(.reset) + case .logout: + actionsSubject.send(.logout) } } diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift index 5e99d8881..359f97ee3 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift @@ -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 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-en-GB.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-en-GB.1.png index 9bd9deb9b..3531ce245 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-en-GB.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bf60b748aa8c48aad659c3567c814cc1f601c194fbafcfffeed37fe6f3594e40 -size 108900 +oid sha256:b4a84aba9177f2aabd5ac0a277abc49e39ef9d24c66e09eced3f9d811a51c839 +size 112052 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-pseudo.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-pseudo.1.png index 99fe3cac3..f4676f532 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-pseudo.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPad-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:080f9960d7ca7e83a183050cc663c50635a7a6260bcfd808cf7607680cbf7ae4 -size 123013 +oid sha256:f7424e467fdbf85f3536a32703fcaadb1ef55464f53cf0ab3d2fc8c4edf57f9f +size 126931 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-en-GB.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-en-GB.1.png index 7fa28b5f8..4ce196dd6 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-en-GB.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:797ad10083353eeb2362f882ff1072a213dde5c879511e5854c4aa415f68d35e -size 64174 +oid sha256:9bf6f00287b731049979d42cdfc44d46ba58e612329b17dea34bdc7815c458ab +size 67095 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-pseudo.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-pseudo.1.png index f17402a1e..d072c34a6 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-pseudo.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_identityConfirmationScreen-iPhone-15-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0d54f1544f9cd0ffc14183a8baff1317fd0c793ca94c7e88e8a0a2d02816b36 -size 81854 +oid sha256:49f7af683e4a2b10351bb4edf8b4692934e2bc47ee4c726c6d6230bfa6e7f034 +size 84897