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

Top of Stack #29

Closed
notquiteamonad opened this issue Jun 21, 2020 · 5 comments
Closed

Top of Stack #29

notquiteamonad opened this issue Jun 21, 2020 · 5 comments

Comments

@notquiteamonad
Copy link
Contributor

Hi,

I'd find it really useful to know what the top item in the backstack is - I'm using bottom navigation and knowing the top item on the backstack would help in deciding which item at the bottom should be highlighted (even when a few destinations deep in that stack).

Is there a reason this shouldn't be exposed?

@notquiteamonad
Copy link
Contributor Author

I'll put in a PR in case you deem it to be a reasonable thing to do.

@notquiteamonad
Copy link
Contributor Author

Thinking about this I wonder if it'd be better using a name like first or last instead - given the top of the stack is usually the last item. I was thinking more in terms of top-level destination.

@zsoltk
Copy link
Owner

zsoltk commented Jun 21, 2020

Hey @samueldple , I don't think this is the right way to approach it.

The last element should be deciding what you show as "selected". Using the oldest element in the history for what you want makes it purely accidental.

What I think you want (correct me if I'm wrong), is a kind of a hierarchy, where you have top-level navigation destinations (deciding the highlighted menu item), but also screens "deeper" inside them.

In this case you shouldn't map this hierarchy as something flat with only one Router. The idea is to have a nested hierarchy, with as many Routers as levels in this hierarchy, each with their own back stack. This way you can use the last element in the top-level back stack for highlighting menu items. Have a look at app-lifelike which shows this pattern.

PS: I agree naming feels off, "top" should definitely be the most recent element in a stack

@notquiteamonad
Copy link
Contributor Author

Thanks @zsoltk, that sounds reasonable. I'll take a look at app-lifelike

@notquiteamonad
Copy link
Contributor Author

Having taken a look at that it seems like exactly what you want, so I guess this isn't needed.

Feel free to close this and the associated PR if you think they're not needed 😄

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 a pull request may close this issue.

2 participants