1

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?

sidpal7747
  • 21
  • 7
  • I haven't used the library but have you checked the Animated style in their docs? https://composedestinations.rafaelcosta.xyz/styles-and-animations/#animated-style – Eliza Camber Jul 03 '23 at 12:01
  • @ElizaCamber I did already as I got the above snippet from there itself. – sidpal7747 Jul 03 '23 at 12:12

0 Answers0