Hi guys! Question for those who use Compose Navigation, with the new type safe destinations.
I need to decide on which type of animation to play depending from where the navigation is coming from in my composable destination called DetailDestination.
Let's say, I have:
Copy code
data object ListDestination
data object FormDestination
//Target screen
data object DetailDestination
In case the navigation comes from ListDestination, I want to play a fade animation, and in case it comes from FormDestination, I want to play a slide animation.
Do you know the best way to check from where the navigation is coming from in the enterTransition callback from the composable method?
Copy code
composable<DetailDestination>(
enterTransition = {
if (initialState.destination.route?.contains(ListDestination::class.simpleName)) {
// play fade
} else ....
// play slide
}
)
voliveira
01/24/2025, 12:47 PM
The problem of this approach is that if one day Google changes the way they serialize type safe destination into Strings, that would break this check.