How do I enable predictive back animation only for back-to-home and disable it between Compose destinations?
Hi everyone!
I'm working on an Android app built with Jetpack Compose and Navigation Compose. With the latest dependencies, the predictive back animation is enabled by default on the NavHost.
What I want
- Enable the predictive back gesture for the back-to-home action (when the user is on the start destination and swipes back to leave the app).
- Disable the predictive back animation when navigating between composable destinations inside the app. (i have a single activity architecture)
What I tried:
I set popEnterTransition and popExitTransition on the NavHost to EnterTransition.None and ExitTransition.None. This works as a baseline, but the problem is that any individual composable() destination that defines its own popEnterTransition or popExitTransition will override the NavHost defaults.
I couldn't find a global switch in Jetpack Compose to disable the in-app predictive back animation while keeping the system-level back-to-home one. It feels like an all-or-nothing setup right now.
My question:
Is there a clean way to opt out of the predictive back animation for in-app navigation only? Some kind of NavHost-level flag, or a different approach I'm missing?
Thanks in advance for any pointers.