diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/core/components/modal_drawer/ModalDrawer.kt b/app/src/main/java/ua/acclorite/book_story/presentation/core/components/modal_drawer/ModalDrawer.kt index 1401922a..911a18df 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/core/components/modal_drawer/ModalDrawer.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/core/components/modal_drawer/ModalDrawer.kt @@ -35,7 +35,9 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import ua.acclorite.book_story.presentation.core.components.common.AnimatedVisibility import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar @@ -63,7 +65,9 @@ fun ModalDrawer( header: @Composable () -> Unit = {}, content: LazyListScope.() -> Unit ) { + val layoutDirection = LocalLayoutDirection.current val density = LocalDensity.current + val offset = remember { mutableFloatStateOf(0f) } val offsetDp = remember { derivedStateOf { @@ -93,8 +97,14 @@ fun ModalDrawer( ) { AnimatedVisibility( visible = show, - enter = slideInHorizontally { (-it + with(density) { -20.dp.toPx() }).toInt() }, - exit = slideOutHorizontally { (-it + with(density) { -20.dp.toPx() }).toInt() } + enter = slideInHorizontally { + if (layoutDirection == LayoutDirection.Ltr) (-it + with(density) { -20.dp.toPx() }).toInt() + else (it + with(density) { 20.dp.toPx() }).toInt() + }, + exit = slideOutHorizontally { + if (layoutDirection == LayoutDirection.Ltr) (-it + with(density) { -20.dp.toPx() }).toInt() + else (it + with(density) { 20.dp.toPx() }).toInt() + } ) { Column( modifier = Modifier @@ -125,8 +135,9 @@ fun ModalDrawer( else offset.floatValue = 0f } ) { _, dragAmount -> - offset.floatValue = (offset.floatValue + dragAmount) - .coerceAtMost(0f) + offset.floatValue = (if (layoutDirection == LayoutDirection.Ltr) { + offset.floatValue + dragAmount + } else offset.floatValue + (-dragAmount)).coerceAtMost(0f) } } .systemBarsPadding()