Add a logout option on the root of IdentityVerification screen.

This commit is contained in:
Stefan Ceriu
2024-08-29 14:39:08 +03:00
committed by Stefan Ceriu
parent c1991b6745
commit c6eb7b63bf
10 changed files with 57 additions and 15 deletions

View File

@@ -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)

View File

@@ -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,

View File

@@ -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)

View File

@@ -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
}

View File

@@ -61,6 +61,8 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
actionsSubject.send(.skip)
case .reset:
actionsSubject.send(.reset)
case .logout:
actionsSubject.send(.logout)
}
}

View File

@@ -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

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bf60b748aa8c48aad659c3567c814cc1f601c194fbafcfffeed37fe6f3594e40
size 108900
oid sha256:b4a84aba9177f2aabd5ac0a277abc49e39ef9d24c66e09eced3f9d811a51c839
size 112052

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:080f9960d7ca7e83a183050cc663c50635a7a6260bcfd808cf7607680cbf7ae4
size 123013
oid sha256:f7424e467fdbf85f3536a32703fcaadb1ef55464f53cf0ab3d2fc8c4edf57f9f
size 126931

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:797ad10083353eeb2362f882ff1072a213dde5c879511e5854c4aa415f68d35e
size 64174
oid sha256:9bf6f00287b731049979d42cdfc44d46ba58e612329b17dea34bdc7815c458ab
size 67095

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e0d54f1544f9cd0ffc14183a8baff1317fd0c793ca94c7e88e8a0a2d02816b36
size 81854
oid sha256:49f7af683e4a2b10351bb4edf8b4692934e2bc47ee4c726c6d6230bfa6e7f034
size 84897