Closed smallshen closed 3 years ago
Try this:
Modifier.clickable(interactionSource = remember(::MutableInteractionSource), indication = null)
@jimgoog, disabling the indication is a little verbose now :). What do you think about adding an overload of clickable
without interactionSource
parameter?
fun Modifier.clickable(
indication: Indication?,
enabled: Boolean = true,
onClickLabel: String? = null,
role: Role? = null,
onClick: () -> Unit
)= composed(
inspectorInfo = debugInspectorInfo {
name = "clickable"
properties["enabled"] = enabled
properties["onClickLabel"] = onClickLabel
properties["role"] = role
properties["onClick"] = onClick
}
) {
Modifier.clickable(
enabled = enabled,
onClickLabel = onClickLabel,
onClick = onClick,
role = role,
indication = indication,
interactionSource = remember { MutableInteractionSource() }
)
}
Not so long ago interactionSource
was with a default value:
https://android-review.googlesource.com/c/platform/frameworks/support/+/1544584/5/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Clickable.kt#b64
Thank you, it works.
I believe the ripple animation is setup when MaterialTheme is installed, which seems appropriate, and LocalIndication
can be used to override this default behavior across the hierarchy. Users can also work around the verbosity by creating their own overload.
That said, I don't see a reason why Modifier.clickable
's interactionSource
parameter doesn't have a default value of remember { MutableInteractionSource() }
instead forcing users to pass it in when they want to override the indication parameter. I will raise this with API Council and see if I'm missing something. @igordmn - Thanks for pointing it out as an opportunity for polish.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
How to remove ripple effect on Modifier.clickable()