Travis Griggs
10/27/2023, 5:50 PM@Preview(showBackground = true)
@Composable
private fun LongPressPreview() {
Spacer(modifier = Modifier
.fillMaxSize()
.pointerInput(Unit) {
detectTapGestures(onPress = {
coroutineScope {
var isDinging = false
val dingScope = async {
delay(viewConfiguration.longPressTimeoutMillis)
isDinging = true
while (true) {
println("DING")
delay(250)
}
}
val completed = tryAwaitRelease()
dingScope.cancel()
if (!isDinging && completed) {
println("SINGLE CLICK")
}
}
})
})
}
Coroutines aren't my strongest play, hopefully this is all legal. Seems to work for what I need. Any suggestions?