Skip to content

Commit

Permalink
Merge pull request #85 from element-hq/bma/rtlIcons
Browse files Browse the repository at this point in the history
Add autoMirroded attribute to some icons so that they render correctly on Rtl mode.
  • Loading branch information
bmarty authored Oct 1, 2024
2 parents 6f8701c + e3e5f78 commit 8af20b6
Show file tree
Hide file tree
Showing 96 changed files with 244 additions and 4 deletions.
3 changes: 3 additions & 0 deletions compound/screenshots/Compound Icons - Rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
Expand All @@ -17,13 +18,16 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
Expand All @@ -34,14 +38,28 @@ internal fun IconsCompoundPreviewLight() = ElementTheme {
IconsCompoundPreview()
}

@Preview(widthDp = 730, heightDp = 1600)
@Composable
internal fun IconsCompoundPreviewRtl() = ElementTheme {
CompositionLocalProvider(
LocalLayoutDirection provides LayoutDirection.Rtl,
) {
IconsCompoundPreview(
title = "Compound Icons Rtl",
)
}
}

@Preview(widthDp = 730, heightDp = 1600)
@Composable
internal fun IconsCompoundPreviewDark() = ElementTheme(darkTheme = true) {
IconsCompoundPreview()
}

@Composable
private fun IconsCompoundPreview() {
private fun IconsCompoundPreview(
title: String = "Compound Icons",
) {
val context = LocalContext.current
val content: Sequence<@Composable ColumnScope.() -> Unit> = sequence {
for (icon in CompoundIcons.allResIds) {
Expand All @@ -64,7 +82,7 @@ private fun IconsCompoundPreview() {
}
}
IconsPreview(
title = "Compound Icons",
title = title,
content = content.toList(),
)
}
Expand Down Expand Up @@ -92,9 +110,10 @@ internal fun IconsPreview(
content.chunked(10).forEach { chunk ->
Row(
modifier = Modifier.height(IntrinsicSize.Max),
horizontalArrangement = Arrangement.spacedBy(6.dp),
// Keep same order of icons for an easier comparison of previews
horizontalArrangement = Arrangement.Absolute.Left,
) {
chunk.forEach { icon ->
chunk.forEachIndexed { index, icon ->
Column(
modifier = Modifier
.background(MaterialTheme.colorScheme.background)
Expand All @@ -105,6 +124,9 @@ internal fun IconsPreview(
) {
icon()
}
if (index < chunk.size - 1) {
Spacer(modifier = Modifier.width(6.dp))
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_arrow_left.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_arrow_right.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_attachment.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_block.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_chart.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_chat.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_chat_new.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_chat_solid.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_cloud.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_cloud_solid.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_collapse.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_company.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_compose.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_copy.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_dark_mode.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_devices.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_document.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_edit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_edit_solid.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_expand.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_extensions.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_file_error.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_files.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_forward.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_history.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_host.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_image.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_image_error.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_italic.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_key.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
1 change: 1 addition & 0 deletions compound/src/main/res/drawable/ic_compound_key_off.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
Expand Down
Loading

0 comments on commit 8af20b6

Please sign in to comment.