From 10bc7ceb62a21d0a0ae58540eda95d2be7d46da3 Mon Sep 17 00:00:00 2001 From: Charlie Scheer Date: Mon, 22 Jul 2024 16:08:06 -0600 Subject: [PATCH 1/3] Use secondary action to move to the email view instead of switch --- Simplenote/AuthViewController+Swift.swift | 17 +++++++ Simplenote/AuthViewController.h | 4 ++ Simplenote/AuthViewController.xib | 61 ++++++++++++++++++++--- Simplenote/AuthenticationMode.swift | 19 ++++--- 4 files changed, 86 insertions(+), 15 deletions(-) diff --git a/Simplenote/AuthViewController+Swift.swift b/Simplenote/AuthViewController+Swift.swift index f75ca3f38..38a379564 100644 --- a/Simplenote/AuthViewController+Swift.swift +++ b/Simplenote/AuthViewController+Swift.swift @@ -30,6 +30,17 @@ extension AuthViewController { wordPressSSOButton.image = NSImage(named: .wordPressLogo)?.tinted(with: .simplenoteBrandColor) wordPressSSOButton.title = Localization.dotcomSSOAction wordPressSSOButton.contentTintColor = .simplenoteTertiaryTextColor + + setupActionsSeparatorView() + } + + private func setupActionsSeparatorView() { + leadingSeparatorView.wantsLayer = true + leadingSeparatorView.layer?.backgroundColor = NSColor.lightGray.cgColor + trailingSeparatorView.wantsLayer = true + trailingSeparatorView.layer?.backgroundColor = NSColor.lightGray.cgColor + + separatorLabel.textColor = .lightGray } } @@ -103,6 +114,7 @@ extension AuthViewController { wordPressSSOButton.alphaValue = mode.wordPressSSOFieldAlpha switchAuthenticationView.isHidden = !mode.isSwitchVisible + actionsSeparatorView.isHidden = !mode.showActionSeparator } /// Animates Visible / Invisible components, based on the specified state @@ -181,6 +193,11 @@ extension AuthViewController { return nextVC } + + @objc + func pushEmailLoginView() { + containingNavigationController?.push(nextViewController()) + } } diff --git a/Simplenote/AuthViewController.h b/Simplenote/AuthViewController.h index 5d85ff413..83c4990cd 100644 --- a/Simplenote/AuthViewController.h +++ b/Simplenote/AuthViewController.h @@ -22,6 +22,10 @@ @property (nonatomic, strong) IBOutlet NSView *wordPressSSOContainerView; @property (nonatomic, strong) IBOutlet NSButton *wordPressSSOButton; @property (weak) IBOutlet NSView *switchAuthenticationView; +@property (weak) IBOutlet NSView *actionsSeparatorView; +@property (weak) IBOutlet NSView *leadingSeparatorView; +@property (weak) IBOutlet NSTextField *separatorLabel; +@property (weak) IBOutlet NSView *trailingSeparatorView; @property (nonatomic, strong) IBOutlet NSLayoutConstraint *passwordFieldHeightConstraint; @property (nonatomic, strong) IBOutlet NSLayoutConstraint *secondaryActionHeightConstraint; diff --git a/Simplenote/AuthViewController.xib b/Simplenote/AuthViewController.xib index d77d84527..687c4025b 100644 --- a/Simplenote/AuthViewController.xib +++ b/Simplenote/AuthViewController.xib @@ -10,16 +10,20 @@ + + + + @@ -30,13 +34,13 @@ - + - + - + @@ -44,7 +48,7 @@ - + @@ -55,13 +59,13 @@ - + - + @@ -70,7 +74,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -184,12 +224,15 @@ + + + @@ -200,6 +243,7 @@ + @@ -210,6 +254,7 @@ + diff --git a/Simplenote/AuthenticationMode.swift b/Simplenote/AuthenticationMode.swift index 0ae05869a..e8371a251 100644 --- a/Simplenote/AuthenticationMode.swift +++ b/Simplenote/AuthenticationMode.swift @@ -19,8 +19,9 @@ class AuthenticationMode: NSObject { let isSecondaryActionVisible: Bool let isWordPressVisible: Bool let isSwitchVisible: Bool + let showActionSeparator: Bool - init(primaryActionText: String, primaryActionAnimationText: String, primaryActionSelector: Selector, secondaryActionText: String?, secondaryActionSelector: Selector?, switchActionText: String, switchActionTip: String, switchTargetMode: @escaping () -> AuthenticationMode, isPasswordVisible: Bool, isSecondaryActionVisible: Bool, isWordPressVisible: Bool, isSwitchVisible: Bool) { + init(primaryActionText: String, primaryActionAnimationText: String, primaryActionSelector: Selector, secondaryActionText: String?, secondaryActionSelector: Selector?, switchActionText: String, switchActionTip: String, switchTargetMode: @escaping () -> AuthenticationMode, isPasswordVisible: Bool, isSecondaryActionVisible: Bool, isWordPressVisible: Bool, isSwitchVisible: Bool, showActionSeparator: Bool) { self.primaryActionText = primaryActionText self.primaryActionAnimationText = primaryActionAnimationText self.primaryActionSelector = primaryActionSelector @@ -33,6 +34,7 @@ class AuthenticationMode: NSObject { self.isSecondaryActionVisible = isSecondaryActionVisible self.isWordPressVisible = isWordPressVisible self.isSwitchVisible = isSwitchVisible + self.showActionSeparator = showActionSeparator } } @@ -90,7 +92,8 @@ extension AuthenticationMode { isPasswordVisible: true, isSecondaryActionVisible: true, isWordPressVisible: true, - isSwitchVisible: false) + isSwitchVisible: false, + showActionSeparator: true) } /// Auth Mode: Login is handled via Magic Links! @@ -108,7 +111,8 @@ extension AuthenticationMode { isPasswordVisible: false, isSecondaryActionVisible: true, isWordPressVisible: true, - isSwitchVisible: false) + isSwitchVisible: false, + showActionSeparator: true) } /// Auth Mode: SignUp @@ -118,15 +122,16 @@ extension AuthenticationMode { AuthenticationMode(primaryActionText: SignupStrings.primaryAction, primaryActionAnimationText: SignupStrings.primaryAnimationText, primaryActionSelector: #selector(AuthViewController.pressedSignUp), - secondaryActionText: nil, - secondaryActionSelector: nil, + secondaryActionText: SignupStrings.switchAction, + secondaryActionSelector: #selector(AuthViewController.pushEmailLoginView), switchActionText: SignupStrings.switchAction, switchActionTip: SignupStrings.switchTip, switchTargetMode: { .loginWithMagicLink }, isPasswordVisible: false, - isSecondaryActionVisible: false, + isSecondaryActionVisible: true, isWordPressVisible: false, - isSwitchVisible: true) + isSwitchVisible: false, + showActionSeparator: false) } } From 6fa0e2ccaf6f3c60e63764d1ed7765d58d20c97c Mon Sep 17 00:00:00 2001 From: Charlie Scheer Date: Mon, 22 Jul 2024 16:18:34 -0600 Subject: [PATCH 2/3] Removed the switch mode button --- Simplenote/AuthViewController+Swift.swift | 14 ----- Simplenote/AuthViewController.h | 3 -- Simplenote/AuthViewController.m | 1 - Simplenote/AuthViewController.xib | 63 ++++------------------- Simplenote/AuthenticationMode.swift | 26 ++++------ 5 files changed, 19 insertions(+), 88 deletions(-) diff --git a/Simplenote/AuthViewController+Swift.swift b/Simplenote/AuthViewController+Swift.swift index 38a379564..c7a7551c4 100644 --- a/Simplenote/AuthViewController+Swift.swift +++ b/Simplenote/AuthViewController+Swift.swift @@ -20,12 +20,6 @@ extension AuthViewController { // Secondary Action secondaryActionButton.contentTintColor = .simplenoteBrandColor - // Toggle Signup: Tip - switchTipField.textColor = .simplenoteTertiaryTextColor - - // Toggle Signup: Action - switchActionButton.contentTintColor = .simplenoteBrandColor - // WordPress SSO wordPressSSOButton.image = NSImage(named: .wordPressLogo)?.tinted(with: .simplenoteBrandColor) wordPressSSOButton.title = Localization.dotcomSSOAction @@ -78,8 +72,6 @@ extension AuthViewController { func refreshButtonTitles() { actionButton.title = mode.primaryActionText secondaryActionButton.title = mode.secondaryActionText?.uppercased() ?? "" - switchTipField.stringValue = mode.switchActionTip.uppercased() - switchActionButton.title = mode.switchActionText.uppercased() } /// Makes sure unused components (in the current mode) are effectively disabled @@ -113,7 +105,6 @@ extension AuthViewController { secondaryActionButton.alphaValue = mode.secondaryActionFieldAlpha wordPressSSOButton.alphaValue = mode.wordPressSSOFieldAlpha - switchAuthenticationView.isHidden = !mode.isSwitchVisible actionsSeparatorView.isHidden = !mode.showActionSeparator } @@ -179,11 +170,6 @@ extension AuthViewController { performSelector(onMainThread: secondaryActionSelector, with: nil, waitUntilDone: false) } - @IBAction - func switchAuthenticationMode(_ sender: Any) { - containingNavigationController?.push(nextViewController()) - } - private func nextViewController() -> AuthViewController { let nextMode = mode.nextMode() diff --git a/Simplenote/AuthViewController.h b/Simplenote/AuthViewController.h index 83c4990cd..6bb688721 100644 --- a/Simplenote/AuthViewController.h +++ b/Simplenote/AuthViewController.h @@ -17,11 +17,8 @@ @property (nonatomic, strong) IBOutlet NSButton *actionButton; @property (nonatomic, strong) IBOutlet NSProgressIndicator *actionProgress; @property (nonatomic, strong) IBOutlet NSButton *secondaryActionButton; -@property (nonatomic, strong) IBOutlet NSTextField *switchTipField; -@property (nonatomic, strong) IBOutlet NSButton *switchActionButton; @property (nonatomic, strong) IBOutlet NSView *wordPressSSOContainerView; @property (nonatomic, strong) IBOutlet NSButton *wordPressSSOButton; -@property (weak) IBOutlet NSView *switchAuthenticationView; @property (weak) IBOutlet NSView *actionsSeparatorView; @property (weak) IBOutlet NSView *leadingSeparatorView; @property (weak) IBOutlet NSTextField *separatorLabel; diff --git a/Simplenote/AuthViewController.m b/Simplenote/AuthViewController.m index f8fde38bd..acbc1eeed 100644 --- a/Simplenote/AuthViewController.m +++ b/Simplenote/AuthViewController.m @@ -81,7 +81,6 @@ - (void)setInterfaceEnabled:(BOOL)enabled { [self.passwordField setEnabled:enabled]; [self.actionButton setEnabled:enabled]; [self.secondaryActionButton setEnabled:enabled]; - [self.switchActionButton setEnabled:enabled]; [self.wordPressSSOButton setEnabled:enabled]; } diff --git a/Simplenote/AuthViewController.xib b/Simplenote/AuthViewController.xib index 687c4025b..9f71a8600 100644 --- a/Simplenote/AuthViewController.xib +++ b/Simplenote/AuthViewController.xib @@ -20,9 +20,6 @@ - - - @@ -34,13 +31,13 @@ - + - + - + @@ -48,7 +45,7 @@ - + @@ -59,13 +56,13 @@ - + - + @@ -74,7 +71,7 @@ - + - + @@ -151,46 +148,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -243,7 +200,6 @@ - @@ -254,7 +210,6 @@ - diff --git a/Simplenote/AuthenticationMode.swift b/Simplenote/AuthenticationMode.swift index e8371a251..395cc2189 100644 --- a/Simplenote/AuthenticationMode.swift +++ b/Simplenote/AuthenticationMode.swift @@ -11,29 +11,32 @@ class AuthenticationMode: NSObject { let secondaryActionText: String? let secondaryActionSelector: Selector? - let switchActionText: String - let switchActionTip: String let switchTargetMode: () -> AuthenticationMode let isPasswordVisible: Bool let isSecondaryActionVisible: Bool let isWordPressVisible: Bool - let isSwitchVisible: Bool let showActionSeparator: Bool - init(primaryActionText: String, primaryActionAnimationText: String, primaryActionSelector: Selector, secondaryActionText: String?, secondaryActionSelector: Selector?, switchActionText: String, switchActionTip: String, switchTargetMode: @escaping () -> AuthenticationMode, isPasswordVisible: Bool, isSecondaryActionVisible: Bool, isWordPressVisible: Bool, isSwitchVisible: Bool, showActionSeparator: Bool) { + init(primaryActionText: String, + primaryActionAnimationText: String, + primaryActionSelector: Selector, + secondaryActionText: String?, + secondaryActionSelector: Selector?, + switchTargetMode: @escaping () -> AuthenticationMode, + isPasswordVisible: Bool, + isSecondaryActionVisible: Bool, + isWordPressVisible: Bool, + showActionSeparator: Bool) { self.primaryActionText = primaryActionText self.primaryActionAnimationText = primaryActionAnimationText self.primaryActionSelector = primaryActionSelector self.secondaryActionText = secondaryActionText self.secondaryActionSelector = secondaryActionSelector - self.switchActionText = switchActionText - self.switchActionTip = switchActionTip self.switchTargetMode = switchTargetMode self.isPasswordVisible = isPasswordVisible self.isSecondaryActionVisible = isSecondaryActionVisible self.isWordPressVisible = isWordPressVisible - self.isSwitchVisible = isSwitchVisible self.showActionSeparator = showActionSeparator } } @@ -86,13 +89,10 @@ extension AuthenticationMode { primaryActionSelector: #selector(AuthViewController.pressedLogInWithPassword), secondaryActionText: LoginStrings.secondaryAction, secondaryActionSelector: #selector(AuthViewController.openForgotPasswordURL), - switchActionText: LoginStrings.switchAction, - switchActionTip: LoginStrings.switchTip, switchTargetMode: { .signup }, isPasswordVisible: true, isSecondaryActionVisible: true, isWordPressVisible: true, - isSwitchVisible: false, showActionSeparator: true) } @@ -105,13 +105,10 @@ extension AuthenticationMode { primaryActionSelector: #selector(AuthViewController.pressedLoginWithMagicLink), secondaryActionText: MagicLinkStrings.secondaryAction, secondaryActionSelector: #selector(AuthViewController.switchToPasswordAuth), - switchActionText: MagicLinkStrings.switchAction, - switchActionTip: MagicLinkStrings.switchTip, switchTargetMode: { .signup }, isPasswordVisible: false, isSecondaryActionVisible: true, isWordPressVisible: true, - isSwitchVisible: false, showActionSeparator: true) } @@ -124,13 +121,10 @@ extension AuthenticationMode { primaryActionSelector: #selector(AuthViewController.pressedSignUp), secondaryActionText: SignupStrings.switchAction, secondaryActionSelector: #selector(AuthViewController.pushEmailLoginView), - switchActionText: SignupStrings.switchAction, - switchActionTip: SignupStrings.switchTip, switchTargetMode: { .loginWithMagicLink }, isPasswordVisible: false, isSecondaryActionVisible: true, isWordPressVisible: false, - isSwitchVisible: false, showActionSeparator: false) } } From a670f8e72d1e5328e3360ae9380f42e4c311c672 Mon Sep 17 00:00:00 2001 From: Charlie Scheer Date: Mon, 22 Jul 2024 16:35:30 -0600 Subject: [PATCH 3/3] Redesign wordpress sso button --- Simplenote/AuthViewController+Swift.swift | 6 +++-- Simplenote/AuthViewController.xib | 27 +++++++++++------------ Simplenote/AuthenticationMode.swift | 2 +- Simplenote/NSColor+Theme.swift | 4 ++++ 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Simplenote/AuthViewController+Swift.swift b/Simplenote/AuthViewController+Swift.swift index c7a7551c4..00d46c05c 100644 --- a/Simplenote/AuthViewController+Swift.swift +++ b/Simplenote/AuthViewController+Swift.swift @@ -21,9 +21,11 @@ extension AuthViewController { secondaryActionButton.contentTintColor = .simplenoteBrandColor // WordPress SSO - wordPressSSOButton.image = NSImage(named: .wordPressLogo)?.tinted(with: .simplenoteBrandColor) wordPressSSOButton.title = Localization.dotcomSSOAction - wordPressSSOButton.contentTintColor = .simplenoteTertiaryTextColor + wordPressSSOButton.contentTintColor = .white + wordPressSSOContainerView.wantsLayer = true + wordPressSSOContainerView.layer?.backgroundColor = NSColor.simplenoteWPBlue50Color.cgColor + wordPressSSOContainerView.layer?.cornerRadius = 5 setupActionsSeparatorView() } diff --git a/Simplenote/AuthViewController.xib b/Simplenote/AuthViewController.xib index 9f71a8600..6493dcb7f 100644 --- a/Simplenote/AuthViewController.xib +++ b/Simplenote/AuthViewController.xib @@ -31,13 +31,13 @@ - + - + - + @@ -45,7 +45,7 @@ - + @@ -56,13 +56,13 @@ - + - + @@ -71,7 +71,7 @@ - + - + @@ -149,11 +149,11 @@ - +