I have taken a look at the following answer and it didn't work How to use detectTransformGestures but not consuming all pointer event
The problem: I have a LazyList that I need to scroll vertically, the children composables also are draggable horizontally and respond to tap and presses. But, I want the LazyList to also be pinched-in or pinched-out while still intercepting the drag gestures. Here's the current code of the modifier for the existing gestures:
/* LazyList child composable */
Modifier.pointerInput(myLock) {
detectDragGestures(
onDragEnd = {
if (fooBolean) {
stuffToDo()
},
onDrag = { change, dragAmount ->
draggingTheComposableLogic()
scope.launch {
/* Scrolling the lazylist using the state linked to it */
state.scroll {
scrollBy(-dragAmount.y)
}
}
}
)
}
.pointerInput(Unit) {
detectTapGesturesUnconsumed(
onTap = {
scope.launch {
val press = PressInteraction.Press(Offset.Zero)
clickInteraction.emit(press)
delay(150)
clickInteraction.emit(PressInteraction.Release(press))
}
}
)
}
My attempt: I tried modifying the source code for detectTransformGestures to remove the consume part, but it doesn't work at all. It worked for tap and drag, but not for transform gestures. If I add this piece of code to detect zoom-in and zoom-out (pinch gesture), then everything else will just stop working:
/* This surface is situated on top of the lazylist, i know it's overlaying it, but then if I add the pointerInput modifier to the lazylist, it also won't work, nothing works, it seems like this modifier keeps blocking until the pointers are lifted */
Surface(modifier = Modifier.fillMaxSize().alpha(0f)
.pointerInput(Unit) {
detectTransformGestures(
onGesture = { c, p, z, r ->
Log.e("f", "$z")
}
)
}
) {}
Is there any way I can detect ONLY-ZOOM gesture without consuming it, so I can intercept the other gestures normally ?