Are there any plans to support top level destinati...
# compose
Are there any plans to support top level destination transitions in navigation compose? Like having different transition animation when switching between navigation bar destinations and other destinations that are not top level?
Yep that’s totally possible, you can define what animation should exist per composable/navigation in the NavHost as you’re building it. I’m assuming you’re using accompanist navigation here. Both
extensions on
accept enterTransition, exitTransition, popEnterTransition, popExitTransition, where you can specify whatever you want there.
That wont work when using multiple back-stack setup
Why not? What did you try which did not work?
Currently, I'm using default transitions at the NavHost level(slide in, slide out) and I want to use different transitions when switching between navigation bar items(fade in, fade out). So I've provided custom transitions at the destination level of the navigation bar items screens. Suppose you have a multi-stack setup: A, B, C from B you navigate to another composable screen let's call it D from D you navigate to A In this current setup, the transitions that I've provided for the navigation bar items won't get triggered(exit transition)since I'm not at one of the navigation bar desintations. I hope that made sense. One solution would be if there's a way to know from the navController if a user navigated to a different stack but I'm not sure that's possible.
Aha I see yeah. I wonder, in the place where you do this navigation call, if you can pass custom
which specify the animations on that level. And if those would override the nav options set on a per-destination level.
You're approaching the problem backwards - set the animations at the nested graph level (e.g., the
element for bottom nav element A, for bottom nav element B, etc.) for navigating between screens within that graph and have the top level animations you set on the
level control the across bottom nav element transitions. See the example of doing exactly that in the blog post:
Would that work if I setup my project where I have multiple flows that have their own navigation graph? So in this scenario navigating from a bottom navigation item navigation graph to another navigation graph that is not a "bottom navigation element" possible. Is this setup correct? I find it hard to decide weather I should contain a set of screens in their own navigation graph or not