sindrenm
11/05/2024, 7:39 PMHideBottomNav()
composable that basically just wraps a DisposableEffect
and sets a global isBottomNavVisible
to true, then false again in onDispose
. This has worked well for us so far, but we were toying with the idea of synchronizing its show/hide animation with the screen transitions from compose-navigation. I was thinking of changing this isBottomNavVisible
property to something more of a visibilityFraction
or something. However, I don't see a way to get the progress of transitioning between screens from the AnimatedContentScope
that composable {}
provides. Am I approaching this the wrong way?Stylianos Gakis
11/05/2024, 7:43 PMStylianos Gakis
11/05/2024, 8:00 PMsindrenm
11/05/2024, 9:12 PMHideBottomNav()
composable effectively wraps a DisposableEffect
, as mentioned above, which updates the config. We could potentially maintain a list of all the routes that should hide the navigation bar, but I still don't see how that would help.
I've looked into getting stuff from the transition
, but it doesn't seem to provide any progress for the transition. I think that might be on purpose, as it doesn't make sense for all transitions specs (spring()
, for instance, comes to mind).sindrenm
11/05/2024, 9:14 PMStylianos Gakis
11/05/2024, 9:17 PMnavController.currentBackStackEntryAsState()
as the source of which screen is on the screen at any given moment. Get that destination and use the public inline fun <reified T : Any> NavDestination.hasRoute() = hasRoute(T::class)
function to check if it's of the type of the routes that are excluded from the permitted list and return true or false depending on it.
Then it's a matter of just using that as the source of truth for what you pass to that global place of showing/not showing as a direct replacement to that composition local.Stylianos Gakis
11/05/2024, 9:18 PMsindrenm
11/05/2024, 9:36 PMStylianos Gakis
11/05/2024, 9:40 PMStylianos Gakis
11/05/2024, 9:41 PMsindrenm
11/05/2024, 9:47 PMsindrenm
11/05/2024, 9:47 PMPredictiveBackHandler
, but it turns out that multiple of those don't necessarily work great together.Stylianos Gakis
11/05/2024, 10:02 PMsindrenm
11/05/2024, 10:18 PMAltynbek Nurtaza
11/07/2024, 8:11 AMfun NavGraphBuilder.myComposable(
route: String,
bottomNavVisible: Boolean = false,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit,
) {
composable(
route = route,
arguments = arguments,
deepLinks = deepLinks,
content = {
val bottomNavigationHost = LocalBottomNavigationHost.current
val targetState = transition.targetState
val currentState = transition.targetState
LaunchedEffect(targetState) {
if (targetState == EnterExitState.Visible || currentState == EnterExitState.PreEnter) {
bottomNavigationHost.setBottomNavVisible(bottomNavVisible)
}
}
content(it)
},
)
}
it kinda solves @Stylianos Gakis’s problem of
> The one thing which is not 100% simple to do atm is that as you got the back gesture seek back to the previous screen, it is not settled yet, so your SOT still says "no, don't need to show it yet".Stylianos Gakis
11/07/2024, 8:30 AMAltynbek Nurtaza
11/07/2024, 4:21 PMAltynbek Nurtaza
11/07/2024, 4:26 PMStylianos Gakis
11/10/2024, 9:30 PM