Skip to content

Instantly share code, notes, and snippets.

@UndeRus
Created February 2, 2022 11:27
Show Gist options
  • Save UndeRus/56647b21ab19bdf4171f8f506e497e21 to your computer and use it in GitHub Desktop.
Save UndeRus/56647b21ab19bdf4171f8f506e497e21 to your computer and use it in GitHub Desktop.
ripple.kt
fun Modifier.ripple(): Modifier = composed {
val source = MutableInteractionSource()
indication(interactionSource = source, indication = rememberRipple())
.pointerInput(Unit) {
detectTapGestures(
onPress = { offset ->
val press = PressInteraction.Press(offset)
source.emit(press)
tryAwaitRelease()
source.emit(PressInteraction.Release(press))
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment