[优化] 优化导航动画

This commit is contained in:
HapeLee
2026-03-28 00:34:56 +08:00
parent daf93eb521
commit 9b7cd8ec3e
@@ -6,7 +6,6 @@ import android.content.res.Configuration
import android.os.Bundle import android.os.Bundle
import android.text.format.DateUtils import android.text.format.DateUtils
import androidx.compose.animation.AnimatedContentTransitionScope import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.FastOutSlowInEasing import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.tween import androidx.compose.animation.core.tween
@@ -182,63 +181,70 @@ open class MainActivity : BaseComposeActivity() {
(slideIntoContainer( (slideIntoContainer(
towards = AnimatedContentTransitionScope.SlideDirection.Start, towards = AnimatedContentTransitionScope.SlideDirection.Start,
animationSpec = tween( animationSpec = tween(
durationMillis = 260, durationMillis = 520,
easing = FastOutSlowInEasing easing = FastOutSlowInEasing
), ),
initialOffset = { fullWidth -> fullWidth / 10 } initialOffset = { fullWidth -> fullWidth }
) + fadeIn( ) + fadeIn(
animationSpec = tween( animationSpec = tween(
durationMillis = 220, durationMillis = 360,
easing = LinearOutSlowInEasing easing = LinearOutSlowInEasing
) )
)) togetherWith ExitTransition.None )) togetherWith (slideOutOfContainer(
towards = AnimatedContentTransitionScope.SlideDirection.Start,
animationSpec = tween(
durationMillis = 520,
easing = FastOutSlowInEasing
),
targetOffset = { fullWidth -> fullWidth / 4 }
) + fadeOut(
animationSpec = tween(
durationMillis = 360,
easing = LinearOutSlowInEasing
)
))
}, },
popTransitionSpec = { popTransitionSpec = {
(slideIntoContainer( (slideIntoContainer(
towards = AnimatedContentTransitionScope.SlideDirection.Start, towards = AnimatedContentTransitionScope.SlideDirection.Start,
animationSpec = tween( animationSpec = tween(
durationMillis = 240, durationMillis = 520,
easing = FastOutSlowInEasing easing = FastOutSlowInEasing
), ),
initialOffset = { fullWidth -> -fullWidth / 8 } initialOffset = { fullWidth -> -fullWidth / 4 }
) + fadeIn( ) + fadeIn(
animationSpec = tween( animationSpec = tween(
durationMillis = 200, durationMillis = 360,
easing = LinearOutSlowInEasing easing = LinearOutSlowInEasing
) )
)) togetherWith )) togetherWith (scaleOut(
(scaleOut( targetScale = 0.8f,
targetScale = 0.92f,
animationSpec = tween( animationSpec = tween(
durationMillis = 220, durationMillis = 520,
easing = FastOutSlowInEasing easing = FastOutSlowInEasing
) )
) + fadeOut( ) + fadeOut(
animationSpec = tween(durationMillis = 180) animationSpec = tween(durationMillis = 360)
)) ))
}, },
predictivePopTransitionSpec = { _ -> predictivePopTransitionSpec = { _ ->
(slideIntoContainer( (slideIntoContainer(
towards = AnimatedContentTransitionScope.SlideDirection.Start, towards = AnimatedContentTransitionScope.SlideDirection.Start,
animationSpec = tween( animationSpec = tween(
durationMillis = 240,
easing = FastOutSlowInEasing easing = FastOutSlowInEasing
), ),
initialOffset = { fullWidth -> -fullWidth / 8 } initialOffset = { fullWidth -> -fullWidth / 4 }
) + fadeIn( ) + fadeIn(
animationSpec = tween( animationSpec = tween(
durationMillis = 200,
easing = LinearOutSlowInEasing easing = LinearOutSlowInEasing
) )
)) togetherWith )) togetherWith (scaleOut(
(scaleOut( targetScale = 0.8f,
targetScale = 0.92f,
animationSpec = tween( animationSpec = tween(
durationMillis = 220,
easing = FastOutSlowInEasing easing = FastOutSlowInEasing
) )
) + fadeOut( ) + fadeOut(
animationSpec = tween(durationMillis = 180) animationSpec = tween()
)) ))
}, },
onBack = { onBack = {