diff --git a/Source/Turbo Navigator/TurboNavigationHierarchyController.swift b/Source/Turbo Navigator/TurboNavigationHierarchyController.swift index 093ddcc..cbc5afb 100644 --- a/Source/Turbo Navigator/TurboNavigationHierarchyController.swift +++ b/Source/Turbo Navigator/TurboNavigationHierarchyController.swift @@ -23,9 +23,13 @@ class TurboNavigationHierarchyController { } } - init(delegate: TurboNavigationHierarchyControllerDelegate, navigationControler: UINavigationController = UINavigationController(), modalNavigationController: UINavigationController = UINavigationController()) { + init( + delegate: TurboNavigationHierarchyControllerDelegate, + navigationController: UINavigationController = Turbo.config.defaultNavigationController(), + modalNavigationController: UINavigationController = Turbo.config.defaultNavigationController() + ) { self.delegate = delegate - self.navigationController = navigationControler + self.navigationController = navigationController self.modalNavigationController = modalNavigationController } diff --git a/Source/Turbo.swift b/Source/Turbo.swift index 62e0f4b..25398a9 100644 --- a/Source/Turbo.swift +++ b/Source/Turbo.swift @@ -17,6 +17,12 @@ public class TurboConfig { VisitableViewController(url: url) } + /// The navigation controller used in `TurboNavigator` for the main and modal stacks. + /// Must be a `UINavigationController` or subclass. + public var defaultNavigationController: () -> UINavigationController = { + UINavigationController() + } + /// Optionally customize the web views used by each Turbo Session. /// Ensure you return a new instance each time. public var makeCustomWebView: WebViewBlock = { (configuration: WKWebViewConfiguration) in diff --git a/Tests/Turbo Navigator/TurboNavigatorTests.swift b/Tests/Turbo Navigator/TurboNavigatorTests.swift index 6f3e6ea..3a51a54 100644 --- a/Tests/Turbo Navigator/TurboNavigatorTests.swift +++ b/Tests/Turbo Navigator/TurboNavigatorTests.swift @@ -11,7 +11,7 @@ final class TurboNavigationHierarchyControllerTests: XCTestCase { modalNavigationController = TestableNavigationController() navigator = TurboNavigator(session: session, modalSession: modalSession) - hierarchyController = TurboNavigationHierarchyController(delegate: navigator, navigationControler: navigationController, modalNavigationController: modalNavigationController) + hierarchyController = TurboNavigationHierarchyController(delegate: navigator, navigationController: navigationController, modalNavigationController: modalNavigationController) navigator.hierarchyController = hierarchyController loadNavigationControllerInWindow()