alexhelder
02/28/2025, 1:56 PMJetSnackNavController
)
fun navigateToBottomBarRoute(route: String) {
if (route != navController.currentDestination?.route)
The goal is to prevent the user from pressing the same top level Route over and over, which based on the typical Bottom Nav code I see, causes the `compose`<> block to rerun, viewmodels to be recreated, etc.escodro
02/28/2025, 2:01 PMhasRoute()
API, which is very useful for comparing the typesafe with the BackStackEntry. Something like:
navHostController.currentBackStackEntry?.destination?.hasRoute(route::class) == true
https://github.com/igorescodro/alkaa/blob/a9023a1006156c298eaedaebb13e333356c3cc8b[…]/commonMain/kotlin/com/escodro/navigation/compose/Navigation.ktalexhelder
02/28/2025, 2:04 PMhasRoute
, but could not figure out how I would use it with multiple routes using the same class (different default args). I probably should not do that