[Idea] [Navigation Animation] Animations between destinations with and without Scaffold
See original GitHub issueIn general, it is advised to only use a single (Animated)NavHost
. However, as of now, nice transitions between screens with Scaffold
and screens without Scaffold
are not possible with a single NavHost
. Consider this example:
https://user-images.githubusercontent.com/6752601/133760459-819151c3-bd23-4785-9124-699be273dbbc.mp4
I need to wrap the NavHost
for the two bottom bar destinations in a common Scaffold
to properly animate the BottomBar
. With this configuration, the transition to the image screen above the bottom bar (in z-direction) is only possible by adding a second NavHost
, which contains the image screen and the main NavHost
.
I see two options here:
- Make it possible to lay out some
NavHost
destinations above the top and bottom bar of theScaffold
. I don’t think this is currently possible in Compose, so this might be very difficult to implement. - Add a
NavGraphBuilder
function which adds wrapping composables to certain destinations. In this case, both bottom bar destinations would be wrapped in such a function, which would add theScaffold
to these screens.
Probably, there are more options. Personally, I would favor the second option. I know, this is not really in scope of Accompanist, but since Accompanist Navigation currently contains the next-gen NavHost
implementation, I wanted to start here.
What are your opinions on this?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:6
FWIW, we’ll be continuing to look at this as part of the explorations into shared elements (part of the Jetpack Compose Roadmap and their integration into Navigation, which would be the mechanism you’d want to use share an element across multiple (but perhaps not all) screens.
That kind of solution would still only use a single
NavHost
though.By the way, a bare-bones implementation of the second approach: https://github.com/fschuetz04/compose-navigation-test.