@@ -46,6 +46,10 @@ import androidx.navigation.compose.composable
46
46
import androidx.navigation.compose.rememberNavController
47
47
import kotlin.coroutines.cancellation.CancellationException
48
48
import kotlinx.coroutines.flow.Flow
49
+ import kotlinx.serialization.Serializable
50
+
51
+ @Serializable data object Home
52
+ @Serializable data object Settings
49
53
50
54
@Composable
51
55
private fun PredictiveBackOverrideExit (
@@ -56,7 +60,7 @@ private fun PredictiveBackOverrideExit(
56
60
// [START android_compose_predictiveback_navhost]
57
61
NavHost (
58
62
navController = navController,
59
- startDestination = " home " ,
63
+ startDestination = Home ,
60
64
popExitTransition = {
61
65
scaleOut(
62
66
targetScale = 0.9f ,
@@ -70,13 +74,13 @@ private fun PredictiveBackOverrideExit(
70
74
)
71
75
// [END android_compose_predictiveback_navhost]
72
76
{
73
- composable( " home " ) {
77
+ composable< Home > {
74
78
HomeScreen (
75
79
modifier = modifier,
76
80
navController = navController,
77
81
)
78
82
}
79
- composable( " settings " ) {
83
+ composable< Settings > {
80
84
SettingsScreen (
81
85
modifier = modifier,
82
86
navController = navController,
@@ -119,6 +123,7 @@ private fun PredictiveBackHandlerBasicExample() {
119
123
boxScale = 1F - (1F * backEvent.progress)
120
124
}
121
125
// code for completion
126
+ boxScale = 0F
122
127
} catch (e: CancellationException ) {
123
128
// code for cancellation
124
129
boxScale = 1F
0 commit comments