Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom navigation bar #5121

Merged
merged 219 commits into from
Jan 17, 2025
Merged

Remove custom navigation bar #5121

merged 219 commits into from
Jan 17, 2025

Conversation

tonisevener
Copy link
Collaborator

Phabricator: https://phabricator.wikimedia.org/T363606

Notes

This PR removes the ViewController, NavigationBar, NavigationBarHider, and WMFThemeableNavigationController superclasses and deals with the fallout. There other other smaller cleanup items, but those are the main ones.

I added a WMComponentNavigationController (subclass of UINavigationController) in WMFComponents for us to switch to. All legacy view controllers and newer WMFComponentViewControllers use this for navigating.

I also added a WMFNavigationBarConfiguring and default protocol implementation of configureNavigationBar(...) that all UIViewControllers can (optionally) call. I also tried to comb through most of the app and use this method in every viewWillAppear, so that all configuration flows through one method.

There are still bugs, code cleanup and design review feedback that I need to do, but I wanted to get this up (at least in draft form) so that we can discuss it and potentially start review.

Test Steps

  1. Run the app, bask in the glow of the system navigation bar.

…ach tab view

- also hide tab bar in article view controller on push
- header view still needs work
@tonisevener tonisevener marked this pull request as ready for review January 10, 2025 23:50
// MARK: - Subclass Overrides

public func appEnvironmentDidChange() {
overrideUserInterfaceStyle = appEnvironment.theme.userInterfaceStyle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tiny: can we indent this

super.viewDidDisappear(animated)

if parent == nil {
tappedBack()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add any debug prints here or anything?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@l-olson1214 I think it's okay unless there's something particular you want me to write out here. Before in the old code, we added a custom navigation button that called tappedBack upon tap, which logs analytics that they tapped the back button. From what I could find this is a way to get similar functionality with the system nav back button.

@@ -0,0 +1,333 @@
// Common methods used for navigation bar display in the app
import UIKit

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: I think WMFNavigationBarConfiguring deserves to be in it's own file, rather than in a Utils file, same as WMFNavigationBarHiding.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

}

// TODO: remove after expiry date (1 March 2025)
func presentYearInReviewAnnouncement() {

// Do not show announcement when article is previewing. Fixes crash on preview long press.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!!

@@ -104,7 +124,7 @@ extension DiffHeaderTitleView: Themeable {
func apply(theme: Theme) {

backgroundColor = theme.colors.paperBackground
contentView.backgroundColor = theme.colors.paperBackground
backgroundColor = theme.colors.paperBackground
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of line above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

}

func configure(with vm: DiffHeaderViewModel, titleViewTapDelegate: DiffHeaderTitleViewTapDelegate? = nil, theme: Theme) {
contentView.configure(with: vm, titleViewTapDelegate: titleViewTapDelegate, theme: theme)
Copy link
Collaborator

@l-olson1214 l-olson1214 Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this (titleViewTapDelegate) be a good candidate for just passing the function through? I know we talked about that the other day in the badge delegate PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@l-olson1214 Reworked these to use closures, let me know if you'd like more tweaks.

@@ -241,8 +233,42 @@ private extension DiffListViewController {
}

extension DiffListViewController: UICollectionViewDataSource {

func numberOfSections(in collectionView: UICollectionView) -> Int {
return 3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this just a regular variable / computed variable? Why is it a func?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is just conforming to the UIKit UICollectionDataSource protocol, basically it's how we tell the collection view how many sections to display in the list.

It defaults to 1, which is why we didn't have to implement it at all before. With this change, we're taking some header views that were embedded in the custom navigation bar and sticking them in the list as section headers. So now the number of sections went from 1 to 3.

var delegatesSelection: Bool = false
var doesShowArticlePreviews = true

weak var delegate: SearchResultsViewControllerDelegate?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just pass the func here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@l-olson1214 Reworked these to use closures, let me know if you'd like more tweaks.

class PageHistoryViewController: ColumnarCollectionViewController {
class PageHistoryViewController: ColumnarCollectionViewController, WMFNavigationBarConfiguring {

// fileprivate static let headerReuseIdentifier = "TestHeader"
Copy link
Collaborator

@mazevedofs mazevedofs Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I think this comment can be deleted

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch. Fixed!

Copy link
Collaborator

@l-olson1214 l-olson1214 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good! There's nothing in here that I'm concerned about terribly, and I haven't been able to find any massive issues.

Thank you for the hard work you put into this!

Copy link
Collaborator

@mazevedofs mazevedofs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tonisevener tonisevener merged commit 16c3601 into main Jan 17, 2025
4 checks passed
@tonisevener tonisevener deleted the prototype/system-nav-bar branch January 17, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants