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

Add Navigator.navigateSingleTop extension function #180

Closed
arkivanov opened this issue Jul 14, 2021 · 3 comments · Fixed by #208
Closed

Add Navigator.navigateSingleTop extension function #180

arkivanov opened this issue Jul 14, 2021 · 3 comments · Fixed by #208
Labels
enhancement New feature or request

Comments

@arkivanov
Copy link
Contributor

See the discussion where it came from.

@arkivanov arkivanov added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jul 14, 2021
@arkivanov arkivanov removed help wanted Extra attention is needed good first issue Good for newcomers labels Aug 8, 2021
@arkivanov
Copy link
Contributor Author

arkivanov commented Aug 8, 2021

The name navigateSingleTop is misleading in this context, as it has different semantics in Android. We should find a better name. This function should work in the following way:

  • If there is already a component in the stack with configuration of type T, then that component should be moved to top of the stack.
  • Otherwise a new component should be created and pushed to the stack.

Some possible names: reorderToFront, makeOnTop, activate, activateOrPush, bringToFrontOrPush

@aartikov
Copy link

aartikov commented Aug 28, 2021

@arkivanov
stack.filterNot { it::class == configuration::class } + configuration

Maybe it would be better to compare values rather than classes?
Otherwise, we can't use enums for bottom navigation items.

@arkivanov
Copy link
Contributor Author

@aartikov as per my comment above, this function is to ensure there is only one type of component in the stack, and to bring it to front. I suggest to use sealed classes instead of enums, or just use navigate(...) directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants