diff --git a/core/ui/src/main/java/com/sadellie/unitto/core/ui/common/KeyboardButton.kt b/core/ui/src/main/java/com/sadellie/unitto/core/ui/common/KeyboardButton.kt index bfd553cf..233a278e 100644 --- a/core/ui/src/main/java/com/sadellie/unitto/core/ui/common/KeyboardButton.kt +++ b/core/ui/src/main/java/com/sadellie/unitto/core/ui/common/KeyboardButton.kt @@ -19,6 +19,7 @@ package com.sadellie.unitto.core.ui.common import android.view.HapticFeedbackConstants +import androidx.compose.animation.core.tween import androidx.compose.foundation.background import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box @@ -65,6 +66,7 @@ fun BasicKeyboardButton( onLongClick = if (onLongClick != null) { { onLongClick(); vibrate() } } else null, interactionSource = remember { MutableInteractionSource() }, cornerRadiusRange = 30..50, + animationSpec = tween(250) ) .background(containerColor) , diff --git a/core/ui/src/main/java/com/sadellie/unitto/core/ui/common/ModifierExtensions.kt b/core/ui/src/main/java/com/sadellie/unitto/core/ui/common/ModifierExtensions.kt index 88f6974e..41732612 100644 --- a/core/ui/src/main/java/com/sadellie/unitto/core/ui/common/ModifierExtensions.kt +++ b/core/ui/src/main/java/com/sadellie/unitto/core/ui/common/ModifierExtensions.kt @@ -18,7 +18,7 @@ package com.sadellie.unitto.core.ui.common -import androidx.compose.animation.core.FastOutSlowInEasing +import androidx.compose.animation.core.AnimationSpec import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.animateIntAsState import androidx.compose.animation.core.tween @@ -41,15 +41,16 @@ fun Modifier.squashable( interactionSource: MutableInteractionSource, cornerRadiusRange: IntRange, role: Role = Role.Button, + animationSpec: AnimationSpec = tween(), ) = composed { val isPressed by interactionSource.collectIsPressedAsState() val cornerRadius: Int by animateIntAsState( targetValue = if (isPressed) cornerRadiusRange.first else cornerRadiusRange.last, - animationSpec = tween(easing = FastOutSlowInEasing), + animationSpec = animationSpec, label = "Squashed animation" ) - Modifier + this .clip(RoundedCornerShape(cornerRadius)) .combinedClickable( onClick = onClick, @@ -68,15 +69,16 @@ fun Modifier.squashable( interactionSource: MutableInteractionSource, cornerRadiusRange: ClosedRange, role: Role = Role.Button, + animationSpec: AnimationSpec = tween(), ) = composed { val isPressed by interactionSource.collectIsPressedAsState() val cornerRadius: Dp by animateDpAsState( targetValue = if (isPressed) cornerRadiusRange.start else cornerRadiusRange.endInclusive, - animationSpec = tween(easing = FastOutSlowInEasing), + animationSpec = animationSpec, label = "Squashed animation" ) - Modifier + this .clip(RoundedCornerShape(cornerRadius)) .combinedClickable( onClick = onClick,