Out of curiosity, will we be able to hook into the...
# compose-android
a
Out of curiosity, will we be able to hook into the predictive back animation system in compose?
s
Not sure exactly what that means, but considering that the androidx.navigation which is for compose does support the predictive back gestures then I suppose the answer is yes? Isn’t it all basically working around the OnBackPressedDispatcher, which you can retrieve in compose using LocalOnBackPressedDispatcherOwner?
a
I mean the animation that you get between activities and Android 14, I know it's already technically supported under the hood
I.e. you can peek behind to the previous activity
s
Yes, but since androidx.navigation for compose already does this atm, I am not sure what you mean by “hook into the predictive back animation system in compose”. It’s probably me misunderstanding you here 🤔
a
See the screenshot above, I was in another screen in settings, but swiping back allows me to peek the previous screen
Are they two separate composables?
i.e. no activities?
s
Gimme a sec to triple check everything so that I am not lying to you 😅 I was in fact lying to you
a
Because this looks exactly like the activity transition 😛
s
Yeah I now remembered that we do still have some pesky activities lying around in this flow in our app, so I may be showing the wrong thing. And that I could be wrong this entire time. Gimme a sec 😵
a
Gotcha, because that transition is what I'd like to see between two composables using any arbitrary navigation library
However, I just realized, we're intercepting the event with the listener
So this might need to be performed manually!
s
I was just very confidently incorrect here ☠️ 🫢 We are using androidx navigation, and I had seen this behavior before in our app, so in my brain I was like yes, it works. But I forgot that that transition was still between activities right now.
i
It was Activity 1.8.0-alpha01 that added Android 14's new progress APIs to
OnBackPressedCallback
instances - that's what allows your app to get the gesture start callback and react to finger movements to do that Predictive animation
There's three bits remaining to be done: 1.
BackHandler
is going to be getting this same ability to get start and progress events, which will mean any composable or navigation library can interact with Predictive Back in-app progress on Android 14+ 2.
AnimatedContent
and friends are going to get new APIs to handle this in between state (e.g., instead of just a
targetState
, it would let you update the
progress
between two states) - this is what you'd actually do with the progress callbacks
BackHandler
gives you 3.
NavHost
will update its
BackHandler
to call the new APIs on
AnimatedContent
, thus giving you predictive back animations based on the transitions you've set for free
a
This is exciting! Thank you for the update Ian!
Glad to hear it gets first class support!
s
What’s the status on some
AnimatedContent
which supports setting a progress too? Is there some issue that we can track, or some work that is already happening atm? Feels like that is the biggest of the pieces missing in this puzzle right?
a
1 and 2 can be achieved from the Activity 1.8 APIs with a bit of work, to a pretty nice effect. This is nothing official though, just me independently experimenting with the APIs:
a
That is awesome 😎😎
Imagine with official API support
i
1 is just convenience at the Activity Compose layer, the underlying layer is indeed already there. And yep, if you pick a different layer than AnimatedContent, the underlying Compose animation APIs can already be driven by gestures
a
I figure as much, but having high level APIs for convenience makes it accessible for everyone, too. I definitely don't mind digging for now, seeing that it is in fact possible!
a
The version of 1 I'm using is here, and part of my implementation of 2 is here
a
Wondering, what is the status of the predictive back gesture with navigation-compose currently?
Seems like this is the tracking ticket: https://issuetracker.google.com/issues/273554698
i
The
SeekableTransitionState
API added to make
AnimatedContent
seekable is currently still experimental API, but that's what we'd be hooking into `PredictiveBackHandler`: https://androiddev.social/@ianlake/110942864725304854
👍 1
👍🏻 1