rajesh
08/20/2021, 4:28 PMrajesh
08/20/2021, 4:28 PM@Composable
fun BottomBar(
navController: NavHostController,
items: List<Screens>,
profilePicUrl: String?
) {
BottomNavigation(
modifier = Modifier.height(50.dp),
backgroundColor = MaterialTheme.colors.background,
contentColor = contentColorFor(MaterialTheme.colors.background)
) {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
items.forEach { screen ->
val selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true
val iconRes = if (selected) screen.selectedIcon else screen.icon
BottomNavigationItem(
icon = {
Icon(
painterResource(id = iconRes),
modifier = Modifier.iconSize(),
contentDescription = screen.route
)
},
selected = selected,
onClick = {
navController.navigate(screen.route) {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
},
alwaysShowLabel = false
)
}
}
}
Colton Idle
08/20/2021, 6:36 PMtheapache64
08/21/2021, 10:35 AMNavGraph
?theapache64
08/21/2021, 10:36 AMColton Idle
08/21/2021, 4:45 PMrajesh
08/22/2021, 9:29 AMrajesh
08/22/2021, 9:30 AM