Skip to content

Commit 711c400

Browse files
committed
improve animations
1 parent c74da2d commit 711c400

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/modifier/ContainerShapeDefaults.kt

+10-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ package ru.tech.imageresizershrinker.core.ui.widget.modifier
2020
import androidx.compose.animation.core.Animatable
2121
import androidx.compose.animation.core.AnimationVector1D
2222
import androidx.compose.animation.core.FiniteAnimationSpec
23+
import androidx.compose.animation.core.Spring
2324
import androidx.compose.animation.core.animateDpAsState
24-
import androidx.compose.animation.core.tween
25+
import androidx.compose.animation.core.spring
2526
import androidx.compose.foundation.interaction.MutableInteractionSource
2627
import androidx.compose.foundation.interaction.collectIsFocusedAsState
2728
import androidx.compose.foundation.interaction.collectIsPressedAsState
@@ -221,15 +222,21 @@ internal fun rememberAnimatedShape(
221222
@Composable
222223
fun animateShape(
223224
targetValue: RoundedCornerShape,
224-
animationSpec: FiniteAnimationSpec<Float> = tween(250),
225+
animationSpec: FiniteAnimationSpec<Float> = spring(
226+
dampingRatio = Spring.DampingRatioLowBouncy,
227+
stiffness = Spring.StiffnessMediumLow
228+
),
225229
): Shape = rememberAnimatedShape(targetValue, animationSpec)
226230

227231
@Composable
228232
fun shapeByInteraction(
229233
shape: Shape,
230234
pressedShape: Shape,
231235
interactionSource: MutableInteractionSource,
232-
animationSpec: FiniteAnimationSpec<Float> = tween(250),
236+
animationSpec: FiniteAnimationSpec<Float> = spring(
237+
dampingRatio = Spring.DampingRatioLowBouncy,
238+
stiffness = Spring.StiffnessMediumLow
239+
),
233240
): Shape {
234241
val pressed by interactionSource.collectIsPressedAsState()
235242
val focused by interactionSource.collectIsFocusedAsState()

0 commit comments

Comments
 (0)