Fixes ELEMENT-97277 - Be less aggressive on recovery key states
This commit is contained in:
committed by
Stefan Ceriu
parent
a28f417202
commit
617f0f155c
@@ -62,6 +62,8 @@ final class SecureBackupRecoveryKeyScreenCoordinator: CoordinatorProtocol {
|
||||
self.actionsSubject.send(.recoveryChanged)
|
||||
case .fixRecovery:
|
||||
self.actionsSubject.send(.recoveryFixed)
|
||||
case .unknown:
|
||||
fatalError()
|
||||
}
|
||||
case .showResetKeyInfo:
|
||||
self.actionsSubject.send(.showResetKeyInfo)
|
||||
|
||||
@@ -26,6 +26,7 @@ enum SecureBackupRecoveryKeyScreenViewMode {
|
||||
case setupRecovery
|
||||
case changeRecovery
|
||||
case fixRecovery
|
||||
case unknown
|
||||
}
|
||||
|
||||
struct SecureBackupRecoveryKeyScreenViewState: BindableState {
|
||||
@@ -47,10 +48,12 @@ struct SecureBackupRecoveryKeyScreenViewState: BindableState {
|
||||
return recoveryKey == nil ? L10n.screenRecoveryKeyChangeTitle : L10n.screenRecoveryKeySaveTitle
|
||||
case .fixRecovery:
|
||||
return L10n.screenRecoveryKeyConfirmTitle
|
||||
default:
|
||||
return L10n.errorUnknown
|
||||
}
|
||||
}
|
||||
|
||||
var subtitle: String {
|
||||
var subtitle: String? {
|
||||
switch mode {
|
||||
case .setupRecovery:
|
||||
return recoveryKey == nil ? L10n.screenRecoveryKeySetupDescription : L10n.screenRecoveryKeySaveDescription
|
||||
@@ -58,10 +61,12 @@ struct SecureBackupRecoveryKeyScreenViewState: BindableState {
|
||||
return recoveryKey == nil ? L10n.screenRecoveryKeyChangeDescription : L10n.screenRecoveryKeySaveDescription
|
||||
case .fixRecovery:
|
||||
return L10n.screenRecoveryKeyConfirmDescription
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var recoveryKeySubtitle: String {
|
||||
var recoveryKeySubtitle: String? {
|
||||
switch mode {
|
||||
case .setupRecovery:
|
||||
return recoveryKey == nil ? L10n.screenRecoveryKeySetupGenerateKeyDescription : L10n.screenRecoveryKeySaveKeyDescription
|
||||
@@ -69,6 +74,8 @@ struct SecureBackupRecoveryKeyScreenViewState: BindableState {
|
||||
return recoveryKey == nil ? L10n.screenRecoveryKeyChangeGenerateKeyDescription : L10n.screenRecoveryKeySaveKeyDescription
|
||||
case .fixRecovery:
|
||||
return L10n.screenRecoveryKeyConfirmKeyDescription
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ extension SecureBackupRecoveryState {
|
||||
case .incomplete:
|
||||
return .fixRecovery
|
||||
default:
|
||||
fatalError("Invalid recovery state")
|
||||
return .unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,26 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
case .fixRecovery:
|
||||
header
|
||||
confirmRecoveryKeySection
|
||||
case .unknown:
|
||||
header
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var header: some View {
|
||||
VStack(spacing: 16) {
|
||||
HeroImage(icon: \.keySolid)
|
||||
|
||||
Text(context.viewState.title)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.font(.compound.headingMDBold)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
if let subtitle = context.viewState.subtitle {
|
||||
Text(subtitle)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.font(.compound.bodyMD)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +85,8 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
recoveryCreatedActionButtons
|
||||
case .fixRecovery:
|
||||
incompleteVerificationActionButtons
|
||||
case .unknown:
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,22 +143,6 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var header: some View {
|
||||
VStack(spacing: 16) {
|
||||
HeroImage(icon: \.keySolid)
|
||||
|
||||
Text(context.viewState.title)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.font(.compound.headingMDBold)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Text(context.viewState.subtitle)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.font(.compound.bodyMD)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
|
||||
private var generateRecoveryKeySection: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text(L10n.commonRecoveryKey)
|
||||
@@ -172,16 +178,18 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
.background(Color.compound.bgSubtleSecondaryLevel0)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||
|
||||
Label {
|
||||
Text(context.viewState.recoveryKeySubtitle)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.font(.compound.bodySM)
|
||||
} icon: {
|
||||
if context.viewState.recoveryKey == nil {
|
||||
CompoundIcon(\.infoSolid, size: .small, relativeTo: .compound.bodySM)
|
||||
if let subtitle = context.viewState.recoveryKeySubtitle {
|
||||
Label {
|
||||
Text(subtitle)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.font(.compound.bodySM)
|
||||
} icon: {
|
||||
if context.viewState.recoveryKey == nil {
|
||||
CompoundIcon(\.infoSolid, size: .small, relativeTo: .compound.bodySM)
|
||||
}
|
||||
}
|
||||
.labelStyle(.custom(spacing: 8, alignment: .top))
|
||||
}
|
||||
.labelStyle(.custom(spacing: 8, alignment: .top))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,9 +219,11 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
context.send(viewAction: .confirmKey)
|
||||
}
|
||||
|
||||
Text(context.viewState.recoveryKeySubtitle)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.font(.compound.bodySM)
|
||||
if let subtitle = context.viewState.recoveryKeySubtitle {
|
||||
Text(subtitle)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.font(.compound.bodySM)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,6 +234,7 @@ struct SecureBackupRecoveryKeyScreen_Previews: PreviewProvider, TestablePreview
|
||||
static let setupViewModel = viewModel(recoveryState: .enabled)
|
||||
static let notSetUpViewModel = viewModel(recoveryState: .disabled)
|
||||
static let incompleteViewModel = viewModel(recoveryState: .incomplete)
|
||||
static let unknownViewModel = viewModel(recoveryState: .unknown)
|
||||
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
@@ -240,6 +251,11 @@ struct SecureBackupRecoveryKeyScreen_Previews: PreviewProvider, TestablePreview
|
||||
SecureBackupRecoveryKeyScreen(context: incompleteViewModel.context)
|
||||
}
|
||||
.previewDisplayName("Incomplete")
|
||||
|
||||
NavigationStack {
|
||||
SecureBackupRecoveryKeyScreen(context: unknownViewModel.context)
|
||||
}
|
||||
.previewDisplayName("Unknown")
|
||||
}
|
||||
|
||||
static func viewModel(recoveryState: SecureBackupRecoveryState) -> SecureBackupRecoveryKeyScreenViewModelType {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:edb78e9330dad85dbea6b78e5251de463d5256467d156b5c115412f70ffb6e40
|
||||
size 89995
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:db402366ea030a33cee42151bb53fe0246552e5c62007db21973e1b2dd65d46b
|
||||
size 111948
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4887b2039b61cb4983f2b21c8188196363ac15d731ce7d6d5da8587ee9ab7202
|
||||
size 48061
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:66d22d7edf9db13c6dd7e9a40333ee03efd7dc1815abf8c9c7cc31c0f8737f3b
|
||||
size 68216
|
||||
Reference in New Issue
Block a user