Skip to content

Commit 4286477

Browse files
authored
iOS 26: Fix Dotorg login navigation bar appearance (#24810)
* Remove navigation bar custom appearnance * Remove Help notifications support form login flow
1 parent 74f02a5 commit 4286477

26 files changed

+6
-235
lines changed

Sources/WordPressAuthenticator/Features/NUX/NUXTableViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import UIKit
66
open class NUXTableViewController: UITableViewController, NUXViewControllerBase, UIViewControllerTransitioningDelegate {
77
// MARK: NUXViewControllerBase properties
88
/// these properties comply with NUXViewControllerBase and are duplicated with NUXViewController
9-
public var helpNotificationIndicator: WPHelpIndicatorView = WPHelpIndicatorView()
109
public var helpButton: UIButton = UIButton(type: .custom)
1110
public var dismissBlock: ((_ cancelled: Bool) -> Void)?
1211
public var loginFields = LoginFields()

Sources/WordPressAuthenticator/Features/NUX/NUXViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import UIKit
88
open class NUXViewController: UIViewController, NUXViewControllerBase, UIViewControllerTransitioningDelegate {
99
// MARK: NUXViewControllerBase properties
1010
/// these properties comply with NUXViewControllerBase and are duplicated with NUXTableViewController
11-
public var helpNotificationIndicator: WPHelpIndicatorView = WPHelpIndicatorView()
1211
public var helpButton: UIButton = UIButton(type: .custom)
1312
public var dismissBlock: ((_ cancelled: Bool) -> Void)?
1413
public var loginFields = LoginFields()

Sources/WordPressAuthenticator/Features/NUX/NUXViewControllerBase.swift

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ private enum Constants {
1414
/// base protocol for NUX view controllers
1515
public protocol NUXViewControllerBase {
1616
var sourceTag: WordPressSupportSourceTag { get }
17-
var helpNotificationIndicator: WPHelpIndicatorView { get }
1817
var helpButton: UIButton { get }
1918
var loginFields: LoginFields { get }
2019
var dismissBlock: ((_ cancelled: Bool) -> Void)? { get }
@@ -106,15 +105,6 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
106105
self.dismiss(animated: true, completion: nil)
107106
}
108107

109-
// MARK: - Notifications
110-
111-
/// Updates the notification indicatorand its visibility.
112-
///
113-
func refreshSupportNotificationIndicator() {
114-
let showIndicator = WordPressAuthenticator.shared.delegate?.showSupportNotificationIndicator ?? false
115-
helpNotificationIndicator.isHidden = !showIndicator
116-
}
117-
118108
// MARK: - Actions
119109

120110
func handleBackgroundTapGesture() {
@@ -142,48 +132,6 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
142132
displaySupportViewController(from: sourceTag)
143133
}
144134

145-
// MARK: - Navbar Help and App Logo methods
146-
147-
func styleNavigationBar(forUnified: Bool = false) {
148-
var backgroundColor: UIColor
149-
var buttonTextColor: UIColor
150-
var titleTextColor: UIColor
151-
var hideBottomBorder: Bool
152-
153-
if forUnified {
154-
// Unified nav bar style
155-
backgroundColor = WordPressAuthenticator.shared.unifiedStyle?.navBarBackgroundColor ??
156-
WordPressAuthenticator.shared.style.navBarBackgroundColor
157-
buttonTextColor = WordPressAuthenticator.shared.unifiedStyle?.navButtonTextColor ??
158-
WordPressAuthenticator.shared.style.navButtonTextColor
159-
titleTextColor = WordPressAuthenticator.shared.unifiedStyle?.navTitleTextColor ??
160-
WordPressAuthenticator.shared.style.primaryTitleColor
161-
hideBottomBorder = true
162-
} else {
163-
// Original nav bar style
164-
backgroundColor = WordPressAuthenticator.shared.style.navBarBackgroundColor
165-
buttonTextColor = WordPressAuthenticator.shared.style.navButtonTextColor
166-
titleTextColor = WordPressAuthenticator.shared.style.primaryTitleColor
167-
hideBottomBorder = false
168-
}
169-
170-
setupNavBarIcon(showIcon: !forUnified)
171-
setHelpButtonTextColor(forUnified: forUnified)
172-
173-
let buttonItemAppearance = UIBarButtonItem.appearance(whenContainedInInstancesOf: [LoginNavigationController.self])
174-
buttonItemAppearance.tintColor = buttonTextColor
175-
buttonItemAppearance.setTitleTextAttributes([.foregroundColor: buttonTextColor], for: .normal)
176-
177-
let appearance = UINavigationBarAppearance()
178-
appearance.shadowColor = hideBottomBorder ? .clear : .separator
179-
appearance.backgroundColor = backgroundColor
180-
appearance.titleTextAttributes = [.foregroundColor: titleTextColor]
181-
182-
UINavigationBar.appearance(whenContainedInInstancesOf: [LoginNavigationController.self]).standardAppearance = appearance
183-
UINavigationBar.appearance(whenContainedInInstancesOf: [LoginNavigationController.self]).compactAppearance = appearance
184-
UINavigationBar.appearance(whenContainedInInstancesOf: [LoginNavigationController.self]).scrollEdgeAppearance = appearance
185-
}
186-
187135
/// Add/remove the nav bar app logo.
188136
///
189137
func setupNavBarIcon(showIcon: Bool = true) {
@@ -213,24 +161,6 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
213161
}
214162

215163
addHelpButtonToNavController()
216-
refreshSupportNotificationIndicator()
217-
}
218-
219-
/// Sets the Help button text color.
220-
///
221-
/// - Parameters:
222-
/// - forUnified: Indicates whether to use text color for the unified auth flows or the original auth flows.
223-
///
224-
func setHelpButtonTextColor(forUnified: Bool) {
225-
let navButtonTextColor: UIColor = {
226-
if forUnified {
227-
return WordPressAuthenticator.shared.unifiedStyle?.navButtonTextColor ?? WordPressAuthenticator.shared.style.navButtonTextColor
228-
}
229-
return WordPressAuthenticator.shared.style.navButtonTextColor
230-
}()
231-
232-
helpButton.setTitleColor(navButtonTextColor, for: .normal)
233-
helpButton.setTitleColor(navButtonTextColor.withAlphaComponent(0.4), for: .highlighted)
234164
}
235165

236166
// MARK: - Helpers
@@ -240,7 +170,6 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
240170
private func addHelpButtonToNavController() {
241171
let barButtonView = createBarButtonView()
242172
addHelpButton(to: barButtonView)
243-
addNotificationIndicatorView(to: barButtonView)
244173
addRightBarButtonItem(with: barButtonView)
245174
}
246175

@@ -263,7 +192,7 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
263192

264193
private func addHelpButton(to superView: UIView) {
265194
helpButton.setTitle(NSLocalizedString("Help", comment: "Help button"), for: .normal)
266-
setHelpButtonTextColor(forUnified: false)
195+
helpButton.setTitleColor(.label, for: [])
267196
helpButton.accessibilityIdentifier = "authenticator-help-button"
268197

269198
helpButton.on(.touchUpInside) { [weak self] control in
@@ -279,45 +208,6 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
279208
helpButton.bottomAnchor.constraint(equalTo: superView.bottomAnchor).isActive = true
280209
}
281210

282-
// MARK: Notification Indicator settings
283-
284-
private func addNotificationIndicatorView(to superView: UIView) {
285-
setupNotificationsIndicator()
286-
layoutNotificationIndicatorView(helpNotificationIndicator, to: superView)
287-
}
288-
289-
private func setupNotificationsIndicator() {
290-
helpNotificationIndicator.isHidden = true
291-
292-
addNotificationObserver(
293-
NotificationCenter.default.addObserver(forName: .wordpressSupportNotificationReceived, object: nil, queue: nil) { [weak self] _ in
294-
self?.refreshSupportNotificationIndicator()
295-
}
296-
)
297-
298-
addNotificationObserver(
299-
NotificationCenter.default.addObserver(forName: .wordpressSupportNotificationCleared, object: nil, queue: nil) { [weak self] _ in
300-
self?.refreshSupportNotificationIndicator()
301-
}
302-
)
303-
}
304-
305-
private func layoutNotificationIndicatorView(_ view: UIView, to superView: UIView) {
306-
superView.addSubview(view)
307-
view.translatesAutoresizingMaskIntoConstraints = false
308-
309-
let centerOffset = Constants.notificationIndicatorCenterOffset
310-
let xConstant = helpButton.contentEdgeInsets.top + centerOffset.x
311-
let yConstant = helpButton.contentEdgeInsets.top + centerOffset.y
312-
313-
NSLayoutConstraint.activate([
314-
view.centerXAnchor.constraint(equalTo: helpButton.trailingAnchor, constant: xConstant),
315-
view.centerYAnchor.constraint(equalTo: helpButton.topAnchor, constant: yConstant),
316-
view.widthAnchor.constraint(equalToConstant: Constants.notificationIndicatorSize.width),
317-
view.heightAnchor.constraint(equalToConstant: Constants.notificationIndicatorSize.height)
318-
])
319-
}
320-
321211
// MARK: - UIViewControllerTransitioningDelegate
322212

323213
/// Displays the support vc.

Sources/WordPressAuthenticator/Features/NUX/WPHelpIndicatorView.swift

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

Sources/WordPressAuthenticator/Features/SignIn/LoginSocialErrorViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class LoginSocialErrorViewController: NUXTableViewController {
6565
let unifiedApple = unifiedAuthEnabled && loginFields.meta.socialService == .apple
6666
forUnified = unifiedGoogle || unifiedApple
6767

68-
styleNavigationBar(forUnified: forUnified)
6968
styleBackground()
7069
}
7170

Sources/WordPressAuthenticator/Features/SignIn/LoginViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ open class LoginViewController: NUXViewController, LoginFacadeDelegate {
5151
super.viewDidLoad()
5252

5353
displayError(message: "")
54-
styleNavigationBar(forUnified: true)
5554
styleBackground()
5655
styleInstructions()
5756

Sources/WordPressAuthenticator/Helpers/Authenticator/WordPressAuthenticator+Notifications.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,4 @@ extension NSNotification.Name {
88
/// Posted whenever a Jetpack Login was successfully performed.
99
///
1010
public static let wordpressLoginFinishedJetpackLogin = Foundation.Notification.Name(rawValue: "WordPressLoginFinishedJetpackLogin")
11-
12-
/// Posted whenever a Support notification is received.
13-
///
14-
public static let wordpressSupportNotificationReceived = NSNotification.Name(rawValue: "WordPressSupportNotificationReceived")
15-
16-
/// Posted whenever a Support notification has been viewed.
17-
///
18-
public static let wordpressSupportNotificationCleared = NSNotification.Name(rawValue: "WordPressSupportNotificationCleared")
1911
}

Sources/WordPressAuthenticator/Helpers/Authenticator/WordPressAuthenticator.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ import WordPressKit
100100

101101
// MARK: - Public Methods
102102

103-
public func supportPushNotificationReceived() {
104-
NotificationCenter.default.post(name: .wordpressSupportNotificationReceived, object: nil)
105-
}
106-
107-
public func supportPushNotificationCleared() {
108-
NotificationCenter.default.post(name: .wordpressSupportNotificationCleared, object: nil)
109-
}
110-
111103
/// Indicates if the specified ViewController belongs to the Authentication Flow, or not.
112104
///
113105
public class func isAuthenticationViewController(_ viewController: UIViewController) -> Bool {

Sources/WordPressAuthenticator/Helpers/Authenticator/WordPressAuthenticatorDelegateProtocol.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ public protocol WordPressAuthenticatorDelegate: AnyObject {
1717
///
1818
var wpcomTermsOfServiceEnabled: Bool { get }
1919

20-
/// Indicates if the Support notification indicator should be displayed.
21-
///
22-
var showSupportNotificationIndicator: Bool { get }
23-
2420
/// Indicates if Support is available or not.
2521
///
2622
var supportEnabled: Bool { get }

Sources/WordPressAuthenticator/Helpers/UnifiedAuth/ViewRelated/2FA/TwoFAViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ final class TwoFAViewController: LoginViewController {
3939
removeGoogleWaitingView()
4040

4141
navigationItem.title = WordPressAuthenticator.shared.displayStrings.logInTitle
42-
styleNavigationBar(forUnified: true)
4342

4443
defaultTableViewMargin = tableViewLeadingConstraint?.constant ?? 0
4544
setTableViewMargins(forWidth: view.frame.width)

0 commit comments

Comments
 (0)