mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Secrets recover with key: Add reset action.
This commit is contained in:
parent
eea6ba53f1
commit
1684d7a7a8
7 changed files with 55 additions and 11 deletions
|
@ -59,4 +59,8 @@ extension SecretsRecoveryWithKeyCoordinator: SecretsRecoveryWithKeyViewModelCoor
|
||||||
|
|
||||||
func secretsRecoveryWithKeyViewModelDidCancel(_ viewModel: SecretsRecoveryWithKeyViewModelType) { self.delegate?.secretsRecoveryWithKeyCoordinatorDidCancel(self)
|
func secretsRecoveryWithKeyViewModelDidCancel(_ viewModel: SecretsRecoveryWithKeyViewModelType) { self.delegate?.secretsRecoveryWithKeyCoordinatorDidCancel(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func secretsRecoveryWithKeyViewModelWantsToResetSecrets(_ viewModel: SecretsRecoveryWithKeyViewModelType) {
|
||||||
|
self.delegate?.secretsRecoveryWithKeyCoordinatorWantsToResetSecrets(self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import Foundation
|
||||||
protocol SecretsRecoveryWithKeyCoordinatorDelegate: class {
|
protocol SecretsRecoveryWithKeyCoordinatorDelegate: class {
|
||||||
func secretsRecoveryWithKeyCoordinatorDidRecover(_ coordinator: SecretsRecoveryWithKeyCoordinatorType)
|
func secretsRecoveryWithKeyCoordinatorDidRecover(_ coordinator: SecretsRecoveryWithKeyCoordinatorType)
|
||||||
func secretsRecoveryWithKeyCoordinatorDidCancel(_ 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.
|
/// `SecretsRecoveryWithKeyCoordinatorType` is a protocol describing a Coordinator that handle secrets recovery from recovery key navigation flow.
|
||||||
|
|
|
@ -18,6 +18,7 @@ import Foundation
|
||||||
|
|
||||||
/// SecretsRecoveryWithKeyViewController view actions exposed to view model
|
/// SecretsRecoveryWithKeyViewController view actions exposed to view model
|
||||||
enum SecretsRecoveryWithKeyViewAction {
|
enum SecretsRecoveryWithKeyViewAction {
|
||||||
case recover
|
case recover
|
||||||
|
case resetSecrets
|
||||||
case cancel
|
case cancel
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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="xgV-qW-Fsz">
|
<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="xgV-qW-Fsz">
|
||||||
<device id="retina4_7" orientation="portrait">
|
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||||
<adaptation id="fullscreen"/>
|
|
||||||
</device>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="iOS"/>
|
<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="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -19,13 +17,13 @@
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lGc-J1-CgX">
|
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lGc-J1-CgX">
|
||||||
<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>
|
<subviews>
|
||||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="byL-eq-NOk">
|
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="byL-eq-NOk">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="375" height="377"/>
|
<rect key="frame" x="0.0" y="0.0" width="375" height="443"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lYT-Tl-Mah">
|
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lYT-Tl-Mah">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="375" height="377"/>
|
<rect key="frame" x="0.0" y="0.0" width="375" height="443"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="secrets_recovery_key" translatesAutoresizingMaskIntoConstraints="NO" id="eS4-VO-THO">
|
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="secrets_recovery_key" translatesAutoresizingMaskIntoConstraints="NO" id="eS4-VO-THO">
|
||||||
<rect key="frame" x="165.5" y="35" width="44" height="48"/>
|
<rect key="frame" x="165.5" y="35" width="44" height="48"/>
|
||||||
|
@ -54,7 +52,6 @@
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="height" constant="50" id="3ip-DB-fLs"/>
|
<constraint firstAttribute="height" constant="50" id="3ip-DB-fLs"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<nil key="textColor"/>
|
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||||
<textInputTraits key="textInputTraits" autocorrectionType="no" returnKeyType="done"/>
|
<textInputTraits key="textInputTraits" autocorrectionType="no" returnKeyType="done"/>
|
||||||
<connections>
|
<connections>
|
||||||
|
@ -120,20 +117,40 @@
|
||||||
<constraint firstItem="HrF-Jh-mlh" firstAttribute="top" secondItem="xo4-pw-QbA" secondAttribute="top" id="dr9-B3-nAt"/>
|
<constraint firstItem="HrF-Jh-mlh" firstAttribute="top" secondItem="xo4-pw-QbA" secondAttribute="top" id="dr9-B3-nAt"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PPL-j2-hnv">
|
||||||
|
<rect key="frame" x="0.0" y="373" width="375" height="50"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="height" constant="50" id="ORA-ea-g34"/>
|
||||||
|
</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="xgV-qW-Fsz" eventType="touchUpInside" id="vaK-ot-P1e"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="bottom" secondItem="xo4-pw-QbA" secondAttribute="bottom" constant="20" id="0B3-c2-ro5"/>
|
|
||||||
<constraint firstItem="v8b-un-B61" firstAttribute="top" secondItem="nE7-cw-Z30" secondAttribute="bottom" constant="40" id="0OM-LN-FIF"/>
|
<constraint firstItem="v8b-un-B61" firstAttribute="top" secondItem="nE7-cw-Z30" secondAttribute="bottom" constant="40" id="0OM-LN-FIF"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="nE7-cw-Z30" secondAttribute="trailing" constant="20" id="25y-AS-2UT"/>
|
<constraint firstAttribute="trailing" secondItem="nE7-cw-Z30" secondAttribute="trailing" constant="20" id="25y-AS-2UT"/>
|
||||||
<constraint firstItem="xo4-pw-QbA" firstAttribute="leading" secondItem="lYT-Tl-Mah" secondAttribute="leading" id="5h3-ut-ljD"/>
|
<constraint firstItem="xo4-pw-QbA" firstAttribute="leading" secondItem="lYT-Tl-Mah" secondAttribute="leading" id="5h3-ut-ljD"/>
|
||||||
<constraint firstItem="nE7-cw-Z30" firstAttribute="top" secondItem="eS4-VO-THO" secondAttribute="bottom" constant="30" id="87H-5c-7L4"/>
|
<constraint firstItem="nE7-cw-Z30" firstAttribute="top" secondItem="eS4-VO-THO" secondAttribute="bottom" constant="30" id="87H-5c-7L4"/>
|
||||||
<constraint firstItem="eS4-VO-THO" firstAttribute="top" secondItem="lYT-Tl-Mah" secondAttribute="top" constant="35" id="JwA-G2-VIj"/>
|
<constraint firstItem="eS4-VO-THO" firstAttribute="top" secondItem="lYT-Tl-Mah" secondAttribute="top" constant="35" id="JwA-G2-VIj"/>
|
||||||
|
<constraint firstItem="PPL-j2-hnv" firstAttribute="leading" secondItem="lYT-Tl-Mah" secondAttribute="leading" id="L4S-8s-L8O"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="v8b-un-B61" secondAttribute="trailing" id="MIp-Z4-OI9"/>
|
<constraint firstAttribute="trailing" secondItem="v8b-un-B61" secondAttribute="trailing" id="MIp-Z4-OI9"/>
|
||||||
<constraint firstItem="v8b-un-B61" firstAttribute="leading" secondItem="lYT-Tl-Mah" secondAttribute="leading" id="XIH-Fa-RSj"/>
|
<constraint firstItem="v8b-un-B61" firstAttribute="leading" secondItem="lYT-Tl-Mah" secondAttribute="leading" id="XIH-Fa-RSj"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="PPL-j2-hnv" secondAttribute="bottom" constant="20" id="XKs-5K-o7w"/>
|
||||||
<constraint firstItem="eS4-VO-THO" firstAttribute="centerX" secondItem="lYT-Tl-Mah" secondAttribute="centerX" id="YZk-TW-2Yb"/>
|
<constraint firstItem="eS4-VO-THO" firstAttribute="centerX" secondItem="lYT-Tl-Mah" secondAttribute="centerX" id="YZk-TW-2Yb"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="xo4-pw-QbA" secondAttribute="trailing" id="fWz-BT-edl"/>
|
<constraint firstAttribute="trailing" secondItem="xo4-pw-QbA" secondAttribute="trailing" id="fWz-BT-edl"/>
|
||||||
|
<constraint firstItem="PPL-j2-hnv" firstAttribute="top" secondItem="xo4-pw-QbA" secondAttribute="bottom" constant="16" id="lUh-Qo-meH"/>
|
||||||
<constraint firstItem="nE7-cw-Z30" firstAttribute="leading" secondItem="lYT-Tl-Mah" secondAttribute="leading" constant="20" id="ooI-aS-mXQ"/>
|
<constraint firstItem="nE7-cw-Z30" firstAttribute="leading" secondItem="lYT-Tl-Mah" secondAttribute="leading" constant="20" id="ooI-aS-mXQ"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="PPL-j2-hnv" secondAttribute="trailing" id="qHl-BD-M1y"/>
|
||||||
<constraint firstAttribute="width" priority="750" constant="500" id="qpC-Rx-87A"/>
|
<constraint firstAttribute="width" priority="750" constant="500" id="qpC-Rx-87A"/>
|
||||||
<constraint firstItem="xo4-pw-QbA" firstAttribute="top" secondItem="v8b-un-B61" secondAttribute="bottom" constant="50" id="xiD-aT-T0f"/>
|
<constraint firstItem="xo4-pw-QbA" firstAttribute="top" secondItem="v8b-un-B61" secondAttribute="bottom" constant="50" id="xiD-aT-T0f"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
|
@ -174,6 +191,7 @@
|
||||||
<outlet property="recoveryKeyTextField" destination="e79-U2-RHY" id="xEP-LQ-rKR"/>
|
<outlet property="recoveryKeyTextField" destination="e79-U2-RHY" id="xEP-LQ-rKR"/>
|
||||||
<outlet property="recoveryKeyTextFieldBackgroundView" destination="v8b-un-B61" id="YIA-Sn-A22"/>
|
<outlet property="recoveryKeyTextFieldBackgroundView" destination="v8b-un-B61" id="YIA-Sn-A22"/>
|
||||||
<outlet property="recoveryKeyTitleLabel" destination="UdR-PC-WoG" id="R8h-o0-2tR"/>
|
<outlet property="recoveryKeyTitleLabel" destination="UdR-PC-WoG" id="R8h-o0-2tR"/>
|
||||||
|
<outlet property="resetSecretsButton" destination="PPL-j2-hnv" id="Nec-yK-DkU"/>
|
||||||
<outlet property="scrollView" destination="lGc-J1-CgX" id="9Il-vB-zoh"/>
|
<outlet property="scrollView" destination="lGc-J1-CgX" id="9Il-vB-zoh"/>
|
||||||
<outlet property="shieldImageView" destination="eS4-VO-THO" id="P6x-QL-Mqv"/>
|
<outlet property="shieldImageView" destination="eS4-VO-THO" id="P6x-QL-Mqv"/>
|
||||||
</connections>
|
</connections>
|
||||||
|
|
|
@ -36,6 +36,8 @@ final class SecretsRecoveryWithKeyViewController: UIViewController {
|
||||||
@IBOutlet private weak var importFileButton: UIButton!
|
@IBOutlet private weak var importFileButton: UIButton!
|
||||||
|
|
||||||
@IBOutlet private weak var recoverButton: RoundedButton!
|
@IBOutlet private weak var recoverButton: RoundedButton!
|
||||||
|
|
||||||
|
@IBOutlet private weak var resetSecretsButton: UIButton!
|
||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
|
@ -117,6 +119,8 @@ final class SecretsRecoveryWithKeyViewController: UIViewController {
|
||||||
self.recoverButton.setTitle(VectorL10n.secretsRecoveryWithKeyRecoverAction, for: .normal)
|
self.recoverButton.setTitle(VectorL10n.secretsRecoveryWithKeyRecoverAction, for: .normal)
|
||||||
|
|
||||||
self.updateRecoverButton()
|
self.updateRecoverButton()
|
||||||
|
|
||||||
|
self.resetSecretsButton.vc_enableMultiLinesTitle()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func update(theme: Theme) {
|
private func update(theme: Theme) {
|
||||||
|
@ -140,6 +144,15 @@ final class SecretsRecoveryWithKeyViewController: UIViewController {
|
||||||
theme.applyStyle(onButton: self.importFileButton)
|
theme.applyStyle(onButton: self.importFileButton)
|
||||||
|
|
||||||
self.recoverButton.update(theme: theme)
|
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() {
|
private func registerThemeServiceDidChangeThemeNotification() {
|
||||||
|
@ -241,6 +254,10 @@ final class SecretsRecoveryWithKeyViewController: UIViewController {
|
||||||
@IBAction private func recoverButtonAction(_ sender: Any) {
|
@IBAction private func recoverButtonAction(_ sender: Any) {
|
||||||
self.viewModel.process(viewAction: .recover)
|
self.viewModel.process(viewAction: .recover)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction private func resetSecretsAction(_ sender: Any) {
|
||||||
|
self.viewModel.process(viewAction: .resetSecrets)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - UITextFieldDelegate
|
// MARK: - UITextFieldDelegate
|
||||||
|
|
|
@ -50,6 +50,8 @@ final class SecretsRecoveryWithKeyViewModel: SecretsRecoveryWithKeyViewModelType
|
||||||
switch viewAction {
|
switch viewAction {
|
||||||
case .recover:
|
case .recover:
|
||||||
self.recover()
|
self.recover()
|
||||||
|
case .resetSecrets:
|
||||||
|
self.coordinatorDelegate?.secretsRecoveryWithKeyViewModelWantsToResetSecrets(self)
|
||||||
case .cancel:
|
case .cancel:
|
||||||
self.coordinatorDelegate?.secretsRecoveryWithKeyViewModelDidCancel(self)
|
self.coordinatorDelegate?.secretsRecoveryWithKeyViewModelDidCancel(self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ protocol SecretsRecoveryWithKeyViewModelViewDelegate: class {
|
||||||
protocol SecretsRecoveryWithKeyViewModelCoordinatorDelegate: class {
|
protocol SecretsRecoveryWithKeyViewModelCoordinatorDelegate: class {
|
||||||
func secretsRecoveryWithKeyViewModelDidRecover(_ viewModel: SecretsRecoveryWithKeyViewModelType)
|
func secretsRecoveryWithKeyViewModelDidRecover(_ viewModel: SecretsRecoveryWithKeyViewModelType)
|
||||||
func secretsRecoveryWithKeyViewModelDidCancel(_ viewModel: SecretsRecoveryWithKeyViewModelType)
|
func secretsRecoveryWithKeyViewModelDidCancel(_ viewModel: SecretsRecoveryWithKeyViewModelType)
|
||||||
|
func secretsRecoveryWithKeyViewModelWantsToResetSecrets(_ viewModel: SecretsRecoveryWithKeyViewModelType)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Protocol describing the view model used by `SecretsRecoveryWithPassphraseViewController`
|
/// Protocol describing the view model used by `SecretsRecoveryWithPassphraseViewController`
|
||||||
|
|
Loading…
Reference in a new issue