Key Backup setup: Create the key backup using 4S if it exists

This commit is contained in:
manuroe
2021-06-16 08:18:23 +02:00
parent df628da793
commit 5e2d75a2fb
11 changed files with 362 additions and 27 deletions
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="b2C-jK-KPV">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Key Backup Setup Success From Secure Backup View Controller-->
<scene sceneID="A4c-pi-pNE">
<objects>
<viewController extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="b2C-jK-KPV" customClass="KeyBackupSetupSuccessFromSecureBackupViewController" customModule="Riot" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="YAN-xg-EgW">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="S5g-F9-L3B">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="a4X-9Q-mkr">
<rect key="frame" x="0.0" y="0.0" width="375" height="505"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="o2g-Ga-wwR">
<rect key="frame" x="0.0" y="0.0" width="375" height="505"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="key_backup_logo" translatesAutoresizingMaskIntoConstraints="NO" id="epg-Qy-eoD">
<rect key="frame" x="163.5" y="40" width="48" height="46"/>
<constraints>
<constraint firstAttribute="width" constant="48" id="V1N-K1-elw"/>
<constraint firstAttribute="height" constant="46" id="Yzm-7B-uv2"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="30" translatesAutoresizingMaskIntoConstraints="NO" id="xlp-uc-Mug">
<rect key="frame" x="20" y="121" width="335" height="68.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Success!" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="X7g-Ha-15I">
<rect key="frame" x="0.0" y="0.0" width="335" height="20.5"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Your keys are being backed up." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3eY-3I-XYH">
<rect key="frame" x="0.0" y="50.5" width="335" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7aK-CF-d5d">
<rect key="frame" x="0.0" y="435" width="375" height="50"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QxC-gf-8VN">
<rect key="frame" x="0.0" y="0.0" width="375" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="qB9-Kq-7Jw"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
<state key="normal" title="Done">
<color key="titleColor" red="0.47843137250000001" green="0.78823529410000004" blue="0.63137254899999995" alpha="1" colorSpace="calibratedRGB"/>
</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="doneButtonAction:" destination="b2C-jK-KPV" eventType="touchUpInside" id="Vs7-qI-yBp"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="QxC-gf-8VN" secondAttribute="bottom" id="HQu-va-hRH"/>
<constraint firstAttribute="trailing" secondItem="QxC-gf-8VN" secondAttribute="trailing" id="N4c-nq-GMC"/>
<constraint firstItem="QxC-gf-8VN" firstAttribute="leading" secondItem="7aK-CF-d5d" secondAttribute="leading" id="Z8A-af-23Q"/>
<constraint firstItem="QxC-gf-8VN" firstAttribute="top" secondItem="7aK-CF-d5d" secondAttribute="top" id="sed-9I-71h"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="7aK-CF-d5d" firstAttribute="leading" secondItem="o2g-Ga-wwR" secondAttribute="leading" id="1Hy-bc-46Y"/>
<constraint firstAttribute="width" priority="750" constant="500" id="4a2-Az-ekr"/>
<constraint firstItem="epg-Qy-eoD" firstAttribute="centerX" secondItem="o2g-Ga-wwR" secondAttribute="centerX" id="K4J-2Y-7bW"/>
<constraint firstItem="xlp-uc-Mug" firstAttribute="leading" secondItem="o2g-Ga-wwR" secondAttribute="leading" constant="20" id="drb-kN-IRX"/>
<constraint firstItem="xlp-uc-Mug" firstAttribute="top" secondItem="epg-Qy-eoD" secondAttribute="bottom" constant="35" id="hyp-kS-l81"/>
<constraint firstAttribute="bottom" secondItem="7aK-CF-d5d" secondAttribute="bottom" constant="20" id="nPL-nn-PpM"/>
<constraint firstItem="epg-Qy-eoD" firstAttribute="top" secondItem="o2g-Ga-wwR" secondAttribute="top" constant="40" id="p1e-CF-Kln"/>
<constraint firstAttribute="trailing" secondItem="7aK-CF-d5d" secondAttribute="trailing" id="wl8-ha-UIh"/>
<constraint firstAttribute="trailing" secondItem="xlp-uc-Mug" secondAttribute="trailing" constant="20" id="xIU-IL-ycK"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="o2g-Ga-wwR" firstAttribute="centerX" secondItem="a4X-9Q-mkr" secondAttribute="centerX" id="8Ps-hI-nHv"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="o2g-Ga-wwR" secondAttribute="trailing" id="GBk-AU-PAx"/>
<constraint firstItem="o2g-Ga-wwR" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="a4X-9Q-mkr" secondAttribute="leading" id="Z9f-1y-sJV"/>
<constraint firstAttribute="height" constant="505" id="dth-O0-khE"/>
<constraint firstAttribute="bottom" secondItem="o2g-Ga-wwR" secondAttribute="bottom" id="kJP-Gd-vDF"/>
<constraint firstItem="o2g-Ga-wwR" firstAttribute="top" secondItem="a4X-9Q-mkr" secondAttribute="top" id="zZX-fo-MMO"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="a4X-9Q-mkr" firstAttribute="top" secondItem="S5g-F9-L3B" secondAttribute="top" id="47v-Wy-vaA"/>
<constraint firstItem="a4X-9Q-mkr" firstAttribute="width" secondItem="S5g-F9-L3B" secondAttribute="width" id="REA-MB-gew"/>
<constraint firstAttribute="bottom" secondItem="a4X-9Q-mkr" secondAttribute="bottom" id="Sqk-TW-ccx"/>
<constraint firstAttribute="trailing" secondItem="a4X-9Q-mkr" secondAttribute="trailing" id="keL-QJ-bja"/>
<constraint firstItem="a4X-9Q-mkr" firstAttribute="leading" secondItem="S5g-F9-L3B" secondAttribute="leading" id="maD-UF-Wim"/>
</constraints>
</scrollView>
</subviews>
<viewLayoutGuide key="safeArea" id="hUM-zt-PJj"/>
<color key="backgroundColor" red="0.94509803920000002" green="0.96078431369999995" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="hUM-zt-PJj" firstAttribute="trailing" secondItem="S5g-F9-L3B" secondAttribute="trailing" id="EAb-7P-Zsd"/>
<constraint firstAttribute="bottom" secondItem="S5g-F9-L3B" secondAttribute="bottom" id="Ham-fU-JWM"/>
<constraint firstItem="hUM-zt-PJj" firstAttribute="top" secondItem="S5g-F9-L3B" secondAttribute="top" id="Zkl-TJ-HEv"/>
<constraint firstItem="S5g-F9-L3B" firstAttribute="leading" secondItem="hUM-zt-PJj" secondAttribute="leading" id="sme-S5-pY5"/>
</constraints>
</view>
<connections>
<outlet property="doneButton" destination="QxC-gf-8VN" id="eOc-Ec-FgG"/>
<outlet property="doneButtonBackgroundView" destination="7aK-CF-d5d" id="y7U-Ol-8Nk"/>
<outlet property="informationLabel" destination="3eY-3I-XYH" id="ZT2-Lo-JlX"/>
<outlet property="keyBackupLogoImageView" destination="epg-Qy-eoD" id="YOa-Pv-XrT"/>
<outlet property="titleLabel" destination="X7g-Ha-15I" id="yMg-6G-6lF"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Yhm-Kv-QZF" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-3178" y="-675"/>
</scene>
</scenes>
<resources>
<image name="key_backup_logo" width="48" height="46"/>
</resources>
</document>
@@ -0,0 +1,120 @@
/*
Copyright 2021 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import UIKit
protocol KeyBackupSetupSuccessFromSecureBackupViewControllerDelegate: class {
func keyBackupSetupSuccessFromSecureBackupViewControllerDidTapDoneAction(_ viewController: KeyBackupSetupSuccessFromSecureBackupViewController)
}
final class KeyBackupSetupSuccessFromSecureBackupViewController: UIViewController {
// MARK: - Properties
// MARK: Outlets
@IBOutlet private weak var keyBackupLogoImageView: UIImageView!
@IBOutlet private weak var titleLabel: UILabel!
@IBOutlet private weak var informationLabel: UILabel!
@IBOutlet private weak var doneButtonBackgroundView: UIView!
@IBOutlet private weak var doneButton: UIButton!
// MARK: Private
private var theme: Theme!
// MARK: Public
weak var delegate: KeyBackupSetupSuccessFromSecureBackupViewControllerDelegate?
// MARK: - Setup
class func instantiate() -> KeyBackupSetupSuccessFromSecureBackupViewController {
let viewController = StoryboardScene.KeyBackupSetupSuccessFromSecureBackupViewController.initialScene.instantiate()
viewController.theme = ThemeService.shared().theme
return viewController
}
// MARK: - Life cycle
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.title = VectorL10n.keyBackupSetupTitle
self.setupViews()
self.registerThemeServiceDidChangeThemeNotification()
self.update(theme: self.theme)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Hide back button
self.navigationItem.setHidesBackButton(true, animated: animated)
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return self.theme.statusBarStyle
}
// MARK: - Private
private func setupViews() {
let keybackupLogoImage = Asset.Images.keyBackupLogo.image.withRenderingMode(.alwaysTemplate)
self.keyBackupLogoImageView.image = keybackupLogoImage
self.titleLabel.text = VectorL10n.keyBackupSetupSuccessTitle
self.informationLabel.text = VectorL10n.keyBackupSetupSuccessFromSecureBackupInfo
self.doneButton.setTitle(VectorL10n.keyBackupSetupSuccessFromPassphraseDoneAction, for: .normal)
}
private func update(theme: Theme) {
self.theme = theme
self.view.backgroundColor = theme.headerBackgroundColor
if let navigationBar = self.navigationController?.navigationBar {
theme.applyStyle(onNavigationBar: navigationBar)
}
self.keyBackupLogoImageView.tintColor = theme.textPrimaryColor
self.titleLabel.textColor = theme.textPrimaryColor
self.informationLabel.textColor = theme.textPrimaryColor
self.doneButtonBackgroundView.backgroundColor = theme.backgroundColor
theme.applyStyle(onButton: self.doneButton)
}
private func registerThemeServiceDidChangeThemeNotification() {
NotificationCenter.default.addObserver(self, selector: #selector(themeDidChange), name: .themeServiceDidChangeTheme, object: nil)
}
@objc private func themeDidChange() {
self.update(theme: ThemeService.shared().theme)
}
// MARK: - Actions
@IBAction private func doneButtonAction(_ sender: Any) {
self.delegate?.keyBackupSetupSuccessFromSecureBackupViewControllerDidTapDoneAction(self)
}
}