[优化] 优化导航动画
This commit is contained in:
@@ -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,64 +181,71 @@ 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 = 520,
|
||||||
durationMillis = 220,
|
easing = FastOutSlowInEasing
|
||||||
easing = FastOutSlowInEasing
|
)
|
||||||
)
|
) + fadeOut(
|
||||||
) + fadeOut(
|
animationSpec = tween(durationMillis = 360)
|
||||||
animationSpec = tween(durationMillis = 180)
|
))
|
||||||
))
|
|
||||||
},
|
},
|
||||||
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(
|
easing = FastOutSlowInEasing
|
||||||
durationMillis = 220,
|
)
|
||||||
easing = FastOutSlowInEasing
|
) + fadeOut(
|
||||||
)
|
animationSpec = tween()
|
||||||
) + fadeOut(
|
))
|
||||||
animationSpec = tween(durationMillis = 180)
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
onBack = {
|
onBack = {
|
||||||
if (backStack.size > 1) {
|
if (backStack.size > 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user