https://kotlinlang.org logo
#compose
Title
# compose
d

deviant

08/17/2022, 2:13 PM
hey guys looks like drawer gesture doesn't work when using horizontal pager inside scaffold. is there any workaround? maybe we can temporarily disable the pager gestures like we did with views in precompose era?
i created this modifier for the pager:
Copy code
fun Modifier.edgeBypass(scrollEnabled: MutableState<Boolean>): Modifier = then(Modifier.pointerInput(scrollEnabled) {
    val drawerTapArea = 48.dp.toPx()
    forEachGesture {
        awaitPointerEventScope {
            val down = awaitFirstDown(false)
            scrollEnabled.value = down.position.x >= drawerTapArea
            val up = waitForUpOrCancellation()
            scrollEnabled.value = true
        }
    }
})
it modifies the boolean state when user taps on left edge. then i pass this state to the pager's
userScrollEnabled
. maybe a bit ugly but it works as expected.
3 Views