Skip to content

Commit 3cb32af

Browse files
author
golson
committed
Update logo bg
1 parent f594dd7 commit 3cb32af

File tree

2 files changed

+7
-60
lines changed

2 files changed

+7
-60
lines changed

WMFComponents/Sources/WMFComponents/Extensions/Navigation Bar/WMFNavigationBarHiding.swift

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -84,68 +84,11 @@ public extension WMFNavigationBarHiding where Self:UIViewController {
8484

8585
/// Swap logo to the compact W icon
8686
private func swapLogoToCompact() {
87-
if let titleButton = navigationItem.titleView,
88-
let button = titleButton.subviews.first(where: { $0 is UIButton }) as? UIButton {
89-
button.setImage(UIImage(named: "W"), for: .normal)
90-
}
91-
92-
if let rightBarButtonItems = navigationItem.rightBarButtonItems {
93-
for barButtonItem in rightBarButtonItems {
94-
updateLogoImage(in: barButtonItem, to: "W")
95-
}
96-
}
97-
98-
if let leftBarButtonItem = navigationItem.leftBarButtonItem {
99-
updateLogoImage(in: leftBarButtonItem, to: "W")
100-
}
87+
navigationItem.leftBarButtonItem?.image = UIImage(named: "W")
10188
}
10289

10390
/// Swap logo back to the full Wikipedia logo
10491
private func swapLogoToFull() {
105-
if let titleButton = navigationItem.titleView,
106-
let button = titleButton.subviews.first(where: { $0 is UIButton }) as? UIButton {
107-
button.setImage(UIImage(named: "wikipedia"), for: .normal)
108-
}
109-
110-
if let rightBarButtonItems = navigationItem.rightBarButtonItems {
111-
for barButtonItem in rightBarButtonItems {
112-
updateLogoImage(in: barButtonItem, to: "wikipedia")
113-
}
114-
}
115-
116-
if let leftBarButtonItem = navigationItem.leftBarButtonItem {
117-
updateLogoImage(in: leftBarButtonItem, to: "wikipedia")
118-
}
119-
}
120-
121-
private func updateLogoImage(in barButtonItem: UIBarButtonItem, to imageName: String) {
122-
if let customView = barButtonItem.customView {
123-
if let button = customView as? UIButton {
124-
let image = UIImage(named: imageName)
125-
button.setImage(image, for: .normal)
126-
} else {
127-
// Handle nested views
128-
for subview in customView.subviews {
129-
if let button = subview as? UIButton {
130-
let image = UIImage(named: imageName)
131-
button.setImage(image, for: .normal)
132-
}
133-
}
134-
}
135-
}
136-
}
137-
}
138-
139-
private extension UIApplication {
140-
var keyWindow: UIWindow? {
141-
return UIApplication
142-
.shared
143-
.connectedScenes
144-
.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
145-
.last { $0.isKeyWindow }
146-
}
147-
148-
var statusBarFrame: CGRect {
149-
keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? .zero
92+
navigationItem.leftBarButtonItem?.image = UIImage(named: "wikipedia")
15093
}
15194
}

Wikipedia/Code/ExploreViewController.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,12 @@ class ExploreViewController: ColumnarCollectionViewController, ExploreCardViewCo
198198

199199
configureNavigationBar(titleConfig: titleConfig, closeButtonConfig: nil, profileButtonConfig: profileButtonConfig, tabsButtonConfig: tabsButtonConfig, searchBarConfig: searchConfig, hideNavigationBarOnScroll: !presentingSearchResults)
200200

201-
// Need to override this so that "" does not appear as back button title.
201+
// Need to override this so that "" does not appear as back button title.
202202
navigationItem.backButtonTitle = CommonStrings.exploreTabTitle
203+
204+
// Set up logo as left bar button item
205+
let logoBarButtonItem = UIBarButtonItem(image: UIImage(named: "wikipedia"), style: .plain, target: self, action: #selector(titleBarButtonPressed(_:)))
206+
navigationItem.leftBarButtonItem = logoBarButtonItem
203207
}
204208

205209
@objc func updateProfileButton() {

0 commit comments

Comments
 (0)