Introduce inactive state

This commit is contained in:
ismailgulek
2020-09-07 18:09:47 +03:00
parent 6bd880c9f8
commit 87c6b50f49
4 changed files with 51 additions and 1 deletions
@@ -16,6 +16,23 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1YE-D1-eHn">
<rect key="frame" x="0.0" y="64" width="375" height="694"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launch_screen_logo" translatesAutoresizingMaskIntoConstraints="NO" id="8qz-Yk-9a4">
<rect key="frame" x="137.66666666666666" y="277" width="100" height="100"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="Ux9-pH-SW9"/>
<constraint firstAttribute="height" constant="100" id="o3K-YH-5tn"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="8qz-Yk-9a4" firstAttribute="centerY" secondItem="1YE-D1-eHn" secondAttribute="centerY" constant="-20" id="IKY-me-86i"/>
<constraint firstItem="8qz-Yk-9a4" firstAttribute="centerX" secondItem="1YE-D1-eHn" secondAttribute="centerX" id="cPb-3H-3yK"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="DMT-DS-IA8">
<rect key="frame" x="0.0" y="52" width="375" height="718"/>
<subviews>
@@ -274,18 +291,25 @@
</subviews>
<color key="backgroundColor" red="0.94509803921568625" green="0.96078431372549022" blue="0.97254901960784312" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="bFg-jh-JZB" firstAttribute="bottom" secondItem="1YE-D1-eHn" secondAttribute="bottom" constant="20" id="5mk-pT-EGS"/>
<constraint firstItem="1YE-D1-eHn" firstAttribute="top" secondItem="bFg-jh-JZB" secondAttribute="top" constant="20" id="Jzf-aA-rX7"/>
<constraint firstItem="DMT-DS-IA8" firstAttribute="top" secondItem="bFg-jh-JZB" secondAttribute="top" constant="8" id="Mlg-kp-E06"/>
<constraint firstItem="bFg-jh-JZB" firstAttribute="trailing" secondItem="DMT-DS-IA8" secondAttribute="trailing" id="Vwu-g7-vNh"/>
<constraint firstItem="bFg-jh-JZB" firstAttribute="trailing" secondItem="1YE-D1-eHn" secondAttribute="trailing" id="cxG-Xd-t0n"/>
<constraint firstItem="bFg-jh-JZB" firstAttribute="bottom" secondItem="DMT-DS-IA8" secondAttribute="bottom" constant="8" id="gPa-B5-LIs"/>
<constraint firstItem="DMT-DS-IA8" firstAttribute="leading" secondItem="bFg-jh-JZB" secondAttribute="leading" id="kA7-cw-VK1"/>
<constraint firstItem="1YE-D1-eHn" firstAttribute="leading" secondItem="bFg-jh-JZB" secondAttribute="leading" id="qOT-0t-zQs"/>
</constraints>
<viewLayoutGuide key="safeArea" id="bFg-jh-JZB"/>
</view>
<connections>
<outlet property="digitsStackView" destination="W0M-eq-abZ" id="xnb-6w-dtC"/>
<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"/>
<outlet property="informationLabel" destination="bxI-mu-qng" id="pbX-aZ-inC"/>
<outlet property="logoImageView" destination="UHg-qE-anw" id="8C0-pd-i3b"/>
<outlet property="mainStackView" destination="DMT-DS-IA8" id="qYw-KO-M4k"/>
<outlet property="placeholderStackView" destination="xi9-P9-8WP" id="ynl-7M-Rpb"/>
</connections>
</viewController>
@@ -297,6 +321,7 @@
<resources>
<image name="back_icon" width="14" height="23"/>
<image name="callkit_icon" width="40" height="40"/>
<image name="launch_screen_logo" width="240" height="240"/>
<image name="selection_untick" width="22" height="22"/>
</resources>
</document>
@@ -30,6 +30,9 @@ final class EnterPinCodeViewController: UIViewController {
// MARK: Outlets
@IBOutlet private weak var mainStackView: UIStackView!
@IBOutlet private weak var inactiveView: UIView!
@IBOutlet private weak var inactiveLogoImageView: UIImageView!
@IBOutlet private weak var logoImageView: UIImageView!
@IBOutlet private weak var placeholderStackView: UIStackView!
@IBOutlet private weak var digitsStackView: UIStackView!
@@ -113,6 +116,7 @@ final class EnterPinCodeViewController: UIViewController {
}
self.informationLabel.textColor = theme.textPrimaryColor
self.inactiveLogoImageView.tintColor = theme.tintColor
updateThemesOfAllImages(in: placeholderStackView, with: theme)
updateThemesOfAllButtons(in: digitsStackView, with: theme)
@@ -194,16 +198,22 @@ final class EnterPinCodeViewController: UIViewController {
self.renderForgotPin()
case .confirmPinToDisable:
self.renderConfirmPinToDisable()
case .inactive:
self.renderInactive()
}
}
private func renderChoosePin() {
self.inactiveView.isHidden = true
self.mainStackView.isHidden = false
self.logoImageView.isHidden = true
self.informationLabel.text = VectorL10n.pinProtectionChoosePin
self.forgotPinButton.isHidden = true
}
private func renderConfirmPin() {
self.inactiveView.isHidden = true
self.mainStackView.isHidden = false
self.informationLabel.text = VectorL10n.pinProtectionConfirmPin
// reset placeholders
@@ -222,12 +232,16 @@ final class EnterPinCodeViewController: UIViewController {
private func renderUnlockByPin() {
hideCancelButton()
self.inactiveView.isHidden = true
self.mainStackView.isHidden = false
self.logoImageView.isHidden = false
self.informationLabel.text = VectorL10n.pinProtectionEnterPin
self.forgotPinButton.isHidden = false
}
private func renderWrongPin() {
self.inactiveView.isHidden = true
self.mainStackView.isHidden = false
self.placeholderStackView.vc_shake()
}
@@ -258,11 +272,19 @@ final class EnterPinCodeViewController: UIViewController {
}
private func renderConfirmPinToDisable() {
self.inactiveView.isHidden = true
self.mainStackView.isHidden = false
self.logoImageView.isHidden = true
self.informationLabel.text = VectorL10n.pinProtectionConfirmPinToDisable
self.forgotPinButton.isHidden = true
}
private func renderInactive() {
self.hideCancelButton()
self.inactiveView.isHidden = false
self.mainStackView.isHidden = true
}
private func renderPlaceholdersCount(_ count: Int) {
UIView.animate(withDuration: 0.3) {
for case let imageView as UIImageView in self.placeholderStackView.arrangedSubviews {
@@ -148,6 +148,8 @@ final class EnterPinCodeViewModel: EnterPinCodeViewModelType {
update(viewState: .unlock)
case .confirmPinToDeactivate:
update(viewState: .confirmPinToDisable)
case .inactive:
update(viewState: .inactive)
default:
break
}
@@ -23,9 +23,10 @@ enum EnterPinCodeViewState {
case choosePin // creating pin for the first time, enter for first
case confirmPin // creating pin for the first time, confirm
case pinsDontMatch // pins don't match
case unlock // after pin has been set, enter pin to unlock
case unlock // after pin has been set, enter pin to unlock
case wrongPin // after pin has been set, pin entered wrongly
case wrongPinTooManyTimes // after pin has been set, pin entered wrongly too many times
case forgotPin // after pin has been set, user tapped forgot pin
case confirmPinToDisable // after pin has been set, confirm pin to disable pin
case inactive // inactive state, only used when app is not active
}