Add new view states and explanatory label

This commit is contained in:
ismailgulek 2020-09-17 20:20:43 +03:00
parent d36fca38ae
commit 2299a51ced
3 changed files with 43 additions and 8 deletions

View file

@ -37,7 +37,7 @@
<rect key="frame" x="0.0" y="52" width="375" height="718"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ztg-5t-ECh" userLabel="Container">
<rect key="frame" x="20" y="0.0" width="335" height="86"/>
<rect key="frame" x="20" y="0.0" width="335" height="172.33333333333334"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="app_symbol" translatesAutoresizingMaskIntoConstraints="NO" id="UHg-qE-anw">
<rect key="frame" x="147.66666666666666" y="8" width="40" height="40"/>
@ -47,24 +47,35 @@
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Choose a PIN for security" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bxI-mu-qng">
<rect key="frame" x="41.333333333333329" y="57" width="252.66666666666669" height="29"/>
<rect key="frame" x="0.0" y="57.000000000000007" width="335" height="26.333333333333336"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="22"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PINs help keep your profile, messages and contacts secure, so only you can access them." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Rn2-qe-htS">
<rect key="frame" x="0.0" y="111.33333333333334" width="335" height="61"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="86" id="30N-bq-9g8"/>
<constraint firstAttribute="bottom" secondItem="bxI-mu-qng" secondAttribute="bottom" id="8Qc-aK-wkM"/>
<constraint firstItem="Rn2-qe-htS" firstAttribute="centerX" secondItem="ztg-5t-ECh" secondAttribute="centerX" id="18L-xF-ADZ"/>
<constraint firstItem="Rn2-qe-htS" firstAttribute="top" secondItem="bxI-mu-qng" secondAttribute="bottom" constant="28" id="HtF-cu-6el"/>
<constraint firstItem="bxI-mu-qng" firstAttribute="leading" secondItem="ztg-5t-ECh" secondAttribute="leading" id="IMC-TT-zWD"/>
<constraint firstAttribute="bottom" secondItem="Rn2-qe-htS" secondAttribute="bottom" id="IW3-jM-53d"/>
<constraint firstAttribute="trailing" secondItem="Rn2-qe-htS" secondAttribute="trailing" id="Jda-DD-urk"/>
<constraint firstItem="UHg-qE-anw" firstAttribute="centerX" secondItem="ztg-5t-ECh" secondAttribute="centerX" id="Vhm-GS-xYs"/>
<constraint firstAttribute="trailing" secondItem="bxI-mu-qng" secondAttribute="trailing" id="Vug-jC-5c4"/>
<constraint firstItem="Rn2-qe-htS" firstAttribute="leading" secondItem="ztg-5t-ECh" secondAttribute="leading" id="kWf-33-mfM"/>
<constraint firstItem="bxI-mu-qng" firstAttribute="top" secondItem="UHg-qE-anw" secondAttribute="bottom" constant="9" id="laj-kY-eW1"/>
<constraint firstItem="bxI-mu-qng" firstAttribute="centerX" secondItem="ztg-5t-ECh" secondAttribute="centerX" id="p4o-hz-jZJ"/>
<constraint firstItem="UHg-qE-anw" firstAttribute="top" secondItem="ztg-5t-ECh" secondAttribute="top" constant="8" id="uj5-KC-7FD"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="l5x-qO-sdf">
<rect key="frame" x="2" y="153.33333333333334" width="371" height="78.666666666666657"/>
<rect key="frame" x="2" y="211" width="371" height="78.666666666666686"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" spacing="24" translatesAutoresizingMaskIntoConstraints="NO" id="xi9-P9-8WP">
<rect key="frame" x="101.66666666666669" y="0.0" width="168" height="24"/>
@ -131,7 +142,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" alignment="center" spacing="21" translatesAutoresizingMaskIntoConstraints="NO" id="W0M-eq-abZ">
<rect key="frame" x="65.666666666666686" y="299.66666666666669" width="244" height="303.00000000000006"/>
<rect key="frame" x="65.666666666666686" y="328.33333333333331" width="244" height="302.99999999999994"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" spacing="32" translatesAutoresizingMaskIntoConstraints="NO" id="Uqh-o2-7HP">
<rect key="frame" x="0.0" y="0.0" width="244" height="60"/>
@ -216,7 +227,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" spacing="32" translatesAutoresizingMaskIntoConstraints="NO" id="YeU-UN-Uo0">
<rect key="frame" x="0.0" y="161.99999999999994" width="244" height="60"/>
<rect key="frame" x="0.0" y="162.00000000000006" width="244" height="60"/>
<subviews>
<button opaque="NO" tag="7" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lnz-5u-oFb">
<rect key="frame" x="0.0" y="0.0" width="60" height="60"/>
@ -257,7 +268,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" spacing="32" translatesAutoresizingMaskIntoConstraints="NO" id="Nrp-tS-u1k">
<rect key="frame" x="0.0" y="242.99999999999994" width="244" height="60"/>
<rect key="frame" x="0.0" y="243.00000000000006" width="244" height="60"/>
<subviews>
<button opaque="NO" userInteractionEnabled="NO" tag="-99" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DEv-rc-fGB">
<rect key="frame" x="0.0" y="0.0" width="60" height="60"/>
@ -338,6 +349,7 @@
</view>
<connections>
<outlet property="digitsStackView" destination="W0M-eq-abZ" id="xnb-6w-dtC"/>
<outlet property="explanatoryLabel" destination="Rn2-qe-htS" id="8WG-b4-nhE"/>
<outlet property="forgotPinButton" destination="CRt-Fb-0Dq" id="kHp-wn-P0o"/>
<outlet property="inactiveLogoImageView" destination="8qz-Yk-9a4" id="DFZ-fF-0NC"/>
<outlet property="inactiveView" destination="1YE-D1-eHn" id="I2t-3r-WUQ"/>

View file

@ -40,6 +40,7 @@ final class EnterPinCodeViewController: UIViewController {
@IBOutlet private weak var notAllowedPinLabel: UILabel!
@IBOutlet private weak var digitsStackView: UIStackView!
@IBOutlet private weak var informationLabel: UILabel!
@IBOutlet private weak var explanatoryLabel: UILabel!
@IBOutlet private weak var forgotPinButton: UIButton!
// MARK: Private
@ -119,6 +120,7 @@ final class EnterPinCodeViewController: UIViewController {
}
self.informationLabel.textColor = theme.textPrimaryColor
self.explanatoryLabel.textColor = theme.textSecondaryColor
self.notAllowedPinLineView.backgroundColor = theme.noticeColor
self.notAllowedPinLabel.textColor = theme.noticeColor
@ -190,6 +192,10 @@ final class EnterPinCodeViewController: UIViewController {
switch viewState {
case .choosePin:
self.renderChoosePin()
case .choosePinAfterLogin:
self.renderChoosePinAfterLogin()
case .choosePinAfterRegister:
self.renderChoosePinAfterRegister()
case .notAllowedPin:
self.renderNotAllowedPin()
case .confirmPin:
@ -216,10 +222,21 @@ final class EnterPinCodeViewController: UIViewController {
self.mainStackView.isHidden = false
self.logoImageView.isHidden = true
self.informationLabel.text = VectorL10n.pinProtectionChoosePin
self.explanatoryLabel.isHidden = false
self.forgotPinButton.isHidden = true
self.notAllowedPinView.isHidden = true
}
private func renderChoosePinAfterLogin() {
renderChoosePin()
self.informationLabel.text = VectorL10n.pinProtectionChoosePinWelcomeAfterLogin + "\n" + VectorL10n.pinProtectionChoosePin
}
private func renderChoosePinAfterRegister() {
renderChoosePin()
self.informationLabel.text = VectorL10n.pinProtectionChoosePinWelcomeAfterRegister + "\n" + VectorL10n.pinProtectionChoosePin
}
private func renderNotAllowedPin() {
self.inactiveView.isHidden = true
self.mainStackView.isHidden = false
@ -257,6 +274,7 @@ final class EnterPinCodeViewController: UIViewController {
self.mainStackView.isHidden = false
self.logoImageView.isHidden = false
self.informationLabel.text = VectorL10n.pinProtectionEnterPin
self.explanatoryLabel.text = nil
self.forgotPinButton.isHidden = false
self.notAllowedPinView.isHidden = true
}
@ -265,6 +283,7 @@ final class EnterPinCodeViewController: UIViewController {
self.inactiveView.isHidden = true
self.mainStackView.isHidden = false
self.notAllowedPinView.isHidden = true
self.explanatoryLabel.text = nil
self.placeholderStackView.vc_shake()
}
@ -299,6 +318,7 @@ final class EnterPinCodeViewController: UIViewController {
self.mainStackView.isHidden = false
self.logoImageView.isHidden = true
self.informationLabel.text = VectorL10n.pinProtectionConfirmPinToDisable
self.explanatoryLabel.text = nil
self.forgotPinButton.isHidden = true
self.notAllowedPinView.isHidden = true
}
@ -308,6 +328,7 @@ final class EnterPinCodeViewController: UIViewController {
self.inactiveView.isHidden = false
self.mainStackView.isHidden = true
self.notAllowedPinView.isHidden = true
self.explanatoryLabel.text = nil
}
private func renderPlaceholdersCount(_ count: Int, error: Bool = false) {

View file

@ -21,6 +21,8 @@ import Foundation
/// EnterPinCodeViewController view state
enum EnterPinCodeViewState {
case choosePin // creating pin for the first time, enter for first
case choosePinAfterLogin // creating pin for the first time, after login, enter for first
case choosePinAfterRegister // creating pin for the first time, after registration, enter for first
case notAllowedPin // creating pin for the first time, provided pin is not allowed
case confirmPin // creating pin for the first time, confirm
case pinsDontMatch // pins don't match