mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Tweak the onboarding flow identity confirmation screen
- hide the recovery key option if recovery wasn't set up beforehand - add a button to present the reset encryption instructions screen
This commit is contained in:
committed by
Stefan Ceriu
parent
f8d094516d
commit
696d599773
@@ -212,6 +212,8 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
case .skip:
|
case .skip:
|
||||||
appSettings.hasRunIdentityConfirmationOnboarding = true
|
appSettings.hasRunIdentityConfirmationOnboarding = true
|
||||||
stateMachine.tryEvent(.next)
|
stateMachine.tryEvent(.next)
|
||||||
|
case .reset:
|
||||||
|
presentResetRecoveryKeyScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|||||||
+3
@@ -30,6 +30,7 @@ enum IdentityConfirmationScreenCoordinatorAction {
|
|||||||
case recoveryKey
|
case recoveryKey
|
||||||
/// Only possible in debug builds.
|
/// Only possible in debug builds.
|
||||||
case skip
|
case skip
|
||||||
|
case reset
|
||||||
}
|
}
|
||||||
|
|
||||||
final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
||||||
@@ -63,6 +64,8 @@ final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
|||||||
actionsSubject.send(.recoveryKey)
|
actionsSubject.send(.recoveryKey)
|
||||||
case .skip:
|
case .skip:
|
||||||
actionsSubject.send(.skip)
|
actionsSubject.send(.skip)
|
||||||
|
case .reset:
|
||||||
|
actionsSubject.send(.reset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|||||||
+6
-4
@@ -21,15 +21,16 @@ enum IdentityConfirmationScreenViewModelAction {
|
|||||||
case recoveryKey
|
case recoveryKey
|
||||||
/// Only possible in debug builds.
|
/// Only possible in debug builds.
|
||||||
case skip
|
case skip
|
||||||
|
case reset
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IdentityConfirmationScreenViewState: BindableState {
|
struct IdentityConfirmationScreenViewState: BindableState {
|
||||||
enum Mode {
|
enum AvailableActions {
|
||||||
case recoveryOnly
|
case recovery
|
||||||
case recoveryAndVerification
|
case interactiveVerification
|
||||||
}
|
}
|
||||||
|
|
||||||
var mode = Mode.recoveryOnly
|
var availableActions: [AvailableActions] = []
|
||||||
let learnMoreURL: URL
|
let learnMoreURL: URL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,4 +39,5 @@ enum IdentityConfirmationScreenViewAction {
|
|||||||
case recoveryKey
|
case recoveryKey
|
||||||
/// Only possible in debug builds.
|
/// Only possible in debug builds.
|
||||||
case skip
|
case skip
|
||||||
|
case reset
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-3
@@ -59,6 +59,8 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
|
|||||||
actionsSubject.send(.recoveryKey)
|
actionsSubject.send(.recoveryKey)
|
||||||
case .skip:
|
case .skip:
|
||||||
actionsSubject.send(.skip)
|
actionsSubject.send(.skip)
|
||||||
|
case .reset:
|
||||||
|
actionsSubject.send(.reset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,11 +77,18 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
guard case let .success(isOnlyDeviceLeft) = await userSession.clientProxy.isOnlyDeviceLeft() else {
|
var availableActions: [IdentityConfirmationScreenViewState.AvailableActions] = []
|
||||||
return
|
|
||||||
|
if case let .success(isOnlyDeviceLeft) = await userSession.clientProxy.isOnlyDeviceLeft(),
|
||||||
|
!isOnlyDeviceLeft {
|
||||||
|
availableActions.append(.interactiveVerification)
|
||||||
}
|
}
|
||||||
|
|
||||||
state.mode = isOnlyDeviceLeft ? .recoveryOnly : .recoveryAndVerification
|
if sessionSecurityState.recoveryState == .enabled || sessionSecurityState.recoveryState == .incomplete {
|
||||||
|
availableActions.append(.recovery)
|
||||||
|
}
|
||||||
|
|
||||||
|
state.availableActions = availableActions
|
||||||
}
|
}
|
||||||
|
|
||||||
private static let loadingIndicatorIdentifier = "\(IdentityConfirmationScreenViewModel.self)-Loading"
|
private static let loadingIndicatorIdentifier = "\(IdentityConfirmationScreenViewModel.self)-Loading"
|
||||||
|
|||||||
+14
-9
@@ -71,23 +71,23 @@ struct IdentityConfirmationScreen: View {
|
|||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var actionButtons: some View {
|
private var actionButtons: some View {
|
||||||
VStack(spacing: 32) {
|
VStack(spacing: 32) {
|
||||||
switch context.viewState.mode {
|
if context.viewState.availableActions.contains(.interactiveVerification) {
|
||||||
case .recoveryOnly:
|
|
||||||
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
|
||||||
context.send(viewAction: .recoveryKey)
|
|
||||||
}
|
|
||||||
.buttonStyle(.compound(.primary))
|
|
||||||
|
|
||||||
case .recoveryAndVerification:
|
|
||||||
Button(L10n.actionStartVerification) {
|
Button(L10n.actionStartVerification) {
|
||||||
context.send(viewAction: .otherDevice)
|
context.send(viewAction: .otherDevice)
|
||||||
}
|
}
|
||||||
.buttonStyle(.compound(.primary))
|
.buttonStyle(.compound(.primary))
|
||||||
|
|
||||||
|
if context.viewState.availableActions.contains(.recovery) {
|
||||||
|
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
||||||
|
context.send(viewAction: .recoveryKey)
|
||||||
|
}
|
||||||
|
.buttonStyle(.compound(.plain))
|
||||||
|
}
|
||||||
|
} else if context.viewState.availableActions.contains(.recovery) {
|
||||||
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
||||||
context.send(viewAction: .recoveryKey)
|
context.send(viewAction: .recoveryKey)
|
||||||
}
|
}
|
||||||
.buttonStyle(.compound(.plain))
|
.buttonStyle(.compound(.primary))
|
||||||
}
|
}
|
||||||
|
|
||||||
if shouldShowSkipButton {
|
if shouldShowSkipButton {
|
||||||
@@ -96,6 +96,11 @@ struct IdentityConfirmationScreen: View {
|
|||||||
}
|
}
|
||||||
.buttonStyle(.compound(.plain))
|
.buttonStyle(.compound(.plain))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button(L10n.screenRecoveryKeyConfirmLostRecoveryKey, role: .destructive) {
|
||||||
|
context.send(viewAction: .reset)
|
||||||
|
}
|
||||||
|
.buttonStyle(.compound(.plain))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:f3ac13eb903ab6386f788382ea3362e6ef49f0aa065dd672953f1960bad44a27
|
oid sha256:062da336508f1585f505f4cbb28885ba81f62082c8e786bd920386cc34d5ccea
|
||||||
size 115060
|
size 118392
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:783830e86a68a1aec227f6e16fc865451cdb3407e7b7967a00bf1d3920d8db92
|
oid sha256:aed4dbdb22e4fa558b72f189a581e0930fc8d0476d7e0d7dcf9e1a8afb7d17a5
|
||||||
size 146800
|
size 156197
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:15e443ca166ca691ac1f7ba73732e564c5ea3e18297f290337d94fc55da1a821
|
oid sha256:7049b155c4155acf845121595c828822d51143b72cb1cc0eb5fb8309a5ee1c7a
|
||||||
size 71486
|
size 75502
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:f44459b131c9d4a9c88547b9b58c23814919fe2311ffac7694cf19e5f584e817
|
oid sha256:055aa831d819235c1f49b158dd329f10bd8be99d2a8b470e7786b58527d3c168
|
||||||
size 106764
|
size 117727
|
||||||
|
|||||||
Reference in New Issue
Block a user