Skip to content

Instantly share code, notes, and snippets.

@ifucolo
Created August 22, 2025 12:06
Show Gist options
  • Select an option

  • Save ifucolo/29d3c53b6386d72fee4558080d11a479 to your computer and use it in GitHub Desktop.

Select an option

Save ifucolo/29d3c53b6386d72fee4558080d11a479 to your computer and use it in GitHub Desktop.
@Composable
fun ChapletFlowRouteComponent(
viewModel: ChapletFlowViewModel = koinViewModel(),
chapletName: String,
onClose: () -> Unit
) {
val backStack = viewModel.backStack
LaunchedEffect(Unit) {
viewModel.shouldCloseFlow.collect { shouldClose ->
if (shouldClose) {
onClose()
}
}
}
NavDisplay(
backStack = backStack,
onBack = { onClose() },
entryDecorators = listOf(
rememberSceneSetupNavEntryDecorator(),
rememberSavedStateNavEntryDecorator(),
rememberViewModelStoreNavEntryDecorator()
),
entryProvider = entryProvider {
entry<ChapletRoutes.Start> {
ChapletStartStepScreen(
onPrayStart = {
viewModel.navigateTo(ChapletRoutes.Pray(chapletName = chapletName))
}
)
}
entry<ChapletRoutes.Pray> {
ChapletPrayScreen(
chapletName = it.chapletName,
onClose = onClose,
onFinish = {
viewModel.navigateTo(ChapletRoutes.Feedback)
}
)
}
entry<ChapletRoutes.Feedback> {
ChapletFeedbackScreen(
onFinish = {
viewModel.onChapletDone()
}
)
}
},
transitionSpec = {
slideInHorizontally(initialOffsetX = { it }) togetherWith
slideOutHorizontally(targetOffsetX = { -it })
},
popTransitionSpec = {
slideInHorizontally(initialOffsetX = { -it }) togetherWith
slideOutHorizontally(targetOffsetX = { it })
},
predictivePopTransitionSpec = {
slideInHorizontally(initialOffsetX = { -it }) togetherWith
slideOutHorizontally(targetOffsetX = { it })
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment