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