sidpal7747
sidpal7747

Reputation: 21

How to add Transition animation in android jetpack Compose Destination library?

I have started learning Android Jetpack Compose and I come across Compose Destination library which is the best for navigation. But now I am stuck on the navigation transition part where I want to make use of the https://github.com/google/accompanist dependency. Now I want to override the default transition animation which is fade-in and fade-out for enter and exit transition respectively. Here is my code which is not working.

Surface(
            modifier = Modifier.fillMaxSize(),
            color = MaterialTheme.colorScheme.background
        ) {
            val navHostEngine = rememberAnimatedNavHostEngine(
                navHostContentAlignment = Alignment.TopCenter,
                rootDefaultAnimations = RootNavGraphDefaultAnimations.ACCOMPANIST_FADING,
                defaultAnimationsForNestedNavGraph = mapOf(
                    NavGraphs.root to NestedNavGraphDefaultAnimations(
                        enterTransition = { slideInHorizontally() },
                        exitTransition = { slideOutHorizontally() }
                    )
                ))
            DestinationsNavHost(
                navGraph = NavGraphs.root,
                engine = navHostEngine,
                navController = rememberAnimatedNavController()
            )
        }

Can anyone please help me with this?

Upvotes: 1

Views: 1439

Answers (0)

Related Questions