~repos /only-bible-app
git clone
https://pyrossh.dev/repos/only-bible-app.git
The only bible app you will ever need. No ads. No in-app purchases. No distractions.
file:
composeApp/src/commonMain/kotlin/dev/pyrossh/onlyBible/utils/Swipe.kt
package dev.pyrossh.onlyBible.utils
import androidx.compose.foundation.gestures.detectDragGesturesimport androidx.compose.runtime.MutableIntStateimport androidx.compose.runtime.mutableIntStateOfimport androidx.compose.ui.input.pointer.PointerInputScopeimport kotlin.math.abs
suspend fun PointerInputScope.detectSwipe( swipeState: MutableIntState = mutableIntStateOf(-1), onSwipeLeft: () -> Unit = {}, onSwipeRight: () -> Unit = {}, onSwipeUp: () -> Unit = {}, onSwipeDown: () -> Unit = {},) = detectDragGestures( onDrag = { change, dragAmount -> change.consume() val (x, y) = dragAmount println(x) if (abs(x) > abs(y)) { when { x > 10 -> swipeState.intValue = 0 x < -10 -> swipeState.intValue = 1 } } else { when { y > 0 -> swipeState.intValue = 2 y < 0 -> swipeState.intValue = 3 } } }, onDragEnd = { when (swipeState.intValue) { 0 -> onSwipeRight() 1 -> onSwipeLeft() 2 -> onSwipeDown() 3 -> onSwipeUp() } })