Layout of rotation buttons should be the same for RTL as for LTR (fixes #135)

This commit is contained in:
Pierre-Yves Nicolas
2026-03-20 15:49:01 +01:00
parent 58abc2f3fe
commit f371be4e14

View File

@@ -43,6 +43,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableIntState import androidx.compose.runtime.MutableIntState
import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableIntStateOf
@@ -55,9 +56,11 @@ import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import kotlinx.collections.immutable.toImmutableList import kotlinx.collections.immutable.toImmutableList
import net.engawapg.lib.zoomable.ZoomState import net.engawapg.lib.zoomable.ZoomState
@@ -202,21 +205,24 @@ fun RotationButtons(
onRotateImage: (String, Boolean) -> Unit, onRotateImage: (String, Boolean) -> Unit,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
Row(modifier = modifier.padding(4.dp)) { // RotateLeft on the left, RotateRight on the right: for both LTR and RTL languages
// Using AutoMirrored icons would lead to an opposite rotation in RTL languages CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {
@Suppress("DEPRECATION") Row(modifier = modifier.padding(4.dp)) {
SecondaryActionButton( // Using AutoMirrored icons would lead to an opposite rotation in RTL languages
icon = Icons.Default.RotateLeft, @Suppress("DEPRECATION")
contentDescription = stringResource(R.string.rotate_left), SecondaryActionButton(
onClick = { onRotateImage(imageId, false) } icon = Icons.Default.RotateLeft,
) contentDescription = stringResource(R.string.rotate_left),
Spacer(Modifier.width(8.dp)) onClick = { onRotateImage(imageId, false) }
@Suppress("DEPRECATION") )
SecondaryActionButton( Spacer(Modifier.width(8.dp))
icon = Icons.Default.RotateRight, @Suppress("DEPRECATION")
contentDescription = stringResource(R.string.rotate_right), SecondaryActionButton(
onClick = { onRotateImage(imageId, true) } icon = Icons.Default.RotateRight,
) contentDescription = stringResource(R.string.rotate_right),
onClick = { onRotateImage(imageId, true) }
)
}
} }
} }
@@ -255,6 +261,7 @@ private fun BottomBar(
@Composable @Composable
@Preview @Preview
@Preview(locale = "ar")
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true) @Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
@Preview(name = "Landscape", showBackground = true, widthDp = 640, heightDp = 320) @Preview(name = "Landscape", showBackground = true, widthDp = 640, heightDp = 320)
fun DocumentScreenPreview() { fun DocumentScreenPreview() {