admin管理员组文章数量:1129156
I'm using Jetpack Compose's enterTransition to animate navigation between screens. The transition works fine in authGraph (you can find its structure on homeGraph below. It is the same.), but it doesn't apply when navigating to the ChatScreen in the homeGraph. Why isn't the enterTransition applied to the ChatScreen in the homeGraph?
I tried that the enterTransition works for other screens in a different graph. There is normally multiple ways to call ChatRoute with arguments but I tried to remove all the arguments if the problem is about serialization but still didn't work. Removed current transition to just use fadeIn() but didn't work.
The NavHost that manages multiple graphs:
@Composable
fun AppNavHost(appState: MedicineAIAppState, startDestination: String) {
val navController = appState.navController
NavHost(
navController = navController,
startDestination = startDestination.toKClassRoute(),
) {
onboardingGraph(navController)
authGraph(navController)
homeGraph(navController)
}
}
HomeGraph includes the ChatScreen, which is the screen where the transition doesn't work. Also AuthGraph has the same structure with this and same navigation works there.
@Serializable data object HomeGraph
fun NavGraphBuilder.homeGraph(navController: NavHostController) {
navigation<HomeGraph>(startDestination = HomeRoute) {
homeScreen(onStartChatClick = navController::navigateToChatWithoutInbox)
inboxScreen(
onNewChatClick = navController::navigateToChatWithEmpty,
onChatClick = navController::navigateToChatWithInboxAndTopic
)
chatScreen(
onBackClick = navController::popBackStack,
onChatCleared = navController::navigateToInbox
)
profileScreen()
}
}
This is the ChatScreen definition with the enterTransition:
fun NavGraphBuilder.chatScreen(
onBackClick: () -> Unit,
onChatCleared: () -> Unit
) {
composable<ChatRoute>(
enterTransition = {
fadeIn(
animationSpec = tween(300, easing = LinearEasing)
) + slideIntoContainer(
animationSpec = tween(300, easing = EaseIn),
towards = AnimatedContentTransitionScope.SlideDirection.Start
)
},
) {
ChatScreen(
onBackClick = onBackClick,
onChatCleared = onChatCleared
)
}
}
本文标签: androidCompose Navigation Doesn39t Apply the enterTransition AnimationStack Overflow
版权声明:本文标题:android - Compose Navigation Doesn't Apply the enterTransition Animation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736713917a1949092.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论