accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[Navigation Animation] Cannot adjust animation when navigating or popBackStack

Open gregnuvo opened this issue 3 years ago • 0 comments

Description navigation command ignores NavOptions

Expected behavior If I execute a command like this

                val navOptions = NavOptions.Builder().apply {
                    setEnterAnim(0)
                    setPopEnterAnim(0)
                    setExitAnim(0)
                    setPopExitAnim(0)
                }.build()
                controller.navigate(route = "oneroute", navOptions = navOptions)

I expect that if my app executes this code, when I navigate to "oneroute" it will animate without animations even though I have defined animations like this.

composable(
            route,
            getArguments(),
            enterTransition = {
                slideInVertically(initialOffsetY = { it })
            },
            exitTransition = {
                slideOutVertically(targetOffsetY = { it })
            },
            popEnterTransition = {
                slideInVertically(initialOffsetY = { it })
            },
            popExitTransition = {
                slideOutVertically(targetOffsetY = { it })
            },
        )

However, it appears that AnimatedComposeNavigator appears to ignore navOptions completely.

    override fun navigate(
        entries: List<NavBackStackEntry>,
        navOptions: NavOptions?,
        navigatorExtras: Extras?
    ) {
        entries.forEach { entry ->
            state.pushWithTransition(entry)
        }
        isPop.value = false
    }

Additional context

Additionally, there is a similar problem when popStack. There isn't a way to adjust animations when executing a popStack command or to disable them. This makes it that when the user pops the navigation stack, the previous view animates into view. This is not always good.

gregnuvo avatar Aug 01 '22 13:08 gregnuvo