Secrets recovery: Update recovery with passphrase and recovery with key screens.

This commit is contained in:
SBiOSoftWhare
2020-06-11 13:21:47 +02:00
parent 043ddebdf3
commit 49211bdce2
17 changed files with 173 additions and 87 deletions
@@ -33,8 +33,8 @@ final class SecretsRecoveryWithPassphraseCoordinator: SecretsRecoveryWithPassphr
// MARK: - Setup
init(recoveryService: MXRecoveryService) {
let secretsRecoveryWithPassphraseViewModel = SecretsRecoveryWithPassphraseViewModel(recoveryService: recoveryService)
init(recoveryService: MXRecoveryService, recoveryGoal: SecretsRecoveryGoal) {
let secretsRecoveryWithPassphraseViewModel = SecretsRecoveryWithPassphraseViewModel(recoveryService: recoveryService, recoveryGoal: recoveryGoal)
let secretsRecoveryWithPassphraseViewController = SecretsRecoveryWithPassphraseViewController.instantiate(with: secretsRecoveryWithPassphraseViewModel)
self.secretsRecoveryWithPassphraseViewController = secretsRecoveryWithPassphraseViewController
self.secretsRecoveryWithPassphraseViewModel = secretsRecoveryWithPassphraseViewModel
@@ -22,27 +22,27 @@
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dlf-fL-IPA">
<rect key="frame" x="0.0" y="0.0" width="375" height="421"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="423"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Gw9-uS-bGl">
<rect key="frame" x="0.0" y="0.0" width="375" height="421"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="423"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="key_backup_logo" translatesAutoresizingMaskIntoConstraints="NO" id="hA4-wJ-xGz">
<rect key="frame" x="163.5" y="35" width="48" height="46"/>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="secrets_recovery_passphrase" translatesAutoresizingMaskIntoConstraints="NO" id="hA4-wJ-xGz">
<rect key="frame" x="165.5" y="35" width="44" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="48" id="6ho-II-3gd"/>
<constraint firstAttribute="height" constant="46" id="xDH-Af-ISa"/>
<constraint firstAttribute="width" constant="44" id="6ho-II-3gd"/>
<constraint firstAttribute="height" constant="48" id="xDH-Af-ISa"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p2V-aL-g0y">
<rect key="frame" x="20" y="111" width="335" height="54"/>
<rect key="frame" x="20" y="113" width="335" height="54"/>
<string key="text">Access your secure message history and your cross-signing identity for verifying other sessions by entering your recovery passphrase.</string>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uly-5I-NIc">
<rect key="frame" x="0.0" y="205" width="375" height="50"/>
<rect key="frame" x="0.0" y="207" width="375" height="50"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" text="enter" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="I7Q-Tb-YGd">
<rect key="frame" x="20" y="10" width="38" height="30"/>
@@ -91,7 +91,7 @@
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a20-Ii-sAN">
<rect key="frame" x="0.0" y="271" width="375" height="50"/>
<rect key="frame" x="0.0" y="273" width="375" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="9rW-yL-qS1"/>
</constraints>
@@ -108,16 +108,16 @@
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zOv-dc-49b">
<rect key="frame" x="0.0" y="351" width="375" height="50"/>
<rect key="frame" x="0.0" y="353" width="375" height="50"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DpI-8g-yKB">
<rect key="frame" x="0.0" y="0.0" width="375" height="50"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DpI-8g-yKB" customClass="RoundedButton" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="20" y="0.0" width="335" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="Ghb-Uq-q6w"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
<state key="normal" title="Recover Secrets">
<inset key="contentEdgeInsets" minX="20" minY="0.0" maxX="20" maxY="0.0"/>
<state key="normal" title="Validate">
<color key="titleColor" red="0.47843137250000001" green="0.78823529410000004" blue="0.63137254899999995" alpha="1" colorSpace="calibratedRGB"/>
</state>
<state key="disabled">
@@ -128,12 +128,12 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="DpI-8g-yKB" firstAttribute="leading" secondItem="zOv-dc-49b" secondAttribute="leading" id="IfU-Xj-hXn"/>
<constraint firstItem="DpI-8g-yKB" firstAttribute="centerX" secondItem="zOv-dc-49b" secondAttribute="centerX" id="Hr6-9M-GiX"/>
<constraint firstAttribute="bottom" secondItem="DpI-8g-yKB" secondAttribute="bottom" id="TTL-7C-OLb"/>
<constraint firstItem="DpI-8g-yKB" firstAttribute="top" secondItem="zOv-dc-49b" secondAttribute="top" id="TtN-kR-msg"/>
<constraint firstAttribute="trailing" secondItem="DpI-8g-yKB" secondAttribute="trailing" id="Y4l-a9-4la"/>
<constraint firstItem="DpI-8g-yKB" firstAttribute="width" secondItem="zOv-dc-49b" secondAttribute="width" priority="750" id="q7z-h9-oc7"/>
</constraints>
</view>
</subviews>
@@ -160,6 +160,8 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="DpI-8g-yKB" secondAttribute="trailing" constant="20" id="GWL-GS-AAo"/>
<constraint firstItem="DpI-8g-yKB" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="dlf-fL-IPA" secondAttribute="leading" constant="20" id="WtX-De-uw7"/>
<constraint firstItem="Gw9-uS-bGl" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="dlf-fL-IPA" secondAttribute="leading" id="dS8-xZ-yYp"/>
<constraint firstAttribute="bottom" secondItem="Gw9-uS-bGl" secondAttribute="bottom" id="npc-qR-fYH"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Gw9-uS-bGl" secondAttribute="trailing" id="sjh-zi-XoD"/>
@@ -193,7 +195,6 @@
<outlet property="passphraseTitleLabel" destination="I7Q-Tb-YGd" id="jrA-8B-fsw"/>
<outlet property="passphraseVisibilityButton" destination="ahr-Zq-UM4" id="95l-go-Yjj"/>
<outlet property="recoverButton" destination="DpI-8g-yKB" id="aA6-fD-whb"/>
<outlet property="recoverButtonBackgroundView" destination="zOv-dc-49b" id="QKD-5b-NJT"/>
<outlet property="scrollView" destination="FYl-Bb-Kpe" id="jR3-VH-AdU"/>
<outlet property="shieldImageView" destination="hA4-wJ-xGz" id="MPg-q1-UVx"/>
<outlet property="useRecoveryKeyButton" destination="a20-Ii-sAN" id="ZMQ-PQ-jEn"/>
@@ -205,7 +206,7 @@
</scene>
</scenes>
<resources>
<image name="key_backup_logo" width="48" height="46"/>
<image name="reveal_password_button" width="24" height="18"/>
<image name="secrets_recovery_passphrase" width="44" height="48"/>
</resources>
</document>
@@ -35,9 +35,8 @@ final class SecretsRecoveryWithPassphraseViewController: UIViewController {
@IBOutlet private weak var passphraseVisibilityButton: UIButton!
@IBOutlet private weak var useRecoveryKeyButton: UIButton!
@IBOutlet private weak var recoverButtonBackgroundView: UIView!
@IBOutlet private weak var recoverButton: UIButton!
@IBOutlet private weak var recoverButton: RoundedButton!
// MARK: Private
@@ -90,17 +89,26 @@ final class SecretsRecoveryWithPassphraseViewController: UIViewController {
}
self.navigationItem.rightBarButtonItem = cancelBarButtonItem
self.title = VectorL10n.secretsRecoveryTitle
self.title = VectorL10n.secretsRecoveryWithPassphraseTitle
self.scrollView.keyboardDismissMode = .interactive
let shieldImage = Asset.Images.keyBackupLogo.image.withRenderingMode(.alwaysTemplate)
let shieldImage = Asset.Images.secretsRecoveryPassphrase.image.withRenderingMode(.alwaysTemplate)
self.shieldImageView.image = shieldImage
let visibilityImage = Asset.Images.revealPasswordButton.image.withRenderingMode(.alwaysTemplate)
self.passphraseVisibilityButton.setImage(visibilityImage, for: .normal)
self.informationLabel.text = VectorL10n.secretsRecoveryWithPassphraseInformation
let informationText: String
switch self.viewModel.recoveryGoal {
case .default:
informationText = VectorL10n.secretsRecoveryWithPassphraseInformationDefault
case .verifyDevice:
informationText = VectorL10n.secretsRecoveryWithPassphraseInformationVerifyDevice
}
self.informationLabel.text = informationText
self.passphraseTitleLabel.text = VectorL10n.secretsRecoveryWithPassphrasePassphraseTitle
self.passphraseTextField.addTarget(self, action: #selector(passphraseTextFieldDidChange(_:)), for: .editingChanged)
@@ -134,8 +142,7 @@ final class SecretsRecoveryWithPassphraseViewController: UIViewController {
self.theme.applyStyle(onButton: self.passphraseVisibilityButton)
self.recoverButtonBackgroundView.backgroundColor = theme.backgroundColor
theme.applyStyle(onButton: self.recoverButton)
self.recoverButton.update(theme: theme)
let useRecoveryKeyAttributedString = NSMutableAttributedString(string: VectorL10n.secretsRecoveryWithPassphraseLostPassphraseActionPart1, attributes: [.foregroundColor: self.theme.textPrimaryColor])
let unknownRecoveryKeyAttributedStringPart2 = NSAttributedString(string: VectorL10n.secretsRecoveryWithPassphraseLostPassphraseActionPart2, attributes: [.foregroundColor: self.theme.tintColor])
@@ -26,6 +26,8 @@ final class SecretsRecoveryWithPassphraseViewModel: SecretsRecoveryWithPassphras
// MARK: Public
let recoveryGoal: SecretsRecoveryGoal
var passphrase: String?
var isFormValid: Bool {
@@ -37,8 +39,9 @@ final class SecretsRecoveryWithPassphraseViewModel: SecretsRecoveryWithPassphras
// MARK: - Setup
init(recoveryService: MXRecoveryService) {
init(recoveryService: MXRecoveryService, recoveryGoal: SecretsRecoveryGoal) {
self.recoveryService = recoveryService
self.recoveryGoal = recoveryGoal
}
// MARK: - Public
@@ -31,6 +31,7 @@ protocol SecretsRecoveryWithPassphraseViewModelType {
var passphrase: String? { get set }
var isFormValid: Bool { get }
var recoveryGoal: SecretsRecoveryGoal { get }
var viewDelegate: SecretsRecoveryWithPassphraseViewModelViewDelegate? { get set }
var coordinatorDelegate: SecretsRecoveryWithPassphraseViewModelCoordinatorDelegate? { get set }