Hey. Any good options/recommendations for not show...
# compose
v
Hey. Any good options/recommendations for not showing Apps Bottom Navigation on some screens? I have an app with main based on Bottom Nav. But sometimes by the desings, when we go into deeper screens we want to hide the nav bar to free the space. In theory I see the options: • To define a state somewhere in main aka show: Boolean, subscribe the bottom nav to the state and change its size to 0 when false. Then to figure out how exactly and properly and easily to change state to true on those screens and to false when we leave them. A lil hussle but will work. • Dialog with fillMaxSize(). Not sure if that is shot into the foot at a long run. Likely will be issues with the status bar colors and insets • ScaffoldBottomSheet, haven't even checked that yet
p
I like the first approach. You could define something like
Copy code
interface GlobalNavigationHandler {
  fun showControllers ()
  fun hideControllers ()
  ...
}
You pick the name. Then drill it down to Composables using a GlobalNavivationHandlerCompositionLocalProvider.
Same interface can work for a NavigationDrawer or a FloatingMenuButton
v
The main question for the first approach - when exactly to call show/hide
🤔 1
p
I would say when the Composable which occupy the full screen is fully displayed. You can use LaunchEffect for this although we know LaunchEffect doesn't necessarily means is visible 100% of the times
v
In a DisposableEffect(onStart -> show, onDispose -> hide)? Will it always work if one screen opens previous hides and so on
👍 1
But how do you return back to show, when you click Back button in that composable?
p
Interesting, the disposable effect seems to help here. I would say yes, just as you described
🤔 1
j
I use Circuit navigation https://slackhq.github.io/circuit/navigation/ which holds reference to backstack. In backstack each screen has interface method say if root or not. If not root I hide navigation (drawer, rail or bottom based on window classes). Using AnimatedVisibility for bottom nav. I dont like using Scaffold in root level as to messy with insets, top bar, up navigation etc. Also circuit provides a overlay that can be used for dialogs, bottomsheet etc.
p
Interesting, I know circuit is really good. But I think using a plain interface like RootNavigatorController or whatever the name is a bit more general. Perhaps you want to keep you bottom bar a bit more than the first navigation deep level
j
Yes I do use my own navigation interface around Circuit navigator and provide my own Local composition so can use anywhere. No issue having multiple screens using bottom nav bar but animation wise imo looks better have it in one root level.
👍 1