diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/main/FabLayout.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/main/FabLayout.kt index fd7628507..8faa826e3 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/main/FabLayout.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/main/FabLayout.kt @@ -3,7 +3,6 @@ package com.hippo.ehviewer.ui.main import androidx.activity.compose.PredictiveBackHandler import androidx.compose.animation.core.Animatable import androidx.compose.animation.core.AnimationSpec -import androidx.compose.animation.core.EaseOut import androidx.compose.animation.core.tween import androidx.compose.foundation.MutatePriority import androidx.compose.foundation.MutatorMutex @@ -34,6 +33,7 @@ import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.layout.layout import androidx.compose.ui.unit.dp import androidx.compose.ui.util.lerp +import com.hippo.ehviewer.ui.tools.PredictiveBackEasing import com.hippo.ehviewer.ui.tools.delegateSnapshotUpdate import com.hippo.ehviewer.ui.tools.snackBarPadding import eu.kanade.tachiyomi.util.lang.launchIO @@ -158,7 +158,7 @@ fun FabLayout( try { state.mutatorMutex.mutate(MutatePriority.UserInput) { flow.collect { - val eased = EaseOut.transform(it.progress) + val eased = PredictiveBackEasing.transform(it.progress) state.expandProgress.snapTo(1 - eased) } } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/PredictiveBack.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/PredictiveBack.kt index 64c0e3d27..3121d4a61 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/PredictiveBack.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/PredictiveBack.kt @@ -4,7 +4,7 @@ import androidx.activity.BackEventCompat import androidx.activity.compose.PredictiveBackHandler import androidx.compose.animation.core.Animatable import androidx.compose.animation.core.AnimationSpec -import androidx.compose.animation.core.EaseOut +import androidx.compose.animation.core.CubicBezierEasing import androidx.compose.animation.core.Easing import androidx.compose.animation.core.VectorConverter import androidx.compose.animation.core.spring @@ -23,6 +23,8 @@ import kotlinx.coroutines.CancellationException import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.launch +val PredictiveBackEasing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f) + /* enable 0 1 * animationProgress 1F 0F * @@ -41,7 +43,7 @@ import kotlinx.coroutines.launch fun animateFloatMergePredictiveBackAsState( enable: Boolean, animationSpec: AnimationSpec = spring(), - predictiveBackInterpolator: Easing = EaseOut, + predictiveBackInterpolator: Easing = PredictiveBackEasing, finishedListener: ((Float) -> Unit)? = null, onBack: () -> Unit, ): State { @@ -84,7 +86,7 @@ fun animateFloatMergePredictiveBackAsState( fun animateFloatMergeOneWayPredictiveBackAsState( enable: Boolean, animationSpec: AnimationSpec = spring(), - predictiveBackInterpolator: Easing = EaseOut, + predictiveBackInterpolator: Easing = PredictiveBackEasing, onBack: suspend () -> Unit, ): State { val animatable = remember { Animatable(0f, Float.VectorConverter) }