Has anyone else used the accompanist animated navi...
# compose
m
Has anyone else used the accompanist animated navigation? I have the following (along with a rememberAnimatedNavController)
Copy code
AnimatedNavHost(
    navController = navController,
    startDestination = router.currentStep.id,
    exitTransition = { _, _ ->
        slideOutOfContainer(
            AnimatedContentScope.SlideDirection.Left,
            animationSpec = tween(700)
        )
    },
    enterTransition = { _, _ ->
        slideIntoContainer(
            AnimatedContentScope.SlideDirection.Left,
            animationSpec = tween(700)
        )
    })
However, not a single one of my transitions is animated. It all still seems to just pop in and out like it would with the standard NavHost. (as a side note, i’ve tried putting animation specs in the composable function as well for the individual routes with no luck.
i
The standard NavHost doesn't "pop in and out" either - it always crossfades between screens
m
@Ian Lake I’m not really getting any crossfade when using the standard nav controller. it looks like it’s just popping in and out to my eyes
but to be honest, our ux design requires a slide in/out for transitions, so a crossfade wouldn’t help us anyway.
i
Yep, but if it isn't working in NavHost alone, Accompanist Navigation Animation won't fix that - your problem is with a different part of your code
Does it work if you put a simple Button that calls navigate in its onClick?
m
let me set a simpler nav setup
i do see the crossfade with a simple nav graph. I wonder what i could possibly be doing that would be causing that. I do have somewhat of a complicated setup. Due to the nature of what i’m working on, we have a descriptor document that defines the UX flow a series of steps, transitions and string tables (this is shared across platforms). So i’m building the composables in the navcontroller based on the descriptor.
i
I'd focus more on where you are calling
navigate()
, not how you build your graph. Making sure you aren't calling it as part of composition would be the main thing to look at
(Composition should always be side effect free i.e. capable for running hundreds of times over idempotently. Navigating to a new screen is definitely a one time side effect)