Skip to content

Instantly share code, notes, and snippets.

@VitalyPeryatin
Created July 6, 2022 19:57
Show Gist options
  • Save VitalyPeryatin/aa8e6ea5954a7a6e3d8d715d28c9b5c4 to your computer and use it in GitHub Desktop.
Save VitalyPeryatin/aa8e6ea5954a7a6e3d8d715d28c9b5c4 to your computer and use it in GitHub Desktop.
val sharedViewModelHolder = SharedViewModelHolder<PostCreateViewModel>()
navGraphBuilder.navigation(
route = PostCreateDestination.RootCreatePostRoute,
startDestination = PostCreateDestination.SelectCreatablePost.createRoute()
) {
composable(PostCreateDestination.SelectCreatablePost) {
SelectCreatablePostScreen(
modifier = modifier,
navController = navController,
sharedViewModel = sharedViewModelHolder.createNewSharedViewModel()
)
}
composable(PostCreateDestination.CreatePost) { navBackStackEntry ->
val arguments: PostCreateDestination.CreatePost.Arguments =
PostCreateDestination.CreatePost.rememberArguments(navBackStackEntry)
PostCreateScreen(
modifier = modifier,
navController = navController,
sharedViewModel = sharedViewModelHolder.getSharedViewModel(),
type = arguments.nonNullablePostType
)
}
composable(PostCreateDestination.ChooseSpace) {
ChooseSpaceScreen(
modifier = modifier,
navController = navController,
sharedViewModel = sharedViewModelHolder.getSharedViewModel()
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment