According to the Android Developer docs it is possible to implement custom animations for the predictive back gesture. I got it to work on an example similar to the one they present in their docs with the Transition APIs.
However, I would like to implement a similar gradular transition based on the back progress for the navigation component in Jetpack Compose.
How would I do so? I can't find any documentation on being able to control the progress of the transition between different navigation destinations.
Here's an example of my NavHost
:
NavHost(navController = pageNavController!!, startDestination = "home"){
composable(
route = "home",
enterTransition = {
navEnterTransition(
direction = DIRECTION_LEFT,
orientation = orientation) },
exitTransition = {
navExitTransition(
direction = DIRECTION_LEFT,
orientation = orientation) },
content = { HomePage() }
)
composable(
route = "settings",
enterTransition = { navEnterTransition(
direction = getNavEnterDirection(initialState.destination),
orientation = orientation) },
exitTransition = { navExitTransition(
direction = getNavExitDirection(initialState.destination),
orientation = orientation) },
content = { SettingsPage() }
)
}
Is there a way to implement the custom predictive back gestures with this navigation approach?
If not, are there other approaches that might work?
Edit
As ianhanniballake pointed out, this is not supported yet.
However, I was able to somewhat get it to work using the Pager and some complicated custom navigation and modifiers. This worked and incorporated the predictive back gesture but was very unstable and had some bugs so I decided against and I will just wait for official support.