Skip to content

Commit

Permalink
update to use type safe routes (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
trambui09 authored Dec 6, 2024
1 parent 0d07b08 commit c79a414
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit c79a414

Please sign in to comment.