Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 2d6fd81

Browse files
committed
Move text button style configuration from UIButton extension to WPStyleGuide+Login. Update existing usage and configure the "Enter your password instead." text button in LoginLinkRequestViewController.
1 parent fc3d5de commit 2d6fd81

File tree

9 files changed

+31
-18
lines changed

9 files changed

+31
-18
lines changed

WordPressAuthenticator.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
0239624F2398E43C0096F34C /* UIButton+Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0239624E2398E43C0096F34C /* UIButton+Styles.swift */; };
1110
1A21EE9822832BC300C940C6 /* WordPressComOAuthClientFacade+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */; };
1211
1A4095182271AEFC009AA86D /* WPAuthenticator-Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */; settings = {ATTRIBUTES = (Private, ); }; };
1312
7A7A9B9CD2D81959F9AB9AF6 /* Pods_WordPressAuthenticator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C736FF243DE333FCAB1C2614 /* Pods_WordPressAuthenticator.framework */; };
@@ -143,7 +142,6 @@
143142
/* End PBXCopyFilesBuildPhase section */
144143

145144
/* Begin PBXFileReference section */
146-
0239624E2398E43C0096F34C /* UIButton+Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Styles.swift"; sourceTree = "<group>"; };
147145
1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "WordPressComOAuthClientFacade+Swift.swift"; sourceTree = "<group>"; };
148146
1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPAuthenticator-Swift.h"; sourceTree = "<group>"; };
149147
276354F054C34AD36CA32AB6 /* Pods-WordPressAuthenticator.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.release-alpha.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.release-alpha.xcconfig"; sourceTree = "<group>"; };
@@ -467,7 +465,6 @@
467465
B56090EE208A527000399AE4 /* String+Underline.swift */,
468466
B56090EC208A527000399AE4 /* WPStyleGuide+Login.swift */,
469467
B5CDBED320B4714500BC1EF2 /* UIImage+Assets.swift */,
470-
0239624E2398E43C0096F34C /* UIButton+Styles.swift */,
471468
);
472469
path = Extensions;
473470
sourceTree = "<group>";
@@ -902,7 +899,6 @@
902899
B56090EB208A51D000399AE4 /* LoginFields.swift in Sources */,
903900
B56090FB208A533200399AE4 /* WordPressSupportSourceTag.swift in Sources */,
904901
B56090C6208A4F5400399AE4 /* NUXButtonViewController.swift in Sources */,
905-
0239624F2398E43C0096F34C /* UIButton+Styles.swift in Sources */,
906902
B5609121208A555E00399AE4 /* SignupEmailViewController.swift in Sources */,
907903
B5609107208A54F800399AE4 /* WordPressComBlogService.swift in Sources */,
908904
B560910D208A54F800399AE4 /* WordPressXMLRPCAPIFacade.m in Sources */,

WordPressAuthenticator/Extensions/UIButton+Styles.swift

Lines changed: 0 additions & 9 deletions
This file was deleted.

WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ extension WPStyleGuide {
7171
onePasswordButton.addTarget(target, action: selector, for: .touchUpInside)
7272
}
7373

74+
/// Configures a plain text button with default styles.
75+
///
76+
class func configureTextButton(_ button: UIButton) {
77+
button.setTitleColor(WordPressAuthenticator.shared.style.textButtonColor, for: .normal)
78+
button.setTitleColor(WordPressAuthenticator.shared.style.textButtonHighlightColor, for: .highlighted)
79+
}
80+
7481
///
7582
///
7683
class func colorForErrorView(_ opaque: Bool) -> UIColor {

WordPressAuthenticator/Signin/Login2FAViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class Login2FAViewController: LoginViewController, NUXKeyboardResponder, UITextF
7878
private func styleSendCodeButton() {
7979
sendCodeButton.titleLabel?.adjustsFontForContentSizeCategory = true
8080
sendCodeButton.titleLabel?.adjustsFontSizeToFitWidth = true
81+
WPStyleGuide.configureTextButton(sendCodeButton)
8182
}
8283

8384
// MARK: Configuration Methods
@@ -97,7 +98,6 @@ class Login2FAViewController: LoginViewController, NUXKeyboardResponder, UITextF
9798
sendCodeButton.setTitle(NSLocalizedString("Text me a code instead", comment: "Button title"),
9899
for: .normal)
99100
sendCodeButton.titleLabel?.numberOfLines = 0
100-
sendCodeButton.applyTextButtonStyle()
101101
}
102102

103103
/// configures the text fields

WordPressAuthenticator/Signin/LoginLinkRequestViewController.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class LoginLinkRequestViewController: LoginViewController {
2525
super.viewDidLoad()
2626

2727
localizeControls()
28+
configureUsePasswordButton()
2829

2930
let email = loginFields.username
3031
if !email.isValidEmail() {
@@ -78,6 +79,13 @@ class LoginLinkRequestViewController: LoginViewController {
7879
sendLinkButton?.isEnabled = !animating
7980
}
8081

82+
private func configureUsePasswordButton() {
83+
guard let usePasswordButton = usePasswordButton else {
84+
return
85+
}
86+
WPStyleGuide.configureTextButton(usePasswordButton)
87+
}
88+
8189

8290
// MARK: - Instance Methods
8391

WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder {
8787
forgotPasswordButton.setTitle(forgotPasswordTitle, for: .normal)
8888
forgotPasswordButton.setTitle(forgotPasswordTitle, for: .highlighted)
8989
forgotPasswordButton.titleLabel?.numberOfLines = 0
90-
forgotPasswordButton.applyTextButtonStyle()
9190
}
9291

9392

@@ -114,6 +113,7 @@ class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder {
114113
///
115114
@objc func configureForgotPasswordButton() {
116115
forgotPasswordButton.isEnabled = enableSubmit(animating: false)
116+
WPStyleGuide.configureTextButton(forgotPasswordButton)
117117
}
118118

119119

WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder
4747
loginFields.meta.userIsDotCom = false
4848

4949
configureTextFields()
50+
configureSiteAddressHelpButton()
5051
configureSubmitButton(animating: false)
5152
configureViewForEditingIfNeeded()
5253

@@ -87,7 +88,6 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder
8788
siteAddressHelpButton.setTitle(siteAddressHelpTitle, for: .normal)
8889
siteAddressHelpButton.setTitle(siteAddressHelpTitle, for: .highlighted)
8990
siteAddressHelpButton.titleLabel?.numberOfLines = 0
90-
siteAddressHelpButton.applyTextButtonStyle()
9191
}
9292

9393

@@ -133,6 +133,10 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder
133133
}
134134
}
135135

136+
private func configureSiteAddressHelpButton() {
137+
WPStyleGuide.configureTextButton(siteAddressHelpButton)
138+
}
139+
136140

137141
// MARK: - Instance Methods
138142

WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ class LoginUsernamePasswordViewController: LoginViewController, NUXKeyboardRespo
8787
forgotPasswordButton.setTitle(forgotPasswordTitle, for: .normal)
8888
forgotPasswordButton.setTitle(forgotPasswordTitle, for: .highlighted)
8989
forgotPasswordButton.titleLabel?.numberOfLines = 0
90-
forgotPasswordButton.applyTextButtonStyle()
9190
}
9291

9392

@@ -114,6 +113,7 @@ class LoginUsernamePasswordViewController: LoginViewController, NUXKeyboardRespo
114113
///
115114
@objc func configureForgotPasswordButton() {
116115
forgotPasswordButton.isEnabled = enableSubmit(animating: false)
116+
WPStyleGuide.configureTextButton(forgotPasswordButton)
117117
}
118118

119119

WordPressAuthenticator/Signin/LoginWPComViewController.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class LoginWPComViewController: LoginViewController, NUXKeyboardResponder {
4545

4646
configureTextFields()
4747
configureEmailIcon()
48+
configureForgotPasswordButton()
4849
configureSubmitButton(animating: false)
4950
configureViewForEditingIfNeeded()
5051
}
@@ -128,6 +129,13 @@ class LoginWPComViewController: LoginViewController, NUXKeyboardResponder {
128129
emailIcon?.image = image.imageWithTintColor(WordPressAuthenticator.shared.style.subheadlineColor)
129130
}
130131

132+
private func configureForgotPasswordButton() {
133+
guard let forgotPasswordButton = forgotPasswordButton else {
134+
return
135+
}
136+
WPStyleGuide.configureTextButton(forgotPasswordButton)
137+
}
138+
131139
@objc func localizeControls() {
132140

133141
instructionLabel?.text = {
@@ -154,7 +162,6 @@ class LoginWPComViewController: LoginViewController, NUXKeyboardResponder {
154162
forgotPasswordButton?.setTitle(forgotPasswordTitle, for: .normal)
155163
forgotPasswordButton?.setTitle(forgotPasswordTitle, for: .highlighted)
156164
forgotPasswordButton?.titleLabel?.numberOfLines = 0
157-
forgotPasswordButton?.applyTextButtonStyle()
158165
}
159166

160167

0 commit comments

Comments
 (0)