Sevban Bayir
05/13/2024, 9:46 AM@Serializable
open class Destination
sealed class ProfileDestination: Destination() {
@Serializable
data object ProfileGraph: ProfileDestination()
@Serializable
data object ProfilePage: ProfileDestination()
}
With this setup im using bottomBar and here is the BottomNavItem:
sealed class BottomNavItem(val route: Destination)
Im trying to show bottom bar only in specific destinations and i was using this before the migration:
@Composable get() = bottomBarItems.any { it.route == currentDestination?.route ?: String.EMPTY }
but now with safe args, this obviously does not work. So is there any suggestions to show bottom bar in specific destinations in new type safe navigation compose ? Thanks in advance
Edit: I tried this and some similar variations but they did not work:
val shouldShowBottomBar: Boolean
@Composable get() =
bottomBarItems.any {
it.route == navController.currentBackStackEntryAsState().value?.toRoute<Destination>()
}
MR3Y
05/13/2024, 12:37 PMNavDestination.hasRoute()
function
https://androiddev.social/@ianlake/112372847606456367
Example of usage:
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigati[…]va/androidx/navigation/compose/demos/BottomBarNavDemo.kt;l=64Sevban Bayir
05/16/2024, 7:31 AM