From 1e88f138d318075b8b8b7d0c03a2aeb7f583829f Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Thu, 5 Dec 2019 15:54:46 +0800 Subject: [PATCH 1/4] Add `UIButton` extension to apply default styles to a plain text button. --- WordPressAuthenticator.xcodeproj/project.pbxproj | 4 ++++ WordPressAuthenticator/Extensions/UIButton+Styles.swift | 9 +++++++++ .../Signin/Login2FAViewController.swift | 1 + .../Signin/LoginSelfHostedViewController.swift | 1 + .../Signin/LoginSiteAddressViewController.swift | 1 + .../Signin/LoginUsernamePasswordViewController.swift | 1 + .../Signin/LoginWPComViewController.swift | 1 + 7 files changed, 18 insertions(+) create mode 100644 WordPressAuthenticator/Extensions/UIButton+Styles.swift diff --git a/WordPressAuthenticator.xcodeproj/project.pbxproj b/WordPressAuthenticator.xcodeproj/project.pbxproj index e0f6c018a..295574d28 100644 --- a/WordPressAuthenticator.xcodeproj/project.pbxproj +++ b/WordPressAuthenticator.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 0239624F2398E43C0096F34C /* UIButton+Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0239624E2398E43C0096F34C /* UIButton+Styles.swift */; }; 1A21EE9822832BC300C940C6 /* WordPressComOAuthClientFacade+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */; }; 1A4095182271AEFC009AA86D /* WPAuthenticator-Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */; settings = {ATTRIBUTES = (Private, ); }; }; 7A7A9B9CD2D81959F9AB9AF6 /* Pods_WordPressAuthenticator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C736FF243DE333FCAB1C2614 /* Pods_WordPressAuthenticator.framework */; }; @@ -142,6 +143,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0239624E2398E43C0096F34C /* UIButton+Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Styles.swift"; sourceTree = ""; }; 1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "WordPressComOAuthClientFacade+Swift.swift"; sourceTree = ""; }; 1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPAuthenticator-Swift.h"; sourceTree = ""; }; 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 = ""; }; @@ -465,6 +467,7 @@ B56090EE208A527000399AE4 /* String+Underline.swift */, B56090EC208A527000399AE4 /* WPStyleGuide+Login.swift */, B5CDBED320B4714500BC1EF2 /* UIImage+Assets.swift */, + 0239624E2398E43C0096F34C /* UIButton+Styles.swift */, ); path = Extensions; sourceTree = ""; @@ -899,6 +902,7 @@ B56090EB208A51D000399AE4 /* LoginFields.swift in Sources */, B56090FB208A533200399AE4 /* WordPressSupportSourceTag.swift in Sources */, B56090C6208A4F5400399AE4 /* NUXButtonViewController.swift in Sources */, + 0239624F2398E43C0096F34C /* UIButton+Styles.swift in Sources */, B5609121208A555E00399AE4 /* SignupEmailViewController.swift in Sources */, B5609107208A54F800399AE4 /* WordPressComBlogService.swift in Sources */, B560910D208A54F800399AE4 /* WordPressXMLRPCAPIFacade.m in Sources */, diff --git a/WordPressAuthenticator/Extensions/UIButton+Styles.swift b/WordPressAuthenticator/Extensions/UIButton+Styles.swift new file mode 100644 index 000000000..11140c1e8 --- /dev/null +++ b/WordPressAuthenticator/Extensions/UIButton+Styles.swift @@ -0,0 +1,9 @@ +import UIKit + +extension UIButton { + /// Applies default styles to a plain text button. + func applyTextButtonStyle() { + setTitleColor(WordPressAuthenticator.shared.style.textButtonColor, for: .normal) + setTitleColor(WordPressAuthenticator.shared.style.textButtonHighlightColor, for: .highlighted) + } +} diff --git a/WordPressAuthenticator/Signin/Login2FAViewController.swift b/WordPressAuthenticator/Signin/Login2FAViewController.swift index 9f0a840b8..1bb14ba79 100644 --- a/WordPressAuthenticator/Signin/Login2FAViewController.swift +++ b/WordPressAuthenticator/Signin/Login2FAViewController.swift @@ -97,6 +97,7 @@ class Login2FAViewController: LoginViewController, NUXKeyboardResponder, UITextF sendCodeButton.setTitle(NSLocalizedString("Text me a code instead", comment: "Button title"), for: .normal) sendCodeButton.titleLabel?.numberOfLines = 0 + sendCodeButton.applyTextButtonStyle() } /// configures the text fields diff --git a/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift b/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift index 292c0fbb4..a3f4f09cb 100644 --- a/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift +++ b/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift @@ -87,6 +87,7 @@ class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder { forgotPasswordButton.setTitle(forgotPasswordTitle, for: .normal) forgotPasswordButton.setTitle(forgotPasswordTitle, for: .highlighted) forgotPasswordButton.titleLabel?.numberOfLines = 0 + forgotPasswordButton.applyTextButtonStyle() } diff --git a/WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift b/WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift index b878083c7..c6b7fbaf8 100644 --- a/WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift +++ b/WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift @@ -87,6 +87,7 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder siteAddressHelpButton.setTitle(siteAddressHelpTitle, for: .normal) siteAddressHelpButton.setTitle(siteAddressHelpTitle, for: .highlighted) siteAddressHelpButton.titleLabel?.numberOfLines = 0 + siteAddressHelpButton.applyTextButtonStyle() } diff --git a/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift b/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift index ae700c767..1c196d7bc 100644 --- a/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift +++ b/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift @@ -87,6 +87,7 @@ class LoginUsernamePasswordViewController: LoginViewController, NUXKeyboardRespo forgotPasswordButton.setTitle(forgotPasswordTitle, for: .normal) forgotPasswordButton.setTitle(forgotPasswordTitle, for: .highlighted) forgotPasswordButton.titleLabel?.numberOfLines = 0 + forgotPasswordButton.applyTextButtonStyle() } diff --git a/WordPressAuthenticator/Signin/LoginWPComViewController.swift b/WordPressAuthenticator/Signin/LoginWPComViewController.swift index 9add6ab27..8ae351fd6 100644 --- a/WordPressAuthenticator/Signin/LoginWPComViewController.swift +++ b/WordPressAuthenticator/Signin/LoginWPComViewController.swift @@ -154,6 +154,7 @@ class LoginWPComViewController: LoginViewController, NUXKeyboardResponder { forgotPasswordButton?.setTitle(forgotPasswordTitle, for: .normal) forgotPasswordButton?.setTitle(forgotPasswordTitle, for: .highlighted) forgotPasswordButton?.titleLabel?.numberOfLines = 0 + forgotPasswordButton?.applyTextButtonStyle() } From 781f97fdf526df71098de72d99a405213fe4a6bd Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Thu, 5 Dec 2019 15:55:19 +0800 Subject: [PATCH 2/4] Configure alternative label in `viewWillAppear` in `LoginEmailViewController`. --- WordPressAuthenticator/Signin/LoginEmailViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPressAuthenticator/Signin/LoginEmailViewController.swift b/WordPressAuthenticator/Signin/LoginEmailViewController.swift index 5cf2ef07a..d0619b71b 100644 --- a/WordPressAuthenticator/Signin/LoginEmailViewController.swift +++ b/WordPressAuthenticator/Signin/LoginEmailViewController.swift @@ -71,6 +71,7 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder { loginFields.meta.userIsDotCom = true configureEmailField() + configureAlternativeLabel() configureSubmitButton() configureViewForEditingIfNeeded() configureForWPComOnlyIfNeeded() From fc3d5debc1d17ce1b6da0fb691dead0ca2925278 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Thu, 5 Dec 2019 15:58:20 +0800 Subject: [PATCH 3/4] Bump pod version. --- WordPressAuthenticator.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressAuthenticator.podspec b/WordPressAuthenticator.podspec index 2777d5b21..d5a7c81c8 100644 --- a/WordPressAuthenticator.podspec +++ b/WordPressAuthenticator.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressAuthenticator" - s.version = "1.10.4" + s.version = "1.10.5-beta.1" s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps." s.description = <<-DESC From 2d6fd81ce79e2b6e21754e89004bf1c84d10de53 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Thu, 5 Dec 2019 21:57:52 +0800 Subject: [PATCH 4/4] 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`. --- WordPressAuthenticator.xcodeproj/project.pbxproj | 4 ---- WordPressAuthenticator/Extensions/UIButton+Styles.swift | 9 --------- .../Extensions/WPStyleGuide+Login.swift | 7 +++++++ .../Signin/Login2FAViewController.swift | 2 +- .../Signin/LoginLinkRequestViewController.swift | 8 ++++++++ .../Signin/LoginSelfHostedViewController.swift | 2 +- .../Signin/LoginSiteAddressViewController.swift | 6 +++++- .../Signin/LoginUsernamePasswordViewController.swift | 2 +- .../Signin/LoginWPComViewController.swift | 9 ++++++++- 9 files changed, 31 insertions(+), 18 deletions(-) delete mode 100644 WordPressAuthenticator/Extensions/UIButton+Styles.swift diff --git a/WordPressAuthenticator.xcodeproj/project.pbxproj b/WordPressAuthenticator.xcodeproj/project.pbxproj index 295574d28..e0f6c018a 100644 --- a/WordPressAuthenticator.xcodeproj/project.pbxproj +++ b/WordPressAuthenticator.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 0239624F2398E43C0096F34C /* UIButton+Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0239624E2398E43C0096F34C /* UIButton+Styles.swift */; }; 1A21EE9822832BC300C940C6 /* WordPressComOAuthClientFacade+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */; }; 1A4095182271AEFC009AA86D /* WPAuthenticator-Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */; settings = {ATTRIBUTES = (Private, ); }; }; 7A7A9B9CD2D81959F9AB9AF6 /* Pods_WordPressAuthenticator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C736FF243DE333FCAB1C2614 /* Pods_WordPressAuthenticator.framework */; }; @@ -143,7 +142,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 0239624E2398E43C0096F34C /* UIButton+Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Styles.swift"; sourceTree = ""; }; 1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "WordPressComOAuthClientFacade+Swift.swift"; sourceTree = ""; }; 1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPAuthenticator-Swift.h"; sourceTree = ""; }; 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 = ""; }; @@ -467,7 +465,6 @@ B56090EE208A527000399AE4 /* String+Underline.swift */, B56090EC208A527000399AE4 /* WPStyleGuide+Login.swift */, B5CDBED320B4714500BC1EF2 /* UIImage+Assets.swift */, - 0239624E2398E43C0096F34C /* UIButton+Styles.swift */, ); path = Extensions; sourceTree = ""; @@ -902,7 +899,6 @@ B56090EB208A51D000399AE4 /* LoginFields.swift in Sources */, B56090FB208A533200399AE4 /* WordPressSupportSourceTag.swift in Sources */, B56090C6208A4F5400399AE4 /* NUXButtonViewController.swift in Sources */, - 0239624F2398E43C0096F34C /* UIButton+Styles.swift in Sources */, B5609121208A555E00399AE4 /* SignupEmailViewController.swift in Sources */, B5609107208A54F800399AE4 /* WordPressComBlogService.swift in Sources */, B560910D208A54F800399AE4 /* WordPressXMLRPCAPIFacade.m in Sources */, diff --git a/WordPressAuthenticator/Extensions/UIButton+Styles.swift b/WordPressAuthenticator/Extensions/UIButton+Styles.swift deleted file mode 100644 index 11140c1e8..000000000 --- a/WordPressAuthenticator/Extensions/UIButton+Styles.swift +++ /dev/null @@ -1,9 +0,0 @@ -import UIKit - -extension UIButton { - /// Applies default styles to a plain text button. - func applyTextButtonStyle() { - setTitleColor(WordPressAuthenticator.shared.style.textButtonColor, for: .normal) - setTitleColor(WordPressAuthenticator.shared.style.textButtonHighlightColor, for: .highlighted) - } -} diff --git a/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift b/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift index e91513e7f..29c086e88 100644 --- a/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift +++ b/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift @@ -71,6 +71,13 @@ extension WPStyleGuide { onePasswordButton.addTarget(target, action: selector, for: .touchUpInside) } + /// Configures a plain text button with default styles. + /// + class func configureTextButton(_ button: UIButton) { + button.setTitleColor(WordPressAuthenticator.shared.style.textButtonColor, for: .normal) + button.setTitleColor(WordPressAuthenticator.shared.style.textButtonHighlightColor, for: .highlighted) + } + /// /// class func colorForErrorView(_ opaque: Bool) -> UIColor { diff --git a/WordPressAuthenticator/Signin/Login2FAViewController.swift b/WordPressAuthenticator/Signin/Login2FAViewController.swift index 1bb14ba79..0692b550e 100644 --- a/WordPressAuthenticator/Signin/Login2FAViewController.swift +++ b/WordPressAuthenticator/Signin/Login2FAViewController.swift @@ -78,6 +78,7 @@ class Login2FAViewController: LoginViewController, NUXKeyboardResponder, UITextF private func styleSendCodeButton() { sendCodeButton.titleLabel?.adjustsFontForContentSizeCategory = true sendCodeButton.titleLabel?.adjustsFontSizeToFitWidth = true + WPStyleGuide.configureTextButton(sendCodeButton) } // MARK: Configuration Methods @@ -97,7 +98,6 @@ class Login2FAViewController: LoginViewController, NUXKeyboardResponder, UITextF sendCodeButton.setTitle(NSLocalizedString("Text me a code instead", comment: "Button title"), for: .normal) sendCodeButton.titleLabel?.numberOfLines = 0 - sendCodeButton.applyTextButtonStyle() } /// configures the text fields diff --git a/WordPressAuthenticator/Signin/LoginLinkRequestViewController.swift b/WordPressAuthenticator/Signin/LoginLinkRequestViewController.swift index ca4fef406..e7a58d181 100644 --- a/WordPressAuthenticator/Signin/LoginLinkRequestViewController.swift +++ b/WordPressAuthenticator/Signin/LoginLinkRequestViewController.swift @@ -25,6 +25,7 @@ class LoginLinkRequestViewController: LoginViewController { super.viewDidLoad() localizeControls() + configureUsePasswordButton() let email = loginFields.username if !email.isValidEmail() { @@ -78,6 +79,13 @@ class LoginLinkRequestViewController: LoginViewController { sendLinkButton?.isEnabled = !animating } + private func configureUsePasswordButton() { + guard let usePasswordButton = usePasswordButton else { + return + } + WPStyleGuide.configureTextButton(usePasswordButton) + } + // MARK: - Instance Methods diff --git a/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift b/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift index a3f4f09cb..8db550889 100644 --- a/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift +++ b/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift @@ -87,7 +87,6 @@ class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder { forgotPasswordButton.setTitle(forgotPasswordTitle, for: .normal) forgotPasswordButton.setTitle(forgotPasswordTitle, for: .highlighted) forgotPasswordButton.titleLabel?.numberOfLines = 0 - forgotPasswordButton.applyTextButtonStyle() } @@ -114,6 +113,7 @@ class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder { /// @objc func configureForgotPasswordButton() { forgotPasswordButton.isEnabled = enableSubmit(animating: false) + WPStyleGuide.configureTextButton(forgotPasswordButton) } diff --git a/WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift b/WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift index c6b7fbaf8..e51faf76b 100644 --- a/WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift +++ b/WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift @@ -47,6 +47,7 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder loginFields.meta.userIsDotCom = false configureTextFields() + configureSiteAddressHelpButton() configureSubmitButton(animating: false) configureViewForEditingIfNeeded() @@ -87,7 +88,6 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder siteAddressHelpButton.setTitle(siteAddressHelpTitle, for: .normal) siteAddressHelpButton.setTitle(siteAddressHelpTitle, for: .highlighted) siteAddressHelpButton.titleLabel?.numberOfLines = 0 - siteAddressHelpButton.applyTextButtonStyle() } @@ -133,6 +133,10 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder } } + private func configureSiteAddressHelpButton() { + WPStyleGuide.configureTextButton(siteAddressHelpButton) + } + // MARK: - Instance Methods diff --git a/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift b/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift index 1c196d7bc..6c65d1bb9 100644 --- a/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift +++ b/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift @@ -87,7 +87,6 @@ class LoginUsernamePasswordViewController: LoginViewController, NUXKeyboardRespo forgotPasswordButton.setTitle(forgotPasswordTitle, for: .normal) forgotPasswordButton.setTitle(forgotPasswordTitle, for: .highlighted) forgotPasswordButton.titleLabel?.numberOfLines = 0 - forgotPasswordButton.applyTextButtonStyle() } @@ -114,6 +113,7 @@ class LoginUsernamePasswordViewController: LoginViewController, NUXKeyboardRespo /// @objc func configureForgotPasswordButton() { forgotPasswordButton.isEnabled = enableSubmit(animating: false) + WPStyleGuide.configureTextButton(forgotPasswordButton) } diff --git a/WordPressAuthenticator/Signin/LoginWPComViewController.swift b/WordPressAuthenticator/Signin/LoginWPComViewController.swift index 8ae351fd6..6a420ba33 100644 --- a/WordPressAuthenticator/Signin/LoginWPComViewController.swift +++ b/WordPressAuthenticator/Signin/LoginWPComViewController.swift @@ -45,6 +45,7 @@ class LoginWPComViewController: LoginViewController, NUXKeyboardResponder { configureTextFields() configureEmailIcon() + configureForgotPasswordButton() configureSubmitButton(animating: false) configureViewForEditingIfNeeded() } @@ -128,6 +129,13 @@ class LoginWPComViewController: LoginViewController, NUXKeyboardResponder { emailIcon?.image = image.imageWithTintColor(WordPressAuthenticator.shared.style.subheadlineColor) } + private func configureForgotPasswordButton() { + guard let forgotPasswordButton = forgotPasswordButton else { + return + } + WPStyleGuide.configureTextButton(forgotPasswordButton) + } + @objc func localizeControls() { instructionLabel?.text = { @@ -154,7 +162,6 @@ class LoginWPComViewController: LoginViewController, NUXKeyboardResponder { forgotPasswordButton?.setTitle(forgotPasswordTitle, for: .normal) forgotPasswordButton?.setTitle(forgotPasswordTitle, for: .highlighted) forgotPasswordButton?.titleLabel?.numberOfLines = 0 - forgotPasswordButton?.applyTextButtonStyle() }