@@ -212,11 +212,10 @@ private fun SwipeableBox(
212
212
constraints.maxHeight.toFloat()
213
213
}
214
214
val parallaxFormula = {
215
- when (swipeDirection) {
216
- SwipeDirection .LEFT_TO_RIGHT -> - maxWidth.value * (1.0f - offsetProvider()) / parallaxFactor
217
- SwipeDirection .RIGHT_TO_LEFT -> maxWidth.value * (1.0f - offsetProvider()) / parallaxFactor
218
- SwipeDirection .TOP_TO_BOTTOM -> - maxHeight.value * (1.0f - offsetProvider()) / parallaxFactor
219
- SwipeDirection .BOTTOM_TO_TOP -> maxHeight.value * (1.0f - offsetProvider()) / parallaxFactor
215
+ if (swipeDirection.isRTL()) {
216
+ maxHeight.value * (1.0f - offsetProvider()) / parallaxFactor
217
+ } else {
218
+ - maxWidth.value * (1.0f - offsetProvider()) / parallaxFactor
220
219
}
221
220
}
222
221
@@ -315,11 +314,10 @@ private fun SwipeableBox(
315
314
},
316
315
)
317
316
.graphicsLayer {
318
- val translation = when (swipeDirection) {
319
- SwipeDirection .LEFT_TO_RIGHT -> scrollPosition
320
- SwipeDirection .RIGHT_TO_LEFT -> - scrollPosition
321
- SwipeDirection .TOP_TO_BOTTOM -> scrollPosition
322
- SwipeDirection .BOTTOM_TO_TOP -> - scrollPosition
317
+ val translation = if (swipeDirection.isRTL()) {
318
+ - scrollPosition
319
+ } else {
320
+ scrollPosition
323
321
}
324
322
if (swipeDirection.isHorizontal()) {
325
323
translationX = if (applyParallax) parallaxFormula() else translation
@@ -386,11 +384,10 @@ private fun PageElevation(
386
384
},
387
385
)
388
386
.graphicsLayer {
389
- val translation = when (swipeDirection) {
390
- SwipeDirection .LEFT_TO_RIGHT -> positionProvider()
391
- SwipeDirection .RIGHT_TO_LEFT -> pageEnd - positionProvider()
392
- SwipeDirection .TOP_TO_BOTTOM -> positionProvider()
393
- SwipeDirection .BOTTOM_TO_TOP -> pageEnd - positionProvider()
387
+ val translation = if (swipeDirection.isRTL()) {
388
+ pageEnd - positionProvider()
389
+ } else {
390
+ positionProvider()
394
391
}
395
392
if (swipeDirection.isHorizontal()) {
396
393
translationX = translation - elevationAmount.toPx()
@@ -399,8 +396,12 @@ private fun PageElevation(
399
396
}
400
397
},
401
398
) {
402
- val colors = listOf (ElevationEnd , ElevationStart )
403
- val brush = if (swipeDirection.isHorizontal()) Brush .horizontalGradient(
399
+ val colors = if (swipeDirection.isRTL()) {
400
+ listOf (ElevationEnd , ElevationStart )
401
+ } else {
402
+ listOf (ElevationStart , ElevationEnd )
403
+ }
404
+ val brush = if (swipeDirection.isHorizontal()) Brush .horizontalGradient(
404
405
colors = colors,
405
406
) else Brush .verticalGradient(
406
407
colors = colors,
0 commit comments