Hi guys, I'm trying to add some animations to my s...
# compose
i
Hi guys, I'm trying to add some animations to my screens, I'm using Compose Destinations Animations. However in my case I'm using a
DestinationsNavHost
instead of a
NavHost
and all the examples I've seen are with a
NavHost
where you can easily add animations in each composable. The only example I saw with
DestinationsNavHost
is this.
Copy code
val navHostEngine = rememberAnimatedNavHostEngine(
    navHostContentAlignment = Alignment.TopCenter,
    rootDefaultAnimations = RootNavGraphDefaultAnimations.ACCOMPANIST_FADING, //default `rootDefaultAnimations` means no animations
    defaultAnimationsForNestedNavGraph = mapOf(
        NavGraphs.settings to NestedNavGraphDefaultAnimations(
            enterTransition = { fadeIn(animationSpec = tween(2000)) },
            exitTransition = { fadeOut(animationSpec = tween(2000)) }
        ),
        NavGraphs.otherNestedGraph to NestedNavGraphDefaultAnimations.ACCOMPANIST_FADING
    ) // all other nav graphs not specified in this map, will get their animations from the `rootDefaultAnimations` above.
)
But I'm a bit confused. I'm guessing
NavGraphs.settings
and
NavGraphs.otherNestedGraph
are the NestedGraphs that will have the animation applied to them. That's exactly what I wanna do. I have a NestedGraph that I wanna apply those animations to but it can't find it when I'm calling it there. What am I doing wrong?
1