Hi everybody! I'm using jetpack compose navigation...
# compose-android
p
Hi everybody! I'm using jetpack compose navigation. I set up a navigation bar with a navigation graph with multiple back stacks and also show the navigation bar when I'm in a detail screen. Now, when the user is in a detail screen and taps on the active bottom tab again, the app shall navigate to the top-level destination of that tab stack.
1
With the non-compose jetpack navigation lib this was easy to setup - maybe it even was the default behavior. With compose navigation I can't get it to work. I also posted a question on SO with a code sample and a link to a minimal project on GitHub. Did anyone run into the same problem? Is there are flaw with the idea itself?
s
What if you check on the lambda, if you're currently already in a destination which has your top level destination on the hierarchy, do popUpTo(the top level destination, inclusive = false) without saving state here (since you're clearing all of the things deeper in the backstack anyway. If that top level destination isn't in the hierarchy, do what you were doing already
p
Hi @Stylianos Gakis! That was my idea but I had implementation issues. Thanks to your reply I revisit the code and could fix the errors 🙇 I updated the GitHub project with the working state.