Skip to content

Commit

Permalink
Add a logout option on the root of IdentityVerification screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Aug 29, 2024
1 parent 02f868c commit 774c5ab
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 9 deletions.
11 changes: 11 additions & 0 deletions ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -234,6 +243,8 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.tryEvent(.nextSkippingIdentityConfimed)
case .reset:
presentEncryptionResetScreen()
case .logout:
actionsSubject.send(.logout)
}
}
.store(in: &cancellables)
Expand Down
11 changes: 11 additions & 0 deletions ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Task { await self.runLogoutFlow() }
}
}
.store(in: &cancellables)
}

func start() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum IdentityConfirmationScreenCoordinatorAction {
/// Only possible in debug builds.
case skip
case reset
case logout
}

final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
Expand Down Expand Up @@ -64,6 +65,8 @@ final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.skip)
case .reset:
actionsSubject.send(.reset)
case .logout:
actionsSubject.send(.logout)
}
}
.store(in: &cancellables)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum IdentityConfirmationScreenViewModelAction {
/// Only possible in debug builds.
case skip
case reset
case logout
}

struct IdentityConfirmationScreenViewState: BindableState {
Expand All @@ -40,4 +41,5 @@ enum IdentityConfirmationScreenViewAction {
/// Only possible in debug builds.
case skip
case reset
case logout
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
actionsSubject.send(.skip)
case .reset:
actionsSubject.send(.reset)
case .logout:
actionsSubject.send(.logout)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ struct IdentityConfirmationScreen: View {
} bottomContent: {
actionButtons
}
.toolbar { toolbar }
.background()
.backgroundStyle(.compound.bgCanvasDefault)
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
.interactiveDismissDisabled()
}
Expand Down Expand Up @@ -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
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 774c5ab

Please sign in to comment.