Skip to content

Commit

Permalink
Custom navigation controller (#192)
Browse files Browse the repository at this point in the history
* Option to customize UINavigationController

* Fix typo
  • Loading branch information
joemasilotti authored Mar 7, 2024
1 parent 6590418 commit c4ea6f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 6 additions & 0 deletions Source/Turbo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Tests/Turbo Navigator/TurboNavigatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c4ea6f2

Please sign in to comment.