Colton Idle
07/27/2021, 4:37 PMdispatchTouchEvent
method, but now I'm thinking if it'd be possible to have another wrapper composable just inside my Theme declaration that would be able to do the same thing.
i.e. Change this
MyAppTheme {
Scaffold { .. }
}
to this
MyAppTheme {
DebugDialogTouchInterceptor {
Scaffold { .. }
}
}
Does anyone know if it'd be possible to write something like that in compose?alorma
07/27/2021, 4:41 PMalorma
07/27/2021, 4:41 PMalorma
07/27/2021, 4:44 PMColton Idle
07/27/2021, 4:47 PMColton Idle
07/27/2021, 5:02 PM@Composable
fun DebugDialogTouchInterceptor(content: @Composable BoxScope.() -> Unit) {
var touchTimes by remember { mutableStateOf(0) }
Box(
modifier =
Modifier.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = { touchTimes++ })) {
val openDialog = remember { derivedStateOf { touchTimes > 3 } }
if (openDialog.value) {
Dialog(onDismissRequest = {}) {
Box(Modifier.fillMaxSize().background(Color.White))
}
}
content()
}
}
Not perfect as it doesn't have a timer in it, and it doesn't take into account click location, but it's a decent starting point.
Will take tips on timer and click location tho. 😅Francesc
07/27/2021, 7:04 PM