ghosalmartin
03/05/2025, 4:01 PMpointerInteropFilter
and assigning to a 3 state enum and storing in
var buttonActionState by remember { mutableStateOf(ButtonActionState.NOT_PRESSED) }
95% of the time it works fine, but when I slightly move my mouse(via remote screen), then tap again I can see buttonActionState
being set, it being a different value to the old one, but there is no recomposition.
Anyone any ideas? I can provide the full function if required.
CheersLouis Pullen-Freilich [G]
03/05/2025, 4:12 PMghosalmartin
03/05/2025, 4:19 PMLouis Pullen-Freilich [G]
03/05/2025, 4:23 PMghosalmartin
03/05/2025, 4:30 PMawaitFrame()
but no dice unfortunately, still same issue occurs in an odd way, because now it doesnt even set the valueLouis Pullen-Freilich [G]
03/05/2025, 4:33 PMghosalmartin
03/05/2025, 4:40 PMLouis Pullen-Freilich [G]
03/05/2025, 4:44 PMLouis Pullen-Freilich [G]
03/05/2025, 4:44 PMghosalmartin
03/05/2025, 4:47 PMghosalmartin
03/05/2025, 5:02 PMLouis Pullen-Freilich [G]
03/05/2025, 5:03 PMghosalmartin
03/05/2025, 5:05 PM@Composable
fun Modifier.bounceAnimation(
scale: Float = 1.2f,
onFinish: () -> Unit,
) : Modifier {
var buttonActionState by remember { mutableStateOf(ButtonActionState.NOT_PRESSED) }
val scaleState by animateFloatAsState(
targetValue = if (buttonActionState == ButtonActionState.PRESSED) scale else ONE,
label = "scaleState",
animationSpec = SpringSpec(
dampingRatio = Spring.DampingRatioMediumBouncy,
stiffness = Spring.StiffnessMedium,
),
finishedListener = {
if (buttonActionState == ButtonActionState.NOT_PRESSED) onFinish()
},
)
return this then pointerInteropFilter {
buttonActionState = when (it.action) {
MotionEvent.ACTION_DOWN -> ButtonActionState.PRESSED
MotionEvent.ACTION_UP -> ButtonActionState.NOT_PRESSED
else -> ButtonActionState.IGNORE
}
true
}.graphicsLayer {
scaleX = scaleState
scaleY = scaleState
}
}
ghosalmartin
03/05/2025, 5:06 PMghosalmartin
03/05/2025, 5:07 PMghosalmartin
03/05/2025, 5:10 PM@Composable
fun Modifier.bounceAnimation(
scale: Float = 1.2f,
interactionSource: InteractionSource = remember { MutableInteractionSource() },
onFinish: () -> Unit,
) : Modifier {
val isPressed by interactionSource.collectIsPressedAsState()
val scaleState by animateFloatAsState(
targetValue = if (isPressed) scale else ONE,
label = "scaleState",
animationSpec = SpringSpec(
dampingRatio = Spring.DampingRatioMediumBouncy,
stiffness = Spring.StiffnessMedium,
),
finishedListener = {
if (!isPressed) onFinish()
},
)
return this then graphicsLayer {
scaleX = scaleState
scaleY = scaleState
}
}
ghosalmartin
03/05/2025, 5:10 PMLouis Pullen-Freilich [G]
03/05/2025, 5:12 PMLouis Pullen-Freilich [G]
03/05/2025, 5:13 PMghosalmartin
03/05/2025, 5:20 PMLouis Pullen-Freilich [G]
03/05/2025, 5:21 PMghosalmartin
03/05/2025, 5:24 PMghosalmartin
03/05/2025, 5:25 PMIndication
api https://developer.android.com/develop/ui/compose/touch-input/user-interactions/handling-interactions#replace-effectghosalmartin
03/05/2025, 5:26 PMLouis Pullen-Freilich [G]
03/05/2025, 5:28 PMLouis Pullen-Freilich [G]
03/05/2025, 5:29 PMghosalmartin
03/05/2025, 5:31 PMLouis Pullen-Freilich [G]
03/05/2025, 5:33 PMLouis Pullen-Freilich [G]
03/05/2025, 5:33 PMghosalmartin
03/05/2025, 5:34 PMghosalmartin
03/05/2025, 5:42 PMghosalmartin
03/07/2025, 10:01 AMonclick
is always triggered beforehand, or sometimes after the start of the animation but doesnt wait till the end, meaning if for example we are navigating away we never really see it or only partially see it.ghosalmartin
03/07/2025, 10:05 AMLouis Pullen-Freilich [G]
03/07/2025, 10:15 AMghosalmartin
03/07/2025, 10:23 AM