Skip to content

Instantly share code, notes, and snippets.

@carterhudson
Last active September 7, 2021 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carterhudson/9a9dbf8e8e30df5825cfc568c897fc9b to your computer and use it in GitHub Desktop.
Save carterhudson/9a9dbf8e8e30df5825cfc568c897fc9b to your computer and use it in GitHub Desktop.
@Composable
fun RepeatingButton(
modifier: Modifier = Modifier,
onClick: () -> Unit,
enabled: Boolean = true,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
elevation: ButtonElevation? = ButtonDefaults.elevation(),
shape: Shape = MaterialTheme.shapes.small,
border: BorderStroke? = null,
colors: ButtonColors = ButtonDefaults.buttonColors(),
contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
content: @Composable RowScope.() -> Unit
) {
var pressed by remember { mutableStateOf(false) }
Button(
modifier = modifier.pointerInteropFilter {
pressed = when (it.action) {
MotionEvent.ACTION_DOWN -> true
else -> false
}
true
},
onClick = {},
enabled = enabled,
interactionSource = interactionSource,
elevation = elevation,
shape = shape,
border = border,
colors = colors,
contentPadding = contentPadding,
content = content
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment