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

Navigation: Add a way to “pop” the root on iOS #12

Merged
merged 1 commit into from
May 13, 2024

Conversation

hugolefrancois
Copy link
Contributor

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.

@@ -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)?

Choose a reason for hiding this comment

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

nil par defaut missing?

Copy link
Contributor Author

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.

Copy link
Contributor

@sdetilly sdetilly left a comment

Choose a reason for hiding this comment

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

👏

@@ -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)?
Copy link
Member

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.

@hugolefrancois hugolefrancois force-pushed the feature/root_pop_ios branch from 5945997 to cec7d68 Compare May 13, 2024 20:31
@hugolefrancois hugolefrancois merged commit 838b45d into main May 13, 2024
1 check passed
@hugolefrancois hugolefrancois deleted the feature/root_pop_ios branch May 13, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants