Pablichjenkov
04/05/2023, 3:20 AMforEachGesture
got deprecated and suggested to replace with awaitEachGesture
, however, when making the replacement ui breaks in a way that no more touches are given to other composables. The replacement works fine in the other platforms ios, android, desktop but not compose-js.
The code looks like bellow. Perhaps I am doing some prohibited operation when using the new function:
Box(
modifier = Modifier
.fillMaxSize()
.pointerInput(childComponent) {
if (prevChildComponent == null) return@pointerInput
forEachGesture {
awaitPointerEventScope {
val eventDown = awaitFirstDown(requireUnconsumed = true)
if (eventDown.position.x < PredictiveBackAreaWidth) {
eventDown.consume()
val startX = eventDown.position.x
wasCancelled = false
do {
val event: PointerEvent =
awaitPointerEvent(PointerEventPass.Main)
// some event processing code ...
} while (event.changes.any { it.pressed })
coroutineScope.launch {...}
}
}
}
...
Above code breaks when replacing forEachGesture
with awaitEachGesture
then removing awaitPointerEventScope
Box(
modifier = Modifier
.fillMaxSize()
.pointerInput(childComponent) {
if (prevChildComponent == null) return@pointerInput
awaitEachGesture {
val eventDown = awaitFirstDown(requireUnconsumed = true)
if (eventDown.position.x < PredictiveBackAreaWidth) {
eventDown.consume()
val startX = eventDown.position.x
wasCancelled = false
do {
val event: PointerEvent =
awaitPointerEvent(PointerEventPass.Main)
// some event processing code ...
} while (event.changes.any { it.pressed })
coroutineScope.launch {...}
}
}
...
The App becomes unresponsive to touch at all.