Does anyone know how can I scroll to the top when ...
# compose
m
Does anyone know how can I scroll to the top when clicking BottomNavBar item again?
m
That's quite not it, I was asking about the BottomNavBar scenario where there is a NavHost in the content. Thanks, though
j
I would check if my currrent route is the same as the one is displayed and then perform a different action
I’m doing something similar here, where I identify if the current route or child route from the actual tab is being displayed, you can check out my repo: https://github.com/JCorderoCamarena/groceryShoppingCart/tree/develop
Copy code
BottomNavigationItem(
    icon = { Icon(screen.icon, contentDescription = null) },
    label = { Text(stringResource(screen.resourceId)) },
    selected = routeInstance?.item == screen.item || routeInstance?.parentRoute == screen.item,
    onClick = {
        navController.navigate(screen.item.route) {
        popUpTo(navController.graph.startDestinationId)
        launchSingleTop = true
        restoreState = true
        }
    }
)