mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
parent
bb0b75e3f4
commit
f413e98d27
@ -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)
|
||||
,
|
||||
|
@ -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<Int> = 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<Dp>,
|
||||
role: Role = Role.Button,
|
||||
animationSpec: AnimationSpec<Dp> = 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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user