My problem is pretty straight forward however I don't seem to get a working solution. I'm perfectly capable of swiping left to right (0 -> maxWidth), but not right to left (maxWidth -> 0). What am I missing? My code:
val swipeableState = rememberSwipeableState(initialValue = 0)
...
LaunchedEffect(key1 = swipeableState.currentValue) {
if (swipeableState.currentValue == 1 && !engaged) {
onSwipeHigh()
setEngaged(true)
setFractionalThreshold(0.1f)
} else if(swipeableState.currentValue == 0 && engaged) {
onSwipeLow()
setEngaged(false)
setFractionalThreshold(0.9f)
}
}
...
Box(
modifier = Modifier
.onGloballyPositioned {
iconSize = it.size
}
.swipeable(
state = swipeableState,
anchors = mapOf(
0f to 0,
maxWidth to 1
),
thresholds = { _, _ -> FractionalThreshold(fractionalThreshold) },
orientation = Orientation.Horizontal,
)
.offset {
IntOffset(swipeableState.offset.value.roundToInt(), 0)
}
set swipeable reverseDirection true and Box offset's x value negative