Secrets recovery with passphrase: Add reset action.

This commit is contained in:
SBiOSoftWhare
2020-09-30 17:45:26 +02:00
parent 53e0b2e0cd
commit 72b244190d
7 changed files with 62 additions and 13 deletions

View File

@@ -57,9 +57,15 @@ extension SecretsRecoveryWithPassphraseCoordinator: SecretsRecoveryWithPassphras
self.delegate?.secretsRecoveryWithPassphraseCoordinatorDoNotKnowPassphrase(self)
}
func secretsRecoveryWithPassphraseViewModelDidRecover(_ viewModel: SecretsRecoveryWithPassphraseViewModelType) { self.delegate?.secretsRecoveryWithPassphraseCoordinatorDidRecover(self)
func secretsRecoveryWithPassphraseViewModelDidRecover(_ viewModel: SecretsRecoveryWithPassphraseViewModelType) {
self.delegate?.secretsRecoveryWithPassphraseCoordinatorDidRecover(self)
}
func secretsRecoveryWithPassphraseViewModelDidCancel(_ viewModel: SecretsRecoveryWithPassphraseViewModelType) { self.delegate?.secretsRecoveryWithPassphraseCoordinatorDidCancel(self)
}
func secretsRecoveryWithPassphraseViewModelDidCancel(_ viewModel: SecretsRecoveryWithPassphraseViewModelType) {
self.delegate?.secretsRecoveryWithPassphraseCoordinatorDidCancel(self)
}
func secretsRecoveryWithPassphraseViewModelWantsToResetSecrets(_ viewModel: SecretsRecoveryWithPassphraseViewModelType) {
self.delegate?.secretsRecoveryWithPassphraseCoordinatorWantsToResetSecrets(self)
}
}

View File

@@ -20,6 +20,7 @@ protocol SecretsRecoveryWithPassphraseCoordinatorDelegate: class {
func secretsRecoveryWithPassphraseCoordinatorDidRecover(_ coordinator: SecretsRecoveryWithPassphraseCoordinatorType)
func secretsRecoveryWithPassphraseCoordinatorDoNotKnowPassphrase(_ coordinator: SecretsRecoveryWithPassphraseCoordinatorType)
func secretsRecoveryWithPassphraseCoordinatorDidCancel(_ coordinator: SecretsRecoveryWithPassphraseCoordinatorType)
func secretsRecoveryWithPassphraseCoordinatorWantsToResetSecrets(_ coordinator: SecretsRecoveryWithPassphraseCoordinatorType)
}
/// `SecretsRecoveryWithPassphraseCoordinatorType` is a protocol describing a Coordinator that handle key backup passphrase recover navigation flow.

View File

@@ -20,5 +20,6 @@ import Foundation
enum SecretsRecoveryWithPassphraseViewAction {
case recover
case useRecoveryKey
case resetSecrets
case cancel
}

View File

@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="KkK-aQ-7Ig">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.3" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="KkK-aQ-7Ig">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@@ -19,13 +17,13 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FYl-Bb-Kpe">
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dlf-fL-IPA">
<rect key="frame" x="0.0" y="0.0" width="375" height="423"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="489"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Gw9-uS-bGl">
<rect key="frame" x="0.0" y="0.0" width="375" height="423"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="489"/>
<subviews>
<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"/>
@@ -55,7 +53,6 @@
<constraints>
<constraint firstAttribute="height" constant="50" id="iy4-UK-b6r"/>
</constraints>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" returnKeyType="done" secureTextEntry="YES"/>
<connections>
@@ -136,21 +133,41 @@
<constraint firstItem="DpI-8g-yKB" firstAttribute="width" secondItem="zOv-dc-49b" secondAttribute="width" priority="750" id="q7z-h9-oc7"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FsM-8o-pIc">
<rect key="frame" x="0.0" y="419" width="375" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="Zb9-Il-WIS"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<inset key="contentEdgeInsets" minX="20" minY="0.0" maxX="20" maxY="0.0"/>
<state key="normal" title="Forgot or lost all recovery options? Reset everything">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
<state key="disabled">
<color key="titleColor" red="0.47843137250000001" green="0.78823529410000004" blue="0.63137254899999995" alpha="0.5" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="resetSecretsAction:" destination="KkK-aQ-7Ig" eventType="touchUpInside" id="gCT-4A-pG6"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="zOv-dc-49b" secondAttribute="bottom" constant="20" id="3Wl-WT-6Et"/>
<constraint firstAttribute="trailing" secondItem="uly-5I-NIc" secondAttribute="trailing" id="6VB-MQ-hIp"/>
<constraint firstItem="p2V-aL-g0y" firstAttribute="top" secondItem="hA4-wJ-xGz" secondAttribute="bottom" constant="30" id="6eX-cP-a3F"/>
<constraint firstAttribute="trailing" secondItem="zOv-dc-49b" secondAttribute="trailing" id="9er-kg-arg"/>
<constraint firstItem="FsM-8o-pIc" firstAttribute="top" secondItem="zOv-dc-49b" secondAttribute="bottom" constant="16" id="KfQ-rd-n2B"/>
<constraint firstAttribute="width" priority="750" constant="500" id="NAT-Cc-oHN"/>
<constraint firstItem="a20-Ii-sAN" firstAttribute="top" secondItem="uly-5I-NIc" secondAttribute="bottom" constant="16" id="P9q-sL-AcP"/>
<constraint firstItem="p2V-aL-g0y" firstAttribute="leading" secondItem="Gw9-uS-bGl" secondAttribute="leading" constant="20" id="VM5-6u-8kW"/>
<constraint firstItem="uly-5I-NIc" firstAttribute="top" secondItem="p2V-aL-g0y" secondAttribute="bottom" constant="40" id="b6d-xb-RsF"/>
<constraint firstItem="zOv-dc-49b" firstAttribute="top" secondItem="a20-Ii-sAN" secondAttribute="bottom" constant="30" id="b6e-I5-UmV"/>
<constraint firstItem="zOv-dc-49b" firstAttribute="leading" secondItem="Gw9-uS-bGl" secondAttribute="leading" id="bdZ-LL-sEK"/>
<constraint firstAttribute="bottom" secondItem="FsM-8o-pIc" secondAttribute="bottom" constant="20" id="cFV-lL-sr0"/>
<constraint firstItem="uly-5I-NIc" firstAttribute="leading" secondItem="Gw9-uS-bGl" secondAttribute="leading" id="cbx-lF-FxP"/>
<constraint firstItem="FsM-8o-pIc" firstAttribute="leading" secondItem="Gw9-uS-bGl" secondAttribute="leading" id="dlb-Mp-dHQ"/>
<constraint firstAttribute="trailing" secondItem="p2V-aL-g0y" secondAttribute="trailing" constant="20" id="ebM-3Y-G7G"/>
<constraint firstAttribute="trailing" secondItem="FsM-8o-pIc" secondAttribute="trailing" id="jtO-Hw-15P"/>
<constraint firstItem="hA4-wJ-xGz" firstAttribute="centerX" secondItem="Gw9-uS-bGl" secondAttribute="centerX" id="v1j-88-njw"/>
<constraint firstAttribute="trailing" secondItem="a20-Ii-sAN" secondAttribute="trailing" id="ysR-iF-6Wq"/>
<constraint firstItem="hA4-wJ-xGz" firstAttribute="top" secondItem="Gw9-uS-bGl" secondAttribute="top" constant="35" id="zVj-yd-Zo3"/>
@@ -195,6 +212,7 @@
<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="resetSecretsButton" destination="FsM-8o-pIc" id="kKO-9G-JZD"/>
<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"/>

View File

@@ -38,6 +38,8 @@ final class SecretsRecoveryWithPassphraseViewController: UIViewController {
@IBOutlet private weak var recoverButton: RoundedButton!
@IBOutlet private weak var resetSecretsButton: UIButton!
// MARK: Private
private var viewModel: SecretsRecoveryWithPassphraseViewModelType!
@@ -119,6 +121,8 @@ final class SecretsRecoveryWithPassphraseViewController: UIViewController {
self.recoverButton.setTitle(VectorL10n.secretsRecoveryWithPassphraseRecoverAction, for: .normal)
self.updateRecoverButton()
self.resetSecretsButton.vc_enableMultiLinesTitle()
}
private func update(theme: Theme) {
@@ -144,6 +148,8 @@ final class SecretsRecoveryWithPassphraseViewController: UIViewController {
self.recoverButton.update(theme: theme)
// Use recovery key button
let useRecoveryKeyAttributedString = NSMutableAttributedString(string: VectorL10n.secretsRecoveryWithPassphraseLostPassphraseActionPart1, attributes: [.foregroundColor: self.theme.textPrimaryColor])
let unknownRecoveryKeyAttributedStringPart2 = NSAttributedString(string: VectorL10n.secretsRecoveryWithPassphraseLostPassphraseActionPart2, attributes: [.foregroundColor: self.theme.tintColor])
let unknownRecoveryKeyAttributedStringPart3 = NSAttributedString(string: VectorL10n.secretsRecoveryWithPassphraseLostPassphraseActionPart3, attributes: [.foregroundColor: self.theme.textPrimaryColor])
@@ -152,6 +158,15 @@ final class SecretsRecoveryWithPassphraseViewController: UIViewController {
useRecoveryKeyAttributedString.append(unknownRecoveryKeyAttributedStringPart3)
self.useRecoveryKeyButton.setAttributedTitle(useRecoveryKeyAttributedString, for: .normal)
// 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() {
@@ -222,6 +237,11 @@ final class SecretsRecoveryWithPassphraseViewController: UIViewController {
@IBAction private func useRecoveryKeyButtonAction(_ sender: Any) {
self.viewModel.process(viewAction: .useRecoveryKey)
}
@IBAction private func resetSecretsAction(_ sender: Any) {
self.viewModel.process(viewAction: .resetSecrets)
}
}
// MARK: - UITextFieldDelegate

View File

@@ -54,6 +54,8 @@ final class SecretsRecoveryWithPassphraseViewModel: SecretsRecoveryWithPassphras
self.coordinatorDelegate?.secretsRecoveryWithPassphraseViewModelDidCancel(self)
case .useRecoveryKey:
self.coordinatorDelegate?.secretsRecoveryWithPassphraseViewModelWantsToRecoverByKey(self)
case .resetSecrets:
self.coordinatorDelegate?.secretsRecoveryWithPassphraseViewModelWantsToResetSecrets(self)
}
}

View File

@@ -24,6 +24,7 @@ protocol SecretsRecoveryWithPassphraseViewModelCoordinatorDelegate: class {
func secretsRecoveryWithPassphraseViewModelDidRecover(_ viewModel: SecretsRecoveryWithPassphraseViewModelType)
func secretsRecoveryWithPassphraseViewModelDidCancel(_ viewModel: SecretsRecoveryWithPassphraseViewModelType)
func secretsRecoveryWithPassphraseViewModelWantsToRecoverByKey(_ viewModel: SecretsRecoveryWithPassphraseViewModelType)
func secretsRecoveryWithPassphraseViewModelWantsToResetSecrets(_ viewModel: SecretsRecoveryWithPassphraseViewModelType)
}
/// Protocol describing the view model used by `SecretsRecoveryWithPassphraseViewController`