Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to use type safe routes #399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import kotlin.coroutines.cancellation.CancellationException
import kotlinx.coroutines.flow.Flow
import kotlinx.serialization.Serializable

@Serializable data object Home
@Serializable data object Settings

@Composable
private fun PredictiveBackOverrideExit(
Expand All @@ -56,7 +60,7 @@ private fun PredictiveBackOverrideExit(
// [START android_compose_predictiveback_navhost]
NavHost(
navController = navController,
startDestination = "home",
startDestination = Home,
popExitTransition = {
scaleOut(
targetScale = 0.9f,
Expand All @@ -70,13 +74,13 @@ private fun PredictiveBackOverrideExit(
)
// [END android_compose_predictiveback_navhost]
{
composable("home") {
composable<Home> {
HomeScreen(
modifier = modifier,
navController = navController,
)
}
composable("settings") {
composable<Settings> {
SettingsScreen(
modifier = modifier,
navController = navController,
Expand Down Expand Up @@ -119,6 +123,7 @@ private fun PredictiveBackHandlerBasicExample() {
boxScale = 1F - (1F * backEvent.progress)
}
// code for completion
boxScale = 0F
} catch (e: CancellationException) {
// code for cancellation
boxScale = 1F
Expand Down