44package top.yukonga.miuix.kmp.utils
55
66import androidx.compose.animation.core.Animatable
7+ import androidx.compose.animation.core.LinearEasing
78import androidx.compose.animation.core.tween
89import androidx.compose.foundation.Indication
910import androidx.compose.foundation.IndicationNodeFactory
@@ -22,11 +23,11 @@ import kotlinx.coroutines.isActive
2223import kotlinx.coroutines.launch
2324import top.yukonga.miuix.kmp.interfaces.HoldDownInteraction
2425
25- private const val ANIMATION_DURATION_MS = 150
26+ private const val ANIM_DURATION_MS = 120
2627private const val HOVER_ALPHA_DELTA = 0.06f
2728private const val FOCUS_ALPHA_DELTA = 0.08f
28- private const val PRESS_ALPHA_DELTA = 0.1f
29- private const val HOLD_DOWN_ALPHA_DELTA = 0.1f
29+ private const val PRESS_ALPHA_DELTA = 0.10f
30+ private const val HOLD_DOWN_ALPHA_DELTA = 0.10f
3031
3132/* *
3233 * Miuix default [Indication] that draws a rectangular overlay when pressed.
@@ -73,15 +74,21 @@ class MiuixIndication(
7374 coroutineScope.launch {
7475 if (coroutineContext.isActive) {
7576 pressedAnimation?.join()
76- animatedAlpha.animateTo(0f , tween(ANIMATION_DURATION_MS ))
77+ animatedAlpha.animateTo(
78+ targetValue = targetAlpha.coerceIn(0f , 0.10f ),
79+ animationSpec = tween(durationMillis = ANIM_DURATION_MS , easing = LinearEasing )
80+ )
7781 }
7882 }
7983 } else {
8084 pressedAnimation?.cancel()
8185 restingAnimation?.cancel()
8286 pressedAnimation =
8387 coroutineScope.launch {
84- animatedAlpha.animateTo(targetAlpha, tween(ANIMATION_DURATION_MS ))
88+ animatedAlpha.animateTo(
89+ targetValue = targetAlpha.coerceIn(0f , 0.10f ),
90+ animationSpec = tween(durationMillis = ANIM_DURATION_MS , easing = LinearEasing )
91+ )
8592 }
8693 }
8794 }
0 commit comments