diff --git a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyCoordinator.swift b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyCoordinator.swift index 7db8d0bf3..c9be632dd 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyCoordinator.swift +++ b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyCoordinator.swift @@ -59,4 +59,8 @@ extension SecretsRecoveryWithKeyCoordinator: SecretsRecoveryWithKeyViewModelCoor func secretsRecoveryWithKeyViewModelDidCancel(_ viewModel: SecretsRecoveryWithKeyViewModelType) { self.delegate?.secretsRecoveryWithKeyCoordinatorDidCancel(self) } + + func secretsRecoveryWithKeyViewModelWantsToResetSecrets(_ viewModel: SecretsRecoveryWithKeyViewModelType) { + self.delegate?.secretsRecoveryWithKeyCoordinatorWantsToResetSecrets(self) + } } diff --git a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyCoordinatorType.swift b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyCoordinatorType.swift index 3a06e4a9d..f0a593f99 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyCoordinatorType.swift +++ b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyCoordinatorType.swift @@ -19,6 +19,7 @@ import Foundation protocol SecretsRecoveryWithKeyCoordinatorDelegate: class { func secretsRecoveryWithKeyCoordinatorDidRecover(_ coordinator: SecretsRecoveryWithKeyCoordinatorType) func secretsRecoveryWithKeyCoordinatorDidCancel(_ coordinator: SecretsRecoveryWithKeyCoordinatorType) + func secretsRecoveryWithKeyCoordinatorWantsToResetSecrets(_ viewModel: SecretsRecoveryWithKeyCoordinatorType) } /// `SecretsRecoveryWithKeyCoordinatorType` is a protocol describing a Coordinator that handle secrets recovery from recovery key navigation flow. diff --git a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewAction.swift b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewAction.swift index 915dd3aec..66a0818a4 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewAction.swift +++ b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewAction.swift @@ -18,6 +18,7 @@ import Foundation /// SecretsRecoveryWithKeyViewController view actions exposed to view model enum SecretsRecoveryWithKeyViewAction { - case recover + case recover + case resetSecrets case cancel } diff --git a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.storyboard b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.storyboard index d9118f291..5f835af6b 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.storyboard +++ b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.storyboard @@ -1,11 +1,9 @@ - - - - + + - + @@ -19,13 +17,13 @@ - + - + - + @@ -54,7 +52,6 @@ - @@ -120,20 +117,40 @@ + - + + + + @@ -174,6 +191,7 @@ + diff --git a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift index c8c97a5c4..b8a328289 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift +++ b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift @@ -36,6 +36,8 @@ final class SecretsRecoveryWithKeyViewController: UIViewController { @IBOutlet private weak var importFileButton: UIButton! @IBOutlet private weak var recoverButton: RoundedButton! + + @IBOutlet private weak var resetSecretsButton: UIButton! // MARK: Private @@ -117,6 +119,8 @@ final class SecretsRecoveryWithKeyViewController: UIViewController { self.recoverButton.setTitle(VectorL10n.secretsRecoveryWithKeyRecoverAction, for: .normal) self.updateRecoverButton() + + self.resetSecretsButton.vc_enableMultiLinesTitle() } private func update(theme: Theme) { @@ -140,6 +144,15 @@ final class SecretsRecoveryWithKeyViewController: UIViewController { theme.applyStyle(onButton: self.importFileButton) self.recoverButton.update(theme: theme) + + // Reset secrets button + + let resetSecretsAttributedString = NSMutableAttributedString(string: VectorL10n.secretsRecoveryResetActionPart1, attributes: [.foregroundColor: self.theme.textPrimaryColor]) + let resetSecretsAttributedStringPart2 = NSAttributedString(string: VectorL10n.secretsRecoveryResetActionPart2, attributes: [.foregroundColor: self.theme.warningColor]) + + resetSecretsAttributedString.append(resetSecretsAttributedStringPart2) + + self.resetSecretsButton.setAttributedTitle(resetSecretsAttributedString, for: .normal) } private func registerThemeServiceDidChangeThemeNotification() { @@ -241,6 +254,10 @@ final class SecretsRecoveryWithKeyViewController: UIViewController { @IBAction private func recoverButtonAction(_ sender: Any) { self.viewModel.process(viewAction: .recover) } + + @IBAction private func resetSecretsAction(_ sender: Any) { + self.viewModel.process(viewAction: .resetSecrets) + } } // MARK: - UITextFieldDelegate diff --git a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewModel.swift b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewModel.swift index 0dc7607cc..f56562f7d 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewModel.swift +++ b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewModel.swift @@ -50,6 +50,8 @@ final class SecretsRecoveryWithKeyViewModel: SecretsRecoveryWithKeyViewModelType switch viewAction { case .recover: self.recover() + case .resetSecrets: + self.coordinatorDelegate?.secretsRecoveryWithKeyViewModelWantsToResetSecrets(self) case .cancel: self.coordinatorDelegate?.secretsRecoveryWithKeyViewModelDidCancel(self) } diff --git a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewModelType.swift b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewModelType.swift index 62faee9b5..c747d67ba 100644 --- a/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewModelType.swift +++ b/Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewModelType.swift @@ -23,6 +23,7 @@ protocol SecretsRecoveryWithKeyViewModelViewDelegate: class { protocol SecretsRecoveryWithKeyViewModelCoordinatorDelegate: class { func secretsRecoveryWithKeyViewModelDidRecover(_ viewModel: SecretsRecoveryWithKeyViewModelType) func secretsRecoveryWithKeyViewModelDidCancel(_ viewModel: SecretsRecoveryWithKeyViewModelType) + func secretsRecoveryWithKeyViewModelWantsToResetSecrets(_ viewModel: SecretsRecoveryWithKeyViewModelType) } /// Protocol describing the view model used by `SecretsRecoveryWithPassphraseViewController`