-
Notifications
You must be signed in to change notification settings - Fork 0
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
Navigation: Add a way to “pop” the root on iOS #12
Conversation
navigation/ios/Navigation.swift
Outdated
@@ -28,15 +30,17 @@ private struct NavigationModifier<ScreenData, Route: PilotNavigationRoute, Actio | |||
buildView: @escaping (ScreenData) -> ScreenView, | |||
buildNavigation: @escaping ([Route], Route) -> PilotNavigationType<ScreenData, NavModifier>?, | |||
handleAction: ((Action) -> Void)? = nil, | |||
navigationManager: PilotNavigationManager<Route, Action>? = nil | |||
navigationManager: PilotNavigationManager<Route, Action>? = nil, | |||
popRoot: (() -> Void)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nil par defaut missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, this is called internally, so we always pass something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
navigation/ios/NavigationState.swift
Outdated
@@ -23,19 +23,22 @@ class NavigationState< | |||
private let buildNavigation: (([Route], Route) -> PilotNavigationType<ScreenData, NavModifier>?)? | |||
private let navigationManager: PilotNavigationManager<Route, Action>? | |||
private let actionListener: ActionListener<Route, Action> | |||
private let popRoot: (() -> Void)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the behavior, however I'm not sure about the naming, this feels inconsistant with the handleAction
closure. Maybe handlePopRoot
if that is a thing?
On android I would've gone for onRootPopped
and onAction
but whatever feels more natural in the iOS terms is fine with me.
5945997
to
cec7d68
Compare
This functionality becomes necessary when the Pilot navigation stack is not implemented at the app's root level but is instead utilized within a specific app section. Given that the navigation stack might be integrated within a navigation controller or displayed in a modally, the responsibility to close the stack must be transferred to the caller.
To address this requirement, an optional closure named "popRoot" has been introduced at the navigation's entry point, enabling a flexible approach to close the stack.