From 30836c3944ef3d300ff58691de2719dcb5a7fcd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 23 Sep 2024 14:20:12 +0200 Subject: [PATCH 1/4] Update avatar colors to the new semantic ones in Compound --- .../android/compound/theme/AvatarColors.kt | 54 ++++++------------- .../compound/screenshot/AvatarColorsTests.kt | 8 +-- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/compound/src/main/kotlin/io/element/android/compound/theme/AvatarColors.kt b/compound/src/main/kotlin/io/element/android/compound/theme/AvatarColors.kt index 64e91cf..5f846c3 100644 --- a/compound/src/main/kotlin/io/element/android/compound/theme/AvatarColors.kt +++ b/compound/src/main/kotlin/io/element/android/compound/theme/AvatarColors.kt @@ -13,9 +13,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import io.element.android.compound.annotations.CoreColorToken -import io.element.android.compound.tokens.generated.internal.DarkColorTokens -import io.element.android.compound.tokens.generated.internal.LightColorTokens /** * Data class to hold avatar colors. @@ -28,41 +25,24 @@ data class AvatarColors( ) /** - * Avatar colors are not yet part of SemanticColors, so create list here. - * LightColorTokens is internal to the module. + * Avatar colors using semantic tokens. */ -@OptIn(CoreColorToken::class) -val avatarColorsLight = listOf( - AvatarColors(background = LightColorTokens.colorBlue300, foreground = LightColorTokens.colorBlue1200), - AvatarColors(background = LightColorTokens.colorFuchsia300, foreground = LightColorTokens.colorFuchsia1200), - AvatarColors(background = LightColorTokens.colorGreen300, foreground = LightColorTokens.colorGreen1200), - AvatarColors(background = LightColorTokens.colorPink300, foreground = LightColorTokens.colorPink1200), - AvatarColors(background = LightColorTokens.colorOrange300, foreground = LightColorTokens.colorOrange1200), - AvatarColors(background = LightColorTokens.colorCyan300, foreground = LightColorTokens.colorCyan1200), - AvatarColors(background = LightColorTokens.colorPurple300, foreground = LightColorTokens.colorPurple1200), - AvatarColors(background = LightColorTokens.colorLime300, foreground = LightColorTokens.colorLime1200), -) - -/** - * Avatar colors are not yet part of SemanticColors, so create list here. - * DarkColorTokens is internal to the module. - */ -@OptIn(CoreColorToken::class) -val avatarColorsDark = listOf( - AvatarColors(background = DarkColorTokens.colorBlue300, foreground = DarkColorTokens.colorBlue1200), - AvatarColors(background = DarkColorTokens.colorFuchsia300, foreground = DarkColorTokens.colorFuchsia1200), - AvatarColors(background = DarkColorTokens.colorGreen300, foreground = DarkColorTokens.colorGreen1200), - AvatarColors(background = DarkColorTokens.colorPink300, foreground = DarkColorTokens.colorPink1200), - AvatarColors(background = DarkColorTokens.colorOrange300, foreground = DarkColorTokens.colorOrange1200), - AvatarColors(background = DarkColorTokens.colorCyan300, foreground = DarkColorTokens.colorCyan1200), - AvatarColors(background = DarkColorTokens.colorPurple300, foreground = DarkColorTokens.colorPurple1200), - AvatarColors(background = DarkColorTokens.colorLime300, foreground = DarkColorTokens.colorLime1200), -) +@Composable +fun avatarColors(): List { + return listOf( + AvatarColors(background = ElementTheme.colors.bgDecorative1, foreground = ElementTheme.colors.textDecorative1), + AvatarColors(background = ElementTheme.colors.bgDecorative2, foreground = ElementTheme.colors.textDecorative2), + AvatarColors(background = ElementTheme.colors.bgDecorative3, foreground = ElementTheme.colors.textDecorative3), + AvatarColors(background = ElementTheme.colors.bgDecorative4, foreground = ElementTheme.colors.textDecorative4), + AvatarColors(background = ElementTheme.colors.bgDecorative5, foreground = ElementTheme.colors.textDecorative5), + AvatarColors(background = ElementTheme.colors.bgDecorative6, foreground = ElementTheme.colors.textDecorative6), + ) +} @Preview @Composable -internal fun AvatarColorsLightPreview() { - val chunks = avatarColorsLight.chunked(4) +internal fun AvatarColorsPreviewLight() { + val chunks = avatarColors().chunked(4) ElementTheme { Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { for (chunk in chunks) { @@ -74,9 +54,9 @@ internal fun AvatarColorsLightPreview() { @Preview @Composable -internal fun AvatarColorsDarkPreview() { - val chunks = avatarColorsDark.chunked(4) - ElementTheme { +internal fun AvatarColorsPreviewDark() { + val chunks = avatarColors().chunked(4) + ElementTheme(darkTheme = true) { Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { for (chunk in chunks) { AvatarColorRow(chunk) diff --git a/compound/src/test/kotlin/io/element/android/compound/screenshot/AvatarColorsTests.kt b/compound/src/test/kotlin/io/element/android/compound/screenshot/AvatarColorsTests.kt index 94d3a3a..0caf71d 100644 --- a/compound/src/test/kotlin/io/element/android/compound/screenshot/AvatarColorsTests.kt +++ b/compound/src/test/kotlin/io/element/android/compound/screenshot/AvatarColorsTests.kt @@ -3,8 +3,8 @@ package io.element.android.compound.screenshot import androidx.test.ext.junit.runners.AndroidJUnit4 import com.github.takahirom.roborazzi.captureRoboImage import io.element.android.compound.screenshot.utils.screenshotFile -import io.element.android.compound.theme.AvatarColorsDarkPreview -import io.element.android.compound.theme.AvatarColorsLightPreview +import io.element.android.compound.theme.AvatarColorsPreviewDark +import io.element.android.compound.theme.AvatarColorsPreviewLight import org.junit.Test import org.junit.runner.RunWith import org.robolectric.annotation.Config @@ -17,10 +17,10 @@ class AvatarColorsTests { @Config(sdk = [34], qualifiers = "xxhdpi") fun screenshots() { captureRoboImage(file = screenshotFile("Avatar Colors - Light.png")) { - AvatarColorsLightPreview() + AvatarColorsPreviewLight() } captureRoboImage(file = screenshotFile("Avatar Colors - Dark.png")) { - AvatarColorsDarkPreview() + AvatarColorsPreviewDark() } } } \ No newline at end of file From ac2cfa9df0d087f7323ecacdbda9ae1fc63effa6 Mon Sep 17 00:00:00 2001 From: ElementBot Date: Mon, 23 Sep 2024 12:28:59 +0000 Subject: [PATCH 2/4] Update screenshots --- compound/screenshots/Avatar Colors - Dark.png | 4 ++-- compound/screenshots/Avatar Colors - Light.png | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compound/screenshots/Avatar Colors - Dark.png b/compound/screenshots/Avatar Colors - Dark.png index 3baf602..7069762 100644 --- a/compound/screenshots/Avatar Colors - Dark.png +++ b/compound/screenshots/Avatar Colors - Dark.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7a08cc01007ac1d1e85ec119e6b428ebf8ac9640560194de94ba9b70910eee8a -size 13410 +oid sha256:80e44e94d7b23af2ec4fd1c5a871851ae2567b40e478b30145de199076f20e95 +size 11296 diff --git a/compound/screenshots/Avatar Colors - Light.png b/compound/screenshots/Avatar Colors - Light.png index 3ee6b4f..7069762 100644 --- a/compound/screenshots/Avatar Colors - Light.png +++ b/compound/screenshots/Avatar Colors - Light.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa2c64328eb84eb999b8c070f11137162a960a59f4b2a080b1602a091e9a513d -size 14109 +oid sha256:80e44e94d7b23af2ec4fd1c5a871851ae2567b40e478b30145de199076f20e95 +size 11296 From 91270a468da390acbb8b7b3e63a0bc927a1851f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 23 Sep 2024 15:17:39 +0200 Subject: [PATCH 3/4] Fix avatar color previews --- .../kotlin/io/element/android/compound/theme/AvatarColors.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compound/src/main/kotlin/io/element/android/compound/theme/AvatarColors.kt b/compound/src/main/kotlin/io/element/android/compound/theme/AvatarColors.kt index 5f846c3..1dc0d8e 100644 --- a/compound/src/main/kotlin/io/element/android/compound/theme/AvatarColors.kt +++ b/compound/src/main/kotlin/io/element/android/compound/theme/AvatarColors.kt @@ -42,8 +42,8 @@ fun avatarColors(): List { @Preview @Composable internal fun AvatarColorsPreviewLight() { - val chunks = avatarColors().chunked(4) ElementTheme { + val chunks = avatarColors().chunked(4) Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { for (chunk in chunks) { AvatarColorRow(chunk) @@ -55,8 +55,8 @@ internal fun AvatarColorsPreviewLight() { @Preview @Composable internal fun AvatarColorsPreviewDark() { - val chunks = avatarColors().chunked(4) ElementTheme(darkTheme = true) { + val chunks = avatarColors().chunked(4) Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { for (chunk in chunks) { AvatarColorRow(chunk) From 5dd7fd48aaeadd910e91ac4d80d9c607e9e04c34 Mon Sep 17 00:00:00 2001 From: ElementBot Date: Mon, 23 Sep 2024 13:19:51 +0000 Subject: [PATCH 4/4] Update screenshots --- compound/screenshots/Avatar Colors - Dark.png | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compound/screenshots/Avatar Colors - Dark.png b/compound/screenshots/Avatar Colors - Dark.png index 7069762..5cf6cbd 100644 --- a/compound/screenshots/Avatar Colors - Dark.png +++ b/compound/screenshots/Avatar Colors - Dark.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:80e44e94d7b23af2ec4fd1c5a871851ae2567b40e478b30145de199076f20e95 -size 11296 +oid sha256:caf2de32caf0fa5368da899297e2eabd5a0c6891dd94f81295ef8a933d79ce16 +size 10751