Repository: google/accompanist

Issue #729: [Idea] [Navigation Animation] Animations between destinations with and without Scaffold
Created: 2021-09-17T09:36:27Z
In 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:

  
    
    

    navigation-transition.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 the Scaffold. 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 the Scaffold 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?

Duplicate issue #633: [Navigation Animation] Allow observing of navigation transition state
Created: 2021-08-09T18:33:11Z
Is your feature request related to a problem? Please describe.
My root composable is a Scaffold which only shows top/bottom bars for the Bottom Navigation screens. Other screens have their own Scaffolds. The problem is, when I navigate with a slide-in animation from my bottom nav screens, the top/bottom bars of the root Scaffold are hidden before the slide in transition completes (because I'm observing the current screen in my root Scaffold and showing the top/bottom bars only if it's a bottom nav screen). This gives a bad UX and I'd like to keep the bars until the transition to the new screen completes.
// Common scaffold for Bottom Nav Screens
Scaffold(
    topBar = { if(currentScreen is BottomNavScreen) TopAppBar(...) },
    bottomBar = { if(currentScreen is BottomNavScreen) BottomNavigation(...) }
) {
    AnimatedNavHost() {
        // Bottom Nav Screens
        navigation(route = Main.route, startDestination = BottomNavScreen.Home.route) {
            composable(BottomNavScreen.Home.route) { HomeScreen() }
            composable(...) { ... }
            composable(...) { ... }
        }

        composable(Search.route, enterTransition = { slideInVertically() }, exitTransition = { slideOutVertically() }) {
            // Search Screen
            Scaffold(...) { ... }
        }
    }
}

Describe the solution you'd like
It'd be great if we can observe the nav transition state to hide the bars when the transition finishes, as suggested here https://kotlinlang.slack.com/archives/CJLTWPH7S/p1628271130295600?thread_ts=1628263708.267200&cid=CJLTWPH7S

Closing comment (2021-11-16T06:57:50Z): @nthily - your use case is a separate issue, perhaps more related to #729 in that you're trying to build a shared element that doesn't animate when you transition between certain screens but is treated as part of the content and its transition when moving to another screen.
This issue is specifically for "Allow observing of navigation transition state", which is what visibleEntries give you - a state change once a destination starts animating and again when it ends animating.