mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add a logout option on the root of IdentityVerification screen.
This commit is contained in:
committed by
Stefan Ceriu
parent
904045f178
commit
32e1e1aa24
@@ -18,6 +18,10 @@ import Combine
|
|||||||
import Foundation
|
import Foundation
|
||||||
import SwiftState
|
import SwiftState
|
||||||
|
|
||||||
|
enum OnboardingFlowCoordinatorAction {
|
||||||
|
case logout
|
||||||
|
}
|
||||||
|
|
||||||
class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
||||||
private let userSession: UserSessionProtocol
|
private let userSession: UserSessionProtocol
|
||||||
private let appLockService: AppLockServiceProtocol
|
private let appLockService: AppLockServiceProtocol
|
||||||
@@ -52,6 +56,11 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
// periphery: ignore - used to store the coordinator to avoid deallocation
|
// periphery: ignore - used to store the coordinator to avoid deallocation
|
||||||
private var appLockFlowCoordinator: AppLockSetupFlowCoordinator?
|
private var appLockFlowCoordinator: AppLockSetupFlowCoordinator?
|
||||||
|
|
||||||
|
private let actionsSubject: PassthroughSubject<OnboardingFlowCoordinatorAction, Never> = .init()
|
||||||
|
var actions: AnyPublisher<OnboardingFlowCoordinatorAction, Never> {
|
||||||
|
actionsSubject.eraseToAnyPublisher()
|
||||||
|
}
|
||||||
|
|
||||||
init(userSession: UserSessionProtocol,
|
init(userSession: UserSessionProtocol,
|
||||||
appLockService: AppLockServiceProtocol,
|
appLockService: AppLockServiceProtocol,
|
||||||
analyticsService: AnalyticsService,
|
analyticsService: AnalyticsService,
|
||||||
@@ -234,6 +243,8 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
stateMachine.tryEvent(.nextSkippingIdentityConfimed)
|
stateMachine.tryEvent(.nextSkippingIdentityConfimed)
|
||||||
case .reset:
|
case .reset:
|
||||||
presentEncryptionResetScreen()
|
presentEncryptionResetScreen()
|
||||||
|
case .logout:
|
||||||
|
actionsSubject.send(.logout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|||||||
@@ -185,6 +185,17 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.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() {
|
func start() {
|
||||||
@@ -429,12 +440,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
guard isLastDevice else {
|
guard isLastDevice else {
|
||||||
ServiceLocator.shared.userIndicatorController.alertInfo = .init(id: .init(),
|
logout()
|
||||||
title: L10n.screenSignoutConfirmationDialogTitle,
|
|
||||||
message: L10n.screenSignoutConfirmationDialogContent,
|
|
||||||
primaryButton: .init(title: L10n.screenSignoutConfirmationDialogSubmit, role: .destructive) { [weak self] in
|
|
||||||
self?.actionsSubject.send(.logout)
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,6 +471,15 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
presentSecureBackupLogoutConfirmationScreen()
|
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
|
// MARK: Room Flow
|
||||||
|
|
||||||
private func startRoomFlow(roomID: String,
|
private func startRoomFlow(roomID: String,
|
||||||
|
|||||||
+3
@@ -29,6 +29,7 @@ enum IdentityConfirmationScreenCoordinatorAction {
|
|||||||
/// Only possible in debug builds.
|
/// Only possible in debug builds.
|
||||||
case skip
|
case skip
|
||||||
case reset
|
case reset
|
||||||
|
case logout
|
||||||
}
|
}
|
||||||
|
|
||||||
final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
||||||
@@ -64,6 +65,8 @@ final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
|||||||
actionsSubject.send(.skip)
|
actionsSubject.send(.skip)
|
||||||
case .reset:
|
case .reset:
|
||||||
actionsSubject.send(.reset)
|
actionsSubject.send(.reset)
|
||||||
|
case .logout:
|
||||||
|
actionsSubject.send(.logout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|||||||
+2
@@ -22,6 +22,7 @@ enum IdentityConfirmationScreenViewModelAction {
|
|||||||
/// Only possible in debug builds.
|
/// Only possible in debug builds.
|
||||||
case skip
|
case skip
|
||||||
case reset
|
case reset
|
||||||
|
case logout
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IdentityConfirmationScreenViewState: BindableState {
|
struct IdentityConfirmationScreenViewState: BindableState {
|
||||||
@@ -40,4 +41,5 @@ enum IdentityConfirmationScreenViewAction {
|
|||||||
/// Only possible in debug builds.
|
/// Only possible in debug builds.
|
||||||
case skip
|
case skip
|
||||||
case reset
|
case reset
|
||||||
|
case logout
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -61,6 +61,8 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
|
|||||||
actionsSubject.send(.skip)
|
actionsSubject.send(.skip)
|
||||||
case .reset:
|
case .reset:
|
||||||
actionsSubject.send(.reset)
|
actionsSubject.send(.reset)
|
||||||
|
case .logout:
|
||||||
|
actionsSubject.send(.logout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -34,9 +34,9 @@ struct IdentityConfirmationScreen: View {
|
|||||||
} bottomContent: {
|
} bottomContent: {
|
||||||
actionButtons
|
actionButtons
|
||||||
}
|
}
|
||||||
|
.toolbar { toolbar }
|
||||||
.background()
|
.background()
|
||||||
.backgroundStyle(.compound.bgCanvasDefault)
|
.backgroundStyle(.compound.bgCanvasDefault)
|
||||||
.navigationBarHidden(true)
|
|
||||||
.navigationBarBackButtonHidden(true)
|
.navigationBarBackButtonHidden(true)
|
||||||
.interactiveDismissDisabled()
|
.interactiveDismissDisabled()
|
||||||
}
|
}
|
||||||
@@ -104,6 +104,15 @@ struct IdentityConfirmationScreen: View {
|
|||||||
.padding(.vertical, 14)
|
.padding(.vertical, 14)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ToolbarContentBuilder
|
||||||
|
var toolbar: some ToolbarContent {
|
||||||
|
ToolbarItem(placement: .destructiveAction) {
|
||||||
|
Button(L10n.actionSignout) {
|
||||||
|
context.send(viewAction: .logout)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:bf60b748aa8c48aad659c3567c814cc1f601c194fbafcfffeed37fe6f3594e40
|
oid sha256:b4a84aba9177f2aabd5ac0a277abc49e39ef9d24c66e09eced3f9d811a51c839
|
||||||
size 108900
|
size 112052
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:080f9960d7ca7e83a183050cc663c50635a7a6260bcfd808cf7607680cbf7ae4
|
oid sha256:f7424e467fdbf85f3536a32703fcaadb1ef55464f53cf0ab3d2fc8c4edf57f9f
|
||||||
size 123013
|
size 126931
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:797ad10083353eeb2362f882ff1072a213dde5c879511e5854c4aa415f68d35e
|
oid sha256:9bf6f00287b731049979d42cdfc44d46ba58e612329b17dea34bdc7815c458ab
|
||||||
size 64174
|
size 67095
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:e0d54f1544f9cd0ffc14183a8baff1317fd0c793ca94c7e88e8a0a2d02816b36
|
oid sha256:49f7af683e4a2b10351bb4edf8b4692934e2bc47ee4c726c6d6230bfa6e7f034
|
||||||
size 81854
|
size 84897
|
||||||
|
|||||||
Reference in New Issue
Block a user