Skip to content

Commit 939b5b9

Browse files
committed
Refactored getting to the passkey authentication to fix the ui tests
1 parent d5ab6bf commit 939b5b9

5 files changed

+89
-71
lines changed

Simplenote/Classes/SPAuthViewController.swift

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,6 @@ class SPAuthViewController: UIViewController {
7676
}
7777
}
7878

79-
/// # Passkey Button Action
80-
///
81-
@IBOutlet weak var passkeySigninButton: SPSquaredButton! {
82-
didSet {
83-
passkeySigninButton.isHidden = !mode.isLogin
84-
passkeySigninButton.setTitle(AuthenticationStrings.passkeyActionButton, for: .normal)
85-
passkeySigninButton.setTitleColor(.white, for: .normal)
86-
passkeySigninButton.addTarget(self, action: #selector(passkeyAuthAction), for: .touchUpInside)
87-
}
88-
}
89-
9079
/// # Primary Action Spinner!
9180
///
9281
@IBOutlet private var primaryActionSpinner: UIActivityIndicatorView! {
@@ -114,14 +103,6 @@ class SPAuthViewController: UIViewController {
114103
}
115104
}
116105

117-
/// # Passkey Action Spinner
118-
///
119-
@IBOutlet weak var passkeyActivitySpinner: UIActivityIndicatorView! {
120-
didSet {
121-
passkeyActivitySpinner.style = .medium
122-
}
123-
}
124-
125106
/// # Reveal Password Button
126107
///
127108
private lazy var revealPasswordButton: UIButton = {
@@ -261,7 +242,6 @@ private extension SPAuthViewController {
261242

262243
func ensureStylesMatchValidationState() {
263244
primaryActionButton.backgroundColor = isInputValid ? .simplenoteBlue50Color : .simplenoteGray20Color
264-
passkeySigninButton.backgroundColor = isInputValid ? .simplenoteBlue50Color : .simplenoteGray20Color
265245
}
266246

267247
@objc
@@ -309,11 +289,6 @@ private extension SPAuthViewController {
309289
return
310290
}
311291

312-
if passwordInputView.isHidden == true && passwordInputView.text?.isEmpty == true {
313-
passwordInputView.isHidden = false
314-
return
315-
}
316-
317292
if mustUpgradePasswordStrength() {
318293
performCredentialsValidation()
319294
return
@@ -685,7 +660,7 @@ extension AuthenticationMode {
685660
secondaryActionSelector: #selector(SPAuthViewController.presentPasswordReset),
686661
secondaryActionText: AuthenticationStrings.loginSecondaryAction,
687662
secondaryActionAttributedText: nil,
688-
isPasswordHidden: true,
663+
isPasswordHidden: false,
689664
isLogin: true)
690665
}
691666

@@ -702,6 +677,18 @@ extension AuthenticationMode {
702677
isPasswordHidden: true,
703678
isLogin: false)
704679
}
680+
681+
static var loginWithPasskeys: AuthenticationMode {
682+
return .init(title: AuthenticationStrings.loginTitle,
683+
validationStyle: .legacy,
684+
primaryActionSelector: #selector(SPAuthViewController.passkeyAuthAction),
685+
primaryActionText: AuthenticationStrings.passkeyActionButton,
686+
secondaryActionSelector: #selector(SPAuthViewController.presentPasswordReset),
687+
secondaryActionText: AuthenticationStrings.loginSecondaryAction,
688+
secondaryActionAttributedText: nil,
689+
isPasswordHidden: true,
690+
isLogin: true)
691+
}
705692
}
706693

707694
// MARK: - Authentication Strings

Simplenote/Classes/SPAuthViewController.xib

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
<connections>
1414
<outlet property="emailInputView" destination="hW6-K1-OyV" id="TyC-Uh-Kaf"/>
1515
<outlet property="emailWarningLabel" destination="n7T-Gj-plH" id="STx-wz-jKg"/>
16-
<outlet property="passkeyActivitySpinner" destination="1r4-a8-hNr" id="1yP-oN-4Fg"/>
17-
<outlet property="passkeySigninButton" destination="h9W-v8-WKk" id="9pc-1i-vUF"/>
1816
<outlet property="passwordInputView" destination="pdF-nK-gXE" id="18P-SU-c90"/>
1917
<outlet property="passwordWarningLabel" destination="UyC-If-pXj" id="D2M-PR-Tph"/>
2018
<outlet property="primaryActionButton" destination="q3p-Ji-dOm" id="l1t-x0-zva"/>
@@ -31,7 +29,7 @@
3129
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3230
<subviews>
3331
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="CJS-5O-pxK">
34-
<rect key="frame" x="332" y="60" width="360" height="304"/>
32+
<rect key="frame" x="332" y="60" width="360" height="252"/>
3533
<subviews>
3634
<view contentMode="center" translatesAutoresizingMaskIntoConstraints="NO" id="hW6-K1-OyV" customClass="SPTextInputView" customModule="Simplenote" customModuleProvider="target">
3735
<rect key="frame" x="0.0" y="0.0" width="360" height="44"/>
@@ -88,31 +86,8 @@
8886
<constraint firstItem="o3M-2A-urw" firstAttribute="centerY" secondItem="CGr-O3-MBQ" secondAttribute="centerY" id="wvA-qg-zbY"/>
8987
</constraints>
9088
</view>
91-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5h1-31-jFW" userLabel="Passkey Button">
92-
<rect key="frame" x="0.0" y="208" width="360" height="44"/>
93-
<subviews>
94-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="h9W-v8-WKk" userLabel="Passkey" customClass="SPSquaredButton" customModule="Simplenote" customModuleProvider="target">
95-
<rect key="frame" x="0.0" y="0.0" width="360" height="44"/>
96-
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
97-
<state key="normal" title="#Passkey#"/>
98-
</button>
99-
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="1r4-a8-hNr">
100-
<rect key="frame" x="322" y="12" width="20" height="20"/>
101-
</activityIndicatorView>
102-
</subviews>
103-
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
104-
<constraints>
105-
<constraint firstItem="h9W-v8-WKk" firstAttribute="leading" secondItem="5h1-31-jFW" secondAttribute="leading" id="11w-Lz-NjB"/>
106-
<constraint firstAttribute="bottom" secondItem="h9W-v8-WKk" secondAttribute="bottom" id="JvA-Ah-SyT"/>
107-
<constraint firstItem="h9W-v8-WKk" firstAttribute="top" secondItem="5h1-31-jFW" secondAttribute="top" id="LcI-bp-W2p"/>
108-
<constraint firstItem="1r4-a8-hNr" firstAttribute="centerY" secondItem="5h1-31-jFW" secondAttribute="centerY" id="QHO-xZ-PfH"/>
109-
<constraint firstAttribute="trailing" secondItem="h9W-v8-WKk" secondAttribute="trailing" id="cNB-id-tDI"/>
110-
<constraint firstAttribute="trailing" secondItem="1r4-a8-hNr" secondAttribute="trailing" constant="18" id="ewS-87-pUI"/>
111-
<constraint firstAttribute="height" constant="44" id="sXy-jP-JIm"/>
112-
</constraints>
113-
</view>
11489
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PfS-vU-7i3">
115-
<rect key="frame" x="0.0" y="260" width="360" height="44"/>
90+
<rect key="frame" x="0.0" y="208" width="360" height="44"/>
11691
<constraints>
11792
<constraint firstAttribute="height" constant="44" id="u8s-d9-Em4"/>
11893
</constraints>
@@ -123,10 +98,8 @@
12398
<constraints>
12499
<constraint firstAttribute="trailing" secondItem="PfS-vU-7i3" secondAttribute="trailing" id="0QL-Iw-KLz"/>
125100
<constraint firstItem="PfS-vU-7i3" firstAttribute="leading" secondItem="CJS-5O-pxK" secondAttribute="leading" id="314-fc-3eX"/>
126-
<constraint firstItem="5h1-31-jFW" firstAttribute="leading" secondItem="CJS-5O-pxK" secondAttribute="leading" id="36P-F4-cGU"/>
127101
<constraint firstAttribute="trailing" secondItem="pdF-nK-gXE" secondAttribute="trailing" id="51g-0D-Oyv"/>
128102
<constraint firstItem="CGr-O3-MBQ" firstAttribute="leading" secondItem="CJS-5O-pxK" secondAttribute="leading" id="BIX-Fy-gqY"/>
129-
<constraint firstAttribute="trailing" secondItem="5h1-31-jFW" secondAttribute="trailing" id="N0i-ud-dYk"/>
130103
<constraint firstAttribute="trailing" secondItem="hW6-K1-OyV" secondAttribute="trailing" id="RSC-Vk-xbB"/>
131104
<constraint firstItem="hW6-K1-OyV" firstAttribute="leading" secondItem="CJS-5O-pxK" secondAttribute="leading" id="UoC-hu-yxe"/>
132105
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="360" id="nLp-JP-Ott"/>
@@ -150,9 +123,6 @@
150123
<designable name="UyC-If-pXj">
151124
<size key="intrinsicContentSize" width="132" height="18"/>
152125
</designable>
153-
<designable name="h9W-v8-WKk">
154-
<size key="intrinsicContentSize" width="87" height="33"/>
155-
</designable>
156126
<designable name="n7T-Gj-plH">
157127
<size key="intrinsicContentSize" width="102.5" height="18"/>
158128
</designable>
@@ -165,10 +135,10 @@
165135
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
166136
</systemColor>
167137
<systemColor name="systemPinkColor">
168-
<color red="1" green="0.17647058823529413" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
138+
<color red="1" green="0.1764705882" blue="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
169139
</systemColor>
170140
<systemColor name="systemRedColor">
171-
<color red="1" green="0.23137254901960785" blue="0.18823529411764706" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
141+
<color red="1" green="0.23137254900000001" blue="0.18823529410000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
172142
</systemColor>
173143
</resources>
174144
</document>

Simplenote/Classes/SPOnboardingViewController.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,18 @@ private extension SPOnboardingViewController {
151151
let sheetController = SPSheetController()
152152

153153
sheetController.setTitleForButton0(title: OnboardingStrings.loginWithEmailText)
154-
sheetController.setTitleForButton1(title: OnboardingStrings.loginWithWpcomText)
154+
sheetController.setTitleForButton1(title: OnboardingStrings.loginWithPasskeysText)
155+
sheetController.setTitleForButton2(title: OnboardingStrings.loginWithWpcomText)
155156

156157
sheetController.onClickButton0 = { [weak self] in
157158
self?.presentAuthenticationInterface(mode: .login)
158159
}
159160

160161
sheetController.onClickButton1 = { [weak self] in
162+
self?.presentAuthenticationInterface(mode: .loginWithPasskeys)
163+
}
164+
165+
sheetController.onClickButton2 = { [weak self] in
161166
self?.presentWordpressSSO()
162167
}
163168

@@ -224,6 +229,7 @@ private struct OnboardingStrings {
224229
static let headerText = NSLocalizedString("The simplest way to keep notes.", comment: "Onboarding Header Text")
225230
static let loginWithEmailText = NSLocalizedString("Log in with email", comment: "Presents the regular Email signin flow")
226231
static let loginWithWpcomText = NSLocalizedString("Log in with WordPress.com", comment: "Allows the user to SignIn using their WPCOM Account")
232+
static let loginWithPasskeysText = NSLocalizedString("Log in with Passkeys", comment: "Allows the user to SignIn using Passkeys")
227233
}
228234

229235
private struct SignInError {

Simplenote/Classes/SPSheetController.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ class SPSheetController: UIViewController {
2929
///
3030
@IBOutlet private var button1: SPSquaredButton! {
3131
didSet {
32-
button1.backgroundColor = .simplenoteWPBlue50Color
32+
button1.backgroundColor = .simplenoteBlue50Color
33+
}
34+
}
35+
36+
@IBOutlet weak var button2: SPSquaredButton! {
37+
didSet {
38+
button2.backgroundColor = .simplenoteWPBlue50Color
3339
}
3440
}
3541

@@ -41,6 +47,10 @@ class SPSheetController: UIViewController {
4147
///
4248
var onClickButton1: (() -> Void)?
4349

50+
/// Closure to be executed whenever button2 is clicked
51+
///
52+
var onClickButton2: (() -> Void)?
53+
4454
/// Designated Initializer
4555
///
4656
init() {
@@ -86,6 +96,11 @@ class SPSheetController: UIViewController {
8696
loadViewIfNeeded()
8797
button1.setTitle(title, for: .normal)
8898
}
99+
100+
func setTitleForButton2(title: String) {
101+
loadViewIfNeeded()
102+
button2.setTitle(title, for: .normal)
103+
}
89104
}
90105

91106
// MARK: - Private Methods
@@ -125,6 +140,11 @@ private extension SPSheetController {
125140
onClickButton1?()
126141
}
127142

143+
@IBAction func button2WasPressed() {
144+
dismissWithAnimation()
145+
onClickButton2?()
146+
}
147+
128148
@IBAction func backgroundWasPressed() {
129149
dismissWithAnimation()
130150
}

0 commit comments

Comments
 (0)