Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autoMirroded attribute to some icons so that they render correctly on Rtl mode. #85

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading