Skip to content

Instantly share code, notes, and snippets.

@walnashgit
Last active May 6, 2021 08:10
Show Gist options
  • Save walnashgit/867094347c55c1d7d150899a104b38cc to your computer and use it in GitHub Desktop.
Save walnashgit/867094347c55c1d7d150899a104b38cc to your computer and use it in GitHub Desktop.
@Composable
fun BottomBar(modifier: Modifier = Modifier, screens: List<Screens.HomeScreens>, navController: NavController) {
BottomNavigation(modifier = modifier) {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.arguments?.getString(KEY_ROUTE)
screens.forEach { screen ->
BottomNavigationItem(
icon = { Icon(imageVector = screen.icon, contentDescription = "") },
label = { Text(screen.title) },
selected = currentRoute == screen.route,
onClick = {
navController.navigate(screen.route) {
popUpTo = navController.graph.startDestination
launchSingleTop = true
}
}
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment