Created
April 12, 2023 14:03
-
-
Save chientrm/eed9a8e0d0ca5654b684610a3efcf76d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scaffold( | |
snackbarHost = { SnackbarHost(snackbarHostState) }, | |
bottomBar = { | |
NavigationBar { | |
val navBackStackEntry by navController.currentBackStackEntryFlow.collectAsState(null) | |
val currentDestination = navBackStackEntry?.destination | |
NavigationBarItem( | |
selected = currentDestination?.route == Routes.HOME, | |
onClick = { | |
navController.navigate(Routes.HOME) { | |
popUpTo(navController.graph.findStartDestination().id) { | |
saveState = true | |
} | |
launchSingleTop = true | |
restoreState = true | |
} | |
}, | |
label = { Text("Home") }, | |
icon = { | |
Icon( | |
imageVector = if (currentDestination?.route == Routes.HOME) | |
Icons.Filled.Home | |
else Icons.Outlined.Home, | |
contentDescription = "Home Icon", | |
) | |
} | |
) | |
NavigationBarItem( | |
selected = currentDestination?.route == Routes.LIBRARY, | |
onClick = { | |
navController.navigate(Routes.LIBRARY) { | |
popUpTo(navController.graph.findStartDestination().id) { | |
saveState = true | |
} | |
launchSingleTop = true | |
restoreState = true | |
} | |
}, | |
label = { Text("Library") }, | |
icon = { | |
Icon( | |
imageVector = if (currentDestination?.route == Routes.LIBRARY) | |
Icons.Filled.VideoLibrary | |
else Icons.Outlined.VideoLibrary, | |
contentDescription = "Library icon", | |
) | |
} | |
) | |
} | |
} | |
) { it -> | |
NavHost( | |
navController = navController, | |
startDestination = Routes.HOME, | |
Modifier.padding(it), | |
) { | |
composable(Routes.HOME) { | |
HomeTab( | |
onProfile = { dialog = Dialogs.PROFILE }, | |
app = app, | |
play = { playerViewModel.play(it) }, | |
) | |
} | |
composable(Routes.LIBRARY) { | |
LibraryTab( | |
app = app, | |
onProfile = { dialog = Dialogs.PROFILE }, | |
play = { playerViewModel.play(it) }, | |
startDestination = libraryTabStartDestination, | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment