Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom navigation controller #192

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

joemasilotti
Copy link
Member

@joemasilotti joemasilotti commented Mar 7, 2024

This PR provides support to customize the UINavigationController used in Turbo Navigator.

This functionality was originally removed when we introduced TurboNavigationHierarchyController as it is internal to the library.

For context, I need a way to hide the status bar on certain screens. Normally, this would work:

class TurboWebViewController: VisitableViewController {
    override var prefersStatusBarHidden: Bool { true }

    // ...
}

But when presented in a UINavigationController this is ignored. The following change needs to be made to the parent navigation controller to defer this setting to the top view controller:

class NavigationController: UINavigationController {
    override var childForStatusBarHidden: UIViewController? { topViewController }
}

This PR allows me to configure the default navigation controllers, like so:

Turbo.config.defaultNavigationController = { NavigationController() }

@joemasilotti joemasilotti changed the base branch from main to turbo-navigator March 7, 2024 17:37
@zoejessica zoejessica self-requested a review March 7, 2024 19:42
Copy link
Contributor

@zoejessica zoejessica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, it's useful to have this customization point 👍

Source/Turbo.swift Show resolved Hide resolved
@joemasilotti joemasilotti merged commit c4ea6f2 into turbo-navigator Mar 7, 2024
1 check passed
@joemasilotti joemasilotti deleted the custom-navigation-controller branch March 7, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants