Correct the RTL animation for AnimatedNavHost

Use Start & End to make sure this is also correct for RTL.

Also import changes from Accompanist.

Bug: 236346018
Test: Manually with Settings
Change-Id: I8ccfd685d6efdb517b4f50845bbec058d76b1636
This commit is contained in:
Chaohui Wang
2023-02-10 18:00:07 +08:00
parent cce2be380b
commit bb5bcefa95
2 changed files with 5 additions and 9 deletions

View File

@@ -119,22 +119,22 @@ private fun NavControllerWrapperImpl.NavContent(allProvider: Collection<Settings
arguments = spp.parameter,
enterTransition = {
slideIntoContainer(
AnimatedContentScope.SlideDirection.Left, animationSpec = slideEffect
AnimatedContentScope.SlideDirection.Start, animationSpec = slideEffect
) + fadeIn(animationSpec = fadeEffect)
},
exitTransition = {
slideOutOfContainer(
AnimatedContentScope.SlideDirection.Left, animationSpec = slideEffect
AnimatedContentScope.SlideDirection.Start, animationSpec = slideEffect
) + fadeOut(animationSpec = fadeEffect)
},
popEnterTransition = {
slideIntoContainer(
AnimatedContentScope.SlideDirection.Right, animationSpec = slideEffect
AnimatedContentScope.SlideDirection.End, animationSpec = slideEffect
) + fadeIn(animationSpec = fadeEffect)
},
popExitTransition = {
slideOutOfContainer(
AnimatedContentScope.SlideDirection.Right, animationSpec = slideEffect
AnimatedContentScope.SlideDirection.End, animationSpec = slideEffect
) + fadeOut(animationSpec = fadeEffect)
},
) { navBackStackEntry ->

View File

@@ -201,11 +201,7 @@ public fun AnimatedNavHost(
transition.AnimatedContent(
modifier,
transitionSpec = {
val zIndex = if (composeNavigator.isPop.value) {
visibleEntries.indexOf(initialState).toFloat()
} else {
visibleEntries.indexOf(targetState).toFloat()
}
val zIndex = composeNavigator.backStack.value.size.toFloat()
// If the initialState of the AnimatedContent is not in visibleEntries, we are in
// a case where visible has cleared the old state for some reason, so instead of
// attempting to animate away from the initialState, we skip the animation.