diff --git a/app/src/main/java/li/songe/gkd/util/ProfileTransitions.kt b/app/src/main/java/li/songe/gkd/util/ProfileTransitions.kt index b9723e0ea..8860743c3 100644 --- a/app/src/main/java/li/songe/gkd/util/ProfileTransitions.kt +++ b/app/src/main/java/li/songe/gkd/util/ProfileTransitions.kt @@ -4,26 +4,37 @@ import androidx.compose.animation.AnimatedContentTransitionScope import androidx.compose.animation.EnterTransition import androidx.compose.animation.ExitTransition import androidx.compose.animation.core.tween -import androidx.compose.animation.fadeOut import androidx.compose.animation.slideInHorizontally import androidx.compose.animation.slideOutHorizontally import androidx.navigation.NavBackStackEntry +import com.blankj.utilcode.util.ScreenUtils import com.ramcosta.composedestinations.spec.DestinationStyle object ProfileTransitions : DestinationStyle.Animated { + private const val durationMillis = 400 override fun AnimatedContentTransitionScope.enterTransition(): EnterTransition? { - return slideInHorizontally(tween()) { it } + return slideInHorizontally( + initialOffsetX = { ScreenUtils.getScreenWidth() }, animationSpec = tween(durationMillis) + ) } override fun AnimatedContentTransitionScope.exitTransition(): ExitTransition? { - return slideOutHorizontally(tween()) { -it } + fadeOut(tween()) + return slideOutHorizontally( + targetOffsetX = { -ScreenUtils.getScreenWidth() / 2 }, + animationSpec = tween(durationMillis) + ) } override fun AnimatedContentTransitionScope.popEnterTransition(): EnterTransition? { - return slideInHorizontally(tween()) { -it } + return slideInHorizontally( + initialOffsetX = { -ScreenUtils.getScreenWidth() / 2 }, + animationSpec = tween(durationMillis) + ) } override fun AnimatedContentTransitionScope.popExitTransition(): ExitTransition? { - return slideOutHorizontally(tween()) { it } + return slideOutHorizontally( + targetOffsetX = { ScreenUtils.getScreenWidth() }, animationSpec = tween(durationMillis) + ) } } \ No newline at end of file