Skip to content

Commit

Permalink
More cleanup + replace the learn more button with an actual link so i…
Browse files Browse the repository at this point in the history
…t's more accessible
  • Loading branch information
stefanceriu committed Oct 19, 2023
1 parent c727ade commit 39033ab
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 26 deletions.

This file was deleted.

7 changes: 5 additions & 2 deletions ElementX/Resources/Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@
"room_timeline_beginning_of_room" = "This is the beginning of %1$@.";
"room_timeline_beginning_of_room_no_name" = "This is the beginning of this conversation.";
"room_timeline_read_marker_title" = "New";
"screen_advanced_settings_element_call_base_url" = "Custom Element Call base URL";
"screen_advanced_settings_element_call_base_url_description" = "Set a custom base URL for Element Call.";
"screen_advanced_settings_element_call_base_url_validation_error" = "Invalid URL, please make sure you include the protocol (http/https) and the correct address.";
"screen_account_provider_change" = "Change account provider";
"screen_account_provider_form_hint" = "Homeserver address";
"screen_account_provider_form_notice" = "Enter a search term or a domain address.";
Expand Down Expand Up @@ -280,7 +283,7 @@
"screen_change_server_title" = "Select your server";
"screen_chat_backup_key_backup_action_disable" = "Turn off backup";
"screen_chat_backup_key_backup_action_enable" = "Turn on backup";
"screen_chat_backup_key_backup_description" = "Backup ensures that you don't lose your message history.";
"screen_chat_backup_key_backup_description" = "Backup ensures that you don't lose your message history. %1$@.";
"screen_chat_backup_key_backup_title" = "Backup";
"screen_chat_backup_recovery_action_change" = "Change recovery key";
"screen_chat_backup_recovery_action_confirm" = "Confirm recovery key";
Expand Down Expand Up @@ -321,7 +324,7 @@
"screen_key_backup_disable_confirmation_action_turn_off" = "Turn off";
"screen_key_backup_disable_confirmation_description" = "You will lose your encrypted messages if you are signed out of all devices.";
"screen_key_backup_disable_confirmation_title" = "Are you sure you want to turn off backup?";
"screen_key_backup_disable_description" = "Turning off backup will remove your your current encryption key backup and turn off other security features. In this case, you will:";
"screen_key_backup_disable_description" = "Turning off backup will remove your current encryption key backup and turn off other security features. In this case, you will:";
"screen_key_backup_disable_description_point_1" = "Not have encrypted message history on new devices";
"screen_key_backup_disable_description_point_2" = "Lose access to your encrypted messages if you are signed out of %1$@ everywhere";
"screen_key_backup_disable_title" = "Are you sure you want to turn off backup?";
Expand Down
14 changes: 11 additions & 3 deletions ElementX/Sources/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,12 @@ public enum L10n {
public static var screenAdvancedSettingsDeveloperMode: String { return L10n.tr("Localizable", "screen_advanced_settings_developer_mode") }
/// Enable to have access to features and functionality for developers.
public static var screenAdvancedSettingsDeveloperModeDescription: String { return L10n.tr("Localizable", "screen_advanced_settings_developer_mode_description") }
/// Custom Element Call base URL
public static var screenAdvancedSettingsElementCallBaseUrl: String { return L10n.tr("Localizable", "screen_advanced_settings_element_call_base_url") }
/// Set a custom base URL for Element Call.
public static var screenAdvancedSettingsElementCallBaseUrlDescription: String { return L10n.tr("Localizable", "screen_advanced_settings_element_call_base_url_description") }
/// Invalid URL, please make sure you include the protocol (http/https) and the correct address.
public static var screenAdvancedSettingsElementCallBaseUrlValidationError: String { return L10n.tr("Localizable", "screen_advanced_settings_element_call_base_url_validation_error") }
/// Disable the rich text editor to type Markdown manually.
public static var screenAdvancedSettingsRichTextEditorDescription: String { return L10n.tr("Localizable", "screen_advanced_settings_rich_text_editor_description") }
/// We won't record or profile any personal data
Expand Down Expand Up @@ -680,8 +686,10 @@ public enum L10n {
public static var screenChatBackupKeyBackupActionDisable: String { return L10n.tr("Localizable", "screen_chat_backup_key_backup_action_disable") }
/// Turn on backup
public static var screenChatBackupKeyBackupActionEnable: String { return L10n.tr("Localizable", "screen_chat_backup_key_backup_action_enable") }
/// Backup ensures that you don't lose your message history.
public static var screenChatBackupKeyBackupDescription: String { return L10n.tr("Localizable", "screen_chat_backup_key_backup_description") }
/// Backup ensures that you don't lose your message history. %1$@.
public static func screenChatBackupKeyBackupDescription(_ p1: Any) -> String {
return L10n.tr("Localizable", "screen_chat_backup_key_backup_description", String(describing: p1))
}
/// Backup
public static var screenChatBackupKeyBackupTitle: String { return L10n.tr("Localizable", "screen_chat_backup_key_backup_title") }
/// Change recovery key
Expand Down Expand Up @@ -786,7 +794,7 @@ public enum L10n {
public static var screenKeyBackupDisableConfirmationDescription: String { return L10n.tr("Localizable", "screen_key_backup_disable_confirmation_description") }
/// Are you sure you want to turn off backup?
public static var screenKeyBackupDisableConfirmationTitle: String { return L10n.tr("Localizable", "screen_key_backup_disable_confirmation_title") }
/// Turning off backup will remove your your current encryption key backup and turn off other security features. In this case, you will:
/// Turning off backup will remove your current encryption key backup and turn off other security features. In this case, you will:
public static var screenKeyBackupDisableDescription: String { return L10n.tr("Localizable", "screen_key_backup_disable_description") }
/// Not have encrypted message history on new devices
public static var screenKeyBackupDisableDescriptionPoint1: String { return L10n.tr("Localizable", "screen_key_backup_disable_description_point_1") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ struct HomeScreenUserMenuButton: View {
/// Menu doesn't render composed views. Trick it into showing a badge.
private var settingsIconImage: Image? {
let settingsIcon = Image(systemSymbol: .gearshape)
.symbolRenderingMode(.palette)
.resizable()
.frame(width: 100, height: 100)
.overlayBadge(40, isBadged: context.viewState.showSettingsMenuOptionBadge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum SecureBackupScreenViewModelAction {
}

struct SecureBackupScreenViewState: BindableState {
let chatBackupDetailsURL: URL
var recoveryKeyState = SecureBackupRecoveryKeyState.unknown
var keyBackupState = SecureBackupKeyBackupState.unknown
var bindings = SecureBackupScreenViewStateBindings()
Expand All @@ -34,5 +35,4 @@ struct SecureBackupScreenViewStateBindings {
enum SecureBackupScreenViewAction {
case recoveryKey
case keyBackup
case learnMore
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ typealias SecureBackupScreenViewModelType = StateStoreViewModel<SecureBackupScre
class SecureBackupScreenViewModel: SecureBackupScreenViewModelType, SecureBackupScreenViewModelProtocol {
private let secureBackupController: SecureBackupControllerProtocol
private weak var userIndicatorController: UserIndicatorControllerProtocol?
private let chatBackupDetailsURL: URL

private var actionsSubject: PassthroughSubject<SecureBackupScreenViewModelAction, Never> = .init()
var actions: AnyPublisher<SecureBackupScreenViewModelAction, Never> {
Expand All @@ -34,9 +33,8 @@ class SecureBackupScreenViewModel: SecureBackupScreenViewModelType, SecureBackup
chatBackupDetailsURL: URL) {
self.secureBackupController = secureBackupController
self.userIndicatorController = userIndicatorController
self.chatBackupDetailsURL = chatBackupDetailsURL

super.init(initialViewState: .init())
super.init(initialViewState: .init(chatBackupDetailsURL: chatBackupDetailsURL))

secureBackupController.recoveryKeyState
.receive(on: DispatchQueue.main)
Expand Down Expand Up @@ -64,8 +62,6 @@ class SecureBackupScreenViewModel: SecureBackupScreenViewModelType, SecureBackup
default:
break
}
case .learnMore:
UIApplication.shared.open(chatBackupDetailsURL)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@ struct SecureBackupScreen: View {
.font(.compound.bodyLGSemibold)
.foregroundColor(.compound.textPrimary)

Button {
context.send(viewAction: .learnMore)
} label: {
Text((try? AttributedString(markdown: "\(L10n.screenChatBackupKeyBackupDescription) **\(L10n.actionLearnMore)**")) ?? "")
.font(.compound.bodySM)
.foregroundColor(.compound.textSecondary)
}
Text(keyBackupDescriptionWithLearnMoreLink)
.font(.compound.bodySM)
.foregroundColor(.compound.textSecondary)
}
.padding(.horizontal, ListRowPadding.horizontal)
.padding(.vertical, ListRowPadding.vertical)
Expand All @@ -64,6 +60,16 @@ struct SecureBackupScreen: View {
}
}

private var keyBackupDescriptionWithLearnMoreLink: AttributedString {
let linkPlaceholder = "{link}"
var description = AttributedString(L10n.screenChatBackupKeyBackupDescription(linkPlaceholder))
var linkString = AttributedString(L10n.actionLearnMore)
linkString.link = context.viewState.chatBackupDetailsURL
linkString.bold()
description.replace(linkPlaceholder, with: linkString)
return description
}

@ViewBuilder
private var keyBackupButton: some View {
switch context.viewState.keyBackupState {
Expand All @@ -76,7 +82,7 @@ struct SecureBackupScreen: View {
context.send(viewAction: .keyBackup)
})
default:
ListRow(label: .plain(title: L10n.commonLoading), details: .isWaiting(true), kind: .button { })
ListRow(label: .plain(title: L10n.commonLoading), details: .isWaiting(true), kind: .label)
}
}

Expand All @@ -95,7 +101,7 @@ struct SecureBackupScreen: View {
ListRow(label: .plain(title: L10n.screenChatBackupRecoveryActionConfirm),
kind: .navigationLink { context.send(viewAction: .recoveryKey) })
default:
ListRow(label: .plain(title: L10n.commonLoading), details: .isWaiting(true), kind: .button { })
ListRow(label: .plain(title: L10n.commonLoading), details: .isWaiting(true), kind: .label)
}
} footer: {
recoveryKeySectionFooter
Expand Down

0 comments on commit 39033ab

Please sign in to comment.