mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Tweak the flow for setting up a recovery key. (#3463)
* Remove unwanted title. * Update SecureBackupScreen strings. * Update SecureBackupRecoveryKeyScreen. * Show the recovery banner when recovery needs setting up. * Fix SecureBackupScreen title. * Fix timeout on MP4 encoding tests
This commit is contained in:
@@ -266,8 +266,12 @@ internal enum L10n {
|
||||
internal static var bannerMigrateToNativeSlidingSyncForceLogoutTitle: String { return L10n.tr("Localizable", "banner_migrate_to_native_sliding_sync_force_logout_title") }
|
||||
/// Upgrade available
|
||||
internal static var bannerMigrateToNativeSlidingSyncTitle: String { return L10n.tr("Localizable", "banner_migrate_to_native_sliding_sync_title") }
|
||||
/// Recover your cryptographic identity and message history with a recovery key if you have lost all your existing devices.
|
||||
internal static var bannerSetUpRecoveryContent: String { return L10n.tr("Localizable", "banner_set_up_recovery_content") }
|
||||
/// Set up recovery
|
||||
internal static var bannerSetUpRecoverySubmit: String { return L10n.tr("Localizable", "banner_set_up_recovery_submit") }
|
||||
/// Set up recovery to protect your account
|
||||
internal static var bannerSetUpRecoveryTitle: String { return L10n.tr("Localizable", "banner_set_up_recovery_title") }
|
||||
/// About
|
||||
internal static var commonAbout: String { return L10n.tr("Localizable", "common_about") }
|
||||
/// Acceptable use policy
|
||||
@@ -1021,6 +1025,8 @@ internal enum L10n {
|
||||
}
|
||||
/// Key storage
|
||||
internal static var screenChatBackupKeyBackupTitle: String { return L10n.tr("Localizable", "screen_chat_backup_key_backup_title") }
|
||||
/// Key storage must be turned on to set up recovery.
|
||||
internal static var screenChatBackupKeyStorageDisabledError: String { return L10n.tr("Localizable", "screen_chat_backup_key_storage_disabled_error") }
|
||||
/// Upload keys from this device
|
||||
internal static var screenChatBackupKeyStorageToggleDescription: String { return L10n.tr("Localizable", "screen_chat_backup_key_storage_toggle_description") }
|
||||
/// Allow key storage
|
||||
@@ -2499,15 +2505,6 @@ internal enum L10n {
|
||||
/// Check UnifiedPush
|
||||
internal static var troubleshootNotificationsTestUnifiedPushTitle: String { return L10n.tr("Localizable", "troubleshoot_notifications_test_unified_push_title") }
|
||||
|
||||
internal enum Banner {
|
||||
internal enum SetUpRecovery {
|
||||
/// Recover your cryptographic identity and message history with a recovery key if you have lost all your existing devices.
|
||||
internal static var content: String { return L10n.tr("Localizable", "banner.set_up_recovery.content") }
|
||||
/// Set up recovery to protect your account
|
||||
internal static var title: String { return L10n.tr("Localizable", "banner.set_up_recovery.title") }
|
||||
}
|
||||
}
|
||||
|
||||
internal enum Common {
|
||||
/// Copied to clipboard
|
||||
internal static var copiedToClipboard: String { return L10n.tr("Localizable", "common.copied_to_clipboard") }
|
||||
|
||||
@@ -58,7 +58,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
switch (securityState.verificationState, securityState.recoveryState) {
|
||||
case (.verified, .disabled):
|
||||
state.requiresExtraAccountSetup = true
|
||||
state.securityBannerMode = .none
|
||||
state.securityBannerMode = .show
|
||||
case (.verified, .incomplete):
|
||||
state.requiresExtraAccountSetup = true
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ struct HomeScreenContent: View {
|
||||
if context.viewState.slidingSyncMigrationBannerMode == .show {
|
||||
HomeScreenSlidingSyncMigrationBanner(context: context)
|
||||
} else if context.viewState.securityBannerMode == .show {
|
||||
HomeScreenRecoveryKeyConfirmationBanner(context: context)
|
||||
HomeScreenRecoveryKeyConfirmationBanner(requiresExtraAccountSetup: context.viewState.requiresExtraAccountSetup, context: context)
|
||||
}
|
||||
}
|
||||
.background(Color.compound.bgCanvasDefault)
|
||||
|
||||
+14
-4
@@ -9,13 +9,18 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct HomeScreenRecoveryKeyConfirmationBanner: View {
|
||||
let requiresExtraAccountSetup: Bool
|
||||
var context: HomeScreenViewModel.Context
|
||||
|
||||
var title: String { requiresExtraAccountSetup ? L10n.bannerSetUpRecoveryTitle : L10n.confirmRecoveryKeyBannerTitle }
|
||||
var message: String { requiresExtraAccountSetup ? L10n.bannerSetUpRecoveryContent : L10n.confirmRecoveryKeyBannerMessage }
|
||||
var actionTitle: String { requiresExtraAccountSetup ? L10n.bannerSetUpRecoverySubmit : L10n.actionContinue }
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
HStack(spacing: 16) {
|
||||
Text(L10n.confirmRecoveryKeyBannerTitle)
|
||||
Text(title)
|
||||
.font(.compound.bodyLGSemibold)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
|
||||
@@ -29,12 +34,12 @@ struct HomeScreenRecoveryKeyConfirmationBanner: View {
|
||||
.frame(width: 12, height: 12)
|
||||
}
|
||||
}
|
||||
Text(L10n.confirmRecoveryKeyBannerMessage)
|
||||
Text(message)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
}
|
||||
|
||||
Button(L10n.actionContinue) {
|
||||
Button(actionTitle) {
|
||||
context.send(viewAction: .confirmRecoveryKey)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
@@ -52,7 +57,12 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab
|
||||
static let viewModel = buildViewModel()
|
||||
|
||||
static var previews: some View {
|
||||
HomeScreenRecoveryKeyConfirmationBanner(context: viewModel.context)
|
||||
HomeScreenRecoveryKeyConfirmationBanner(requiresExtraAccountSetup: true,
|
||||
context: viewModel.context)
|
||||
.previewDisplayName("Set up recovery")
|
||||
HomeScreenRecoveryKeyConfirmationBanner(requiresExtraAccountSetup: false,
|
||||
context: viewModel.context)
|
||||
.previewDisplayName("Out of sync")
|
||||
}
|
||||
|
||||
static func buildViewModel() -> HomeScreenViewModel {
|
||||
|
||||
-12
@@ -28,18 +28,6 @@ class SecureBackupRecoveryKeyScreenViewModel: SecureBackupRecoveryKeyScreenViewM
|
||||
super.init(initialViewState: .init(isModallyPresented: isModallyPresented,
|
||||
mode: secureBackupController.recoveryState.value.viewMode,
|
||||
bindings: .init()))
|
||||
|
||||
secureBackupController.recoveryState
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(receiveValue: { [weak self] state in
|
||||
switch state {
|
||||
case .settingUp:
|
||||
self?.showLoadingIndicator()
|
||||
default:
|
||||
self?.hideLoadingIndicator()
|
||||
}
|
||||
})
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
+6
-6
@@ -28,7 +28,7 @@ struct SecureBackupScreen: View {
|
||||
}
|
||||
}
|
||||
.compoundList()
|
||||
.navigationTitle(L10n.commonChatBackup)
|
||||
.navigationTitle(L10n.commonEncryption)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.alert(item: $context.alertInfo)
|
||||
}
|
||||
@@ -68,8 +68,7 @@ struct SecureBackupScreen: View {
|
||||
}
|
||||
|
||||
private var keyStorageToggle: some View {
|
||||
ListRow(label: .plain(title: L10n.screenChatBackupKeyStorageToggleTitle,
|
||||
description: L10n.screenChatBackupKeyStorageToggleDescription),
|
||||
ListRow(label: .plain(title: L10n.screenChatBackupKeyStorageToggleTitle),
|
||||
kind: .toggle($context.keyStorageEnabled))
|
||||
.onChange(of: context.keyStorageEnabled) { _, newValue in
|
||||
context.send(viewAction: .keyStorageToggled(newValue))
|
||||
@@ -86,7 +85,10 @@ struct SecureBackupScreen: View {
|
||||
iconAlignment: .top),
|
||||
kind: .navigationLink { context.send(viewAction: .recoveryKey) })
|
||||
case .disabled:
|
||||
ListRow(label: .plain(title: L10n.screenChatBackupRecoveryActionSetup),
|
||||
ListRow(label: .default(title: L10n.screenChatBackupRecoveryActionSetup,
|
||||
description: L10n.screenChatBackupRecoveryActionChangeDescription,
|
||||
icon: \.key,
|
||||
iconAlignment: .top),
|
||||
details: .icon(BadgeView(size: 10)),
|
||||
kind: .navigationLink { context.send(viewAction: .recoveryKey) })
|
||||
case .incomplete:
|
||||
@@ -105,8 +107,6 @@ struct SecureBackupScreen: View {
|
||||
@ViewBuilder
|
||||
private var recoveryKeySectionFooter: some View {
|
||||
switch context.viewState.recoveryState {
|
||||
case .disabled:
|
||||
Text(L10n.screenChatBackupRecoveryActionSetupDescription(InfoPlistReader.main.bundleDisplayName))
|
||||
case .incomplete:
|
||||
Text(L10n.screenChatBackupRecoveryActionConfirmDescription)
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user