Hi Guys, Whats the best approach for NavGraph wher...
# compose
a
Hi Guys, Whats the best approach for NavGraph where a combination of Persistent TopAppBar and/or BottomNavigationBar but you also need a Full Screen that provide its own TopAppBar/BottomNaivgationBar?
Would it be better to created nested graphs? Like so?
Copy code
// For Full Screen Screens
NavGraph(
   ...
) {
   Scaffold(
       topbar = { ... },
       ...
   ) {
      // For screens with persistent TopBar/BottomBar
      NavGraph(
          ...
      ) {
          ...
      }
   }
}
i
We've never recommended nested NavHosts as a solution to this (you end up with a lot more of a mess when it comes to deep linking, state management, etc); there's been a number of threads if you search or bottom nav about using your source of truth - the current destination of the NavController - to determine what global nav should or should not appear.
a
Thanks @Ian Lake. Are there any official guide or documentation for this matter?
i
In the docs for listening for navigation events, we use showing/hiding your global UI (like a bottom nav) as the example. Of course, everything is easier in the Navigation Compose world, where you get
navController.currentBackStackEntryAsState()
which is how we synchronize the bottom nav with NavController's state
❤️ 1
a
@Ian Lake can I show you an example of a scenario/project where I think this approach doesn't work specially with animation? Or maybe I am just doing it wrong? Would you be open for that?
i
We've specifically talked about timing global navigation animations to run after any animations ran on the content within a screen (and even adding an API specifically to get those type of state changes): https://github.com/google/accompanist/issues/633#issuecomment-942988181
❤️ 1
Until actual shared element support is added (both at the Compose and Navigation layer), there will be types of animations that won't be possible
K 1
a
I see. Thank you very much. This is very informational. Hope we could have Shared Element Transition soon.