Skip to content

Instantly share code, notes, and snippets.

@kasem-sm
Created February 8, 2022 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasem-sm/d0ee9e6e7e6c698e26c56e6187f79a4f to your computer and use it in GitHub Desktop.
Save kasem-sm/d0ee9e6e7e6c698e26c56e6187f79a4f to your computer and use it in GitHub Desktop.
Navigation Overview
@Composable
internal fun SlimeBottomBar(
navController: NavController,
items: List<BottomNavigationItems>,
) {
Column {
val currentRoute = navController.currentRouteAsState()
NavigationBar {
items.forEach { item ->
NavigationBarItem(
icon = {
Icon(
painter = painterResource(id = item.icon),
modifier = Modifier.size(22.dp),
contentDescription = item.title,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
},
selected = currentRoute == item.route,
onClick = {
if (navController.currentDestination?.route != item.route) {
navController.navigate(item.route) {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
}
}
)
}
}
}
}
AnimatedNavHost(
modifier = modifier,
navController = navController,
startDestination = ProfileScreen.route,
route = MainRoute.route,
) {
attachSignUpScreen(navController)
}
internal fun NavGraphBuilder.attachSignUpScreen(
navController: NavController,
) {
composable(Routes.RegisterScreen.route) {
RegisterScreen(
viewModel = hiltViewModel(),
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment