Open
Description
With the news about shared element transitions coming to compose, naturally a lot of people are going to want to be able to use them in their navigation screens.
As I was trying to get this https://x.com/GakisStylianos/status/1776691881243553937 to work, part of that PR was me having to add this function
private inline fun <reified T : Destination> NavGraphBuilder.animatedComposable(
deepLinks: List<NavDeepLink> = emptyList(),
noinline enterTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
noinline exitTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
noinline popEnterTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
noinline popExitTransition: (@JvmSuppressWildcards AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
noinline content: @Composable AnimatedContentScope.(NavBackStackEntry, T) -> Unit,
) {
val serializer = serializer<T>()
registerDestinationType(T::class, serializer)
composable(
route = createRoutePattern(serializer),
arguments = createNavArguments(serializer),
enterTransition = enterTransition,
exitTransition = exitTransition,
popEnterTransition = popEnterTransition,
popExitTransition = popExitTransition,
deepLinks = deepLinks,
) { navBackStackEntry ->
val t = decodeArguments(serializer, navBackStackEntry)
content(navBackStackEntry, t)
}
}
To basically turn the
noinline content: @Composable T.(NavBackStackEntry) -> Unit,
from the library
into this
noinline content: @Composable AnimatedContentScope.(NavBackStackEntry, T) -> Unit,
To get access to AnimatedContentScope
.
I suspect this will be a common thing that people will want from their nav library, what are your thoughts? Would you want to add this here?
p.s. I know this exists as well #135 and perhaps there won't be much more work done on this library itself, but if you decide to keep it around it's worth considering.
Metadata
Metadata
Assignees
Labels
No labels