Skip to content

Instantly share code, notes, and snippets.

@saqib-github-commits
Created August 21, 2023 07:25
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 saqib-github-commits/b93eb0ad54d89d6b2e4f4b891238e9e3 to your computer and use it in GitHub Desktop.
Save saqib-github-commits/b93eb0ad54d89d6b2e4f4b891238e9e3 to your computer and use it in GitHub Desktop.
@Composable
fun MainNavigation(
navController: NavHostController = rememberNavController(),
coroutineScope: CoroutineScope = rememberCoroutineScope(),
drawerState: DrawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
) {
ModalNavigationDrawer(
drawerState = drawerState,
drawerContent = {
ModalDrawerSheet {
DrawerContent(menus) { route ->
coroutineScope.launch {
drawerState.close()
}
navController.navigate(route)
}
}
}
) {
NavHost(navController = navController, startDestination = MainRoute.Articles.name) {
composable(MainRoute.Articles.name) {
ArticlesScreen(drawerState)
}
composable(MainRoute.About.name) {
AboutScreen(drawerState)
}
composable(MainRoute.Settings.name) {
SettingsScreen(drawerState)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment