Add feature flag for browser-style navigation

This commit is contained in:
Shadowfacts 2023-09-06 13:27:42 -04:00
parent 75caf2c1eb
commit f2485f0ba1
3 changed files with 6 additions and 4 deletions

View File

@ -431,6 +431,7 @@ extension Preferences {
extension Preferences { extension Preferences {
public enum FeatureFlag: String, Codable { public enum FeatureFlag: String, Codable {
case iPadMultiColumn = "ipad-multi-column" case iPadMultiColumn = "ipad-multi-column"
case iPadBrowserNavigation = "ipad-browser-navigation"
} }
} }

View File

@ -180,7 +180,6 @@ class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {
return vc return vc
} else { } else {
let nav = EnhancedNavigationViewController(rootViewController: vc) let nav = EnhancedNavigationViewController(rootViewController: vc)
// nav.useBrowserStyleNavigation = true
return nav return nav
} }
} }

View File

@ -10,7 +10,7 @@ import UIKit
class EnhancedNavigationViewController: UINavigationController { class EnhancedNavigationViewController: UINavigationController {
var useBrowserStyleNavigation = false let useBrowserStyleNavigation = Preferences.shared.hasFeatureFlag(.iPadBrowserNavigation)
var poppedViewControllers = [UIViewController]() var poppedViewControllers = [UIViewController]()
var skipResetPoppedOnNextPush = false var skipResetPoppedOnNextPush = false
@ -20,7 +20,8 @@ class EnhancedNavigationViewController: UINavigationController {
override var viewControllers: [UIViewController] { override var viewControllers: [UIViewController] {
didSet { didSet {
poppedViewControllers = [] poppedViewControllers = []
if #available(iOS 16.0, *) { if #available(iOS 16.0, *),
useBrowserStyleNavigation {
// TODO: this for loop might not be necessary // TODO: this for loop might not be necessary
for vc in viewControllers { for vc in viewControllers {
configureNavItem(vc.navigationItem) configureNavItem(vc.navigationItem)
@ -36,6 +37,7 @@ class EnhancedNavigationViewController: UINavigationController {
self.interactivePushTransition = InteractivePushTransition(navigationController: self) self.interactivePushTransition = InteractivePushTransition(navigationController: self)
if #available(iOS 16.0, *), if #available(iOS 16.0, *),
useBrowserStyleNavigation,
let topViewController { let topViewController {
configureNavItem(topViewController.navigationItem) configureNavItem(topViewController.navigationItem)
updateTopNavItemState() updateTopNavItemState()
@ -124,7 +126,7 @@ class EnhancedNavigationViewController: UINavigationController {
} }
} }
// match the system behavior when popping multiple by animated-ly pushing the final destination one, // match the system behavior when popping multiple by animated-ly pushing the final destination one,
// and then intersiting the intermediary ones before it, as if they'd all been pushed together // and then inserting the intermediary ones before it, as if they'd all been pushed together
performAfterAnimating(block: { performAfterAnimating(block: {
pushViewController(target, animated: true) pushViewController(target, animated: true)
}, after: { }, after: {