From f2485f0ba116b3a03169051dce96f34fa01d7f41 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 6 Sep 2023 13:27:42 -0400 Subject: [PATCH] Add feature flag for browser-style navigation --- .../Sources/TuskerPreferences/Preferences.swift | 1 + Tusker/Screens/Main/MainTabBarViewController.swift | 1 - .../Utilities/EnhancedNavigationViewController.swift | 8 +++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Packages/TuskerPreferences/Sources/TuskerPreferences/Preferences.swift b/Packages/TuskerPreferences/Sources/TuskerPreferences/Preferences.swift index 9e68232d..fe8422b9 100644 --- a/Packages/TuskerPreferences/Sources/TuskerPreferences/Preferences.swift +++ b/Packages/TuskerPreferences/Sources/TuskerPreferences/Preferences.swift @@ -431,6 +431,7 @@ extension Preferences { extension Preferences { public enum FeatureFlag: String, Codable { case iPadMultiColumn = "ipad-multi-column" + case iPadBrowserNavigation = "ipad-browser-navigation" } } diff --git a/Tusker/Screens/Main/MainTabBarViewController.swift b/Tusker/Screens/Main/MainTabBarViewController.swift index fde598c3..3cb9186d 100644 --- a/Tusker/Screens/Main/MainTabBarViewController.swift +++ b/Tusker/Screens/Main/MainTabBarViewController.swift @@ -180,7 +180,6 @@ class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate { return vc } else { let nav = EnhancedNavigationViewController(rootViewController: vc) -// nav.useBrowserStyleNavigation = true return nav } } diff --git a/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift b/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift index bfe74313..752f0867 100644 --- a/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift +++ b/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift @@ -10,7 +10,7 @@ import UIKit class EnhancedNavigationViewController: UINavigationController { - var useBrowserStyleNavigation = false + let useBrowserStyleNavigation = Preferences.shared.hasFeatureFlag(.iPadBrowserNavigation) var poppedViewControllers = [UIViewController]() var skipResetPoppedOnNextPush = false @@ -20,7 +20,8 @@ class EnhancedNavigationViewController: UINavigationController { override var viewControllers: [UIViewController] { didSet { poppedViewControllers = [] - if #available(iOS 16.0, *) { + if #available(iOS 16.0, *), + useBrowserStyleNavigation { // TODO: this for loop might not be necessary for vc in viewControllers { configureNavItem(vc.navigationItem) @@ -36,6 +37,7 @@ class EnhancedNavigationViewController: UINavigationController { self.interactivePushTransition = InteractivePushTransition(navigationController: self) if #available(iOS 16.0, *), + useBrowserStyleNavigation, let topViewController { configureNavItem(topViewController.navigationItem) updateTopNavItemState() @@ -124,7 +126,7 @@ class EnhancedNavigationViewController: UINavigationController { } } // 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: { pushViewController(target, animated: true) }, after: {