Background Information: Apps Debt
Our approach to navigation in the codebase is inconsistent and can be sourced from multiple different areas. We need to clean this up and ensure all navigation from within the app and via deep links happens via the same pattern, and that this path is heavily unit tested. We should also document supported deep links while we are here.
This work will pave the way for a smoother navigation restructuring that we plan to do later this year.
Our navigation approach occurs primarily in two different ways:
- Calling the standard navigationController?.pushViewController(viewController, animated:) and present(viewController, animated:) methods from the view controller we are navigating away from. This is what we want to move away from. It prevents us from easily reusing view controllers in other features.
- Creating an NSUserActivity. These activities are sometimes created directly or by calling the view controller extension navigate(to: URL), which in in turn fires an NSNotification that carries an NSUserActivity. That notification is picked up by the WMFAppController, where it either push/presents a view controller or sends it along further to the ViewControllerRouter, where it push/presents a view controller. The app also handles application deep links via NSUserActivity.
We should evaluate how the app is utilizing NSUserActivities for spotlight, state restoration, and handoff, and ensure they are only used (and used correctly) in those cases. Any unrelated navigation work should be implemented with an alternative method, like Coordinators.
- Spike: Get a better handle on navigation patterns (Coordinators, anything else?), as well as where NSUserActivities for spotlight, state restoration, and handoff may fit into these patterns.
- Prototype two flows in the app using the chosen navigation pattern: (1) On Explore feed, tapping "All top read articles", then tapping an article. (2) Deep linking from Safari to a particular article.
- Add unit tests for the prototype flows. We will not add any more until navigation work is restructured later in the year.
- Implement the prototype pattern everywhere in the app. Handle navigation occurring within:
- Explore Feed
- Places
- Saved
- History
- Search
- Settings
- Article
- Notifications Center
- Talk pages
- Editor Flow
- Panels.swift modals
- WMFAlertManager buttons
- Navigation State restoration (as of this time, this should only restore their last read article rather than their entire navigation stack)
- Update Deep Link documentation (T251929)