Fix some quality issue

This commit is contained in:
Benoit Marty
2025-10-03 18:50:43 +02:00
committed by Benoit Marty
parent e47da1705e
commit f4773e20db
7 changed files with 20 additions and 13 deletions

View File

@@ -7,7 +7,10 @@
package io.element.android.compound.annotations
@RequiresOptIn("This is a Core color token, which should only be used to declare semantic colors, otherwise it would look the same on both light and dark modes. Only use it as is if you know what you are doing.")
@RequiresOptIn(
message = "This is a Core color token, which should only be used to declare semantic colors, otherwise it" +
" would look the same on both light and dark modes. Only use it as is if you know what you are doing."
)
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
annotation class CoreColorToken

View File

@@ -38,6 +38,8 @@ 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
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
@Preview(widthDp = 730, heightDp = 1800)
@Composable
@@ -90,14 +92,14 @@ private fun IconsCompoundPreview(
}
IconsPreview(
title = title,
content = content.toList(),
content = content.toImmutableList(),
)
}
@Composable
internal fun IconsPreview(
title: String,
content: List<@Composable ColumnScope.() -> Unit>,
content: ImmutableList<@Composable ColumnScope.() -> Unit>,
) = Surface {
Column(
modifier = Modifier
@@ -138,4 +140,4 @@ internal fun IconsPreview(
}
}
}
}
}

View File

@@ -19,7 +19,7 @@ import io.element.android.compound.theme.ElementTheme
@Preview
@Composable
fun TypographyPreview() = ElementTheme {
internal fun TypographyPreview() = ElementTheme {
Surface {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
with(ElementTheme.materialTypography) {

View File

@@ -20,6 +20,8 @@ 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 kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
/**
* Data class to hold avatar colors.
@@ -53,7 +55,7 @@ internal fun AvatarColorsPreviewLight() {
val chunks = avatarColors().chunked(4)
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
for (chunk in chunks) {
AvatarColorRow(chunk)
AvatarColorRow(chunk.toImmutableList())
}
}
}
@@ -66,14 +68,14 @@ internal fun AvatarColorsPreviewDark() {
val chunks = avatarColors().chunked(4)
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
for (chunk in chunks) {
AvatarColorRow(chunk)
AvatarColorRow(chunk.toImmutableList())
}
}
}
}
@Composable
private fun AvatarColorRow(colors: List<AvatarColors>) {
private fun AvatarColorRow(colors: ImmutableList<AvatarColors>) {
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
colors.forEach { color ->
Box(
@@ -88,4 +90,4 @@ private fun AvatarColorRow(colors: List<AvatarColors>) {
}
}
}
}
}

View File

@@ -77,7 +77,7 @@ object ElementTheme {
get() = LocalCompoundColors.current.isLight
}
/* Global variables (application level) */
// Global variables (application level)
internal val LocalCompoundColors = staticCompositionLocalOf { compoundColorsLight }
/**
@@ -100,7 +100,8 @@ fun ElementTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
applySystemBarsUpdate: Boolean = true,
lightStatusBar: Boolean = !darkTheme,
dynamicColor: Boolean = false, /* true to enable MaterialYou */
// true to enable MaterialYou
dynamicColor: Boolean = false,
compoundLight: SemanticColors = compoundColorsLight,
compoundDark: SemanticColors = compoundColorsDark,
materialColorsLight: ColorScheme = compoundLight.toMaterialColorScheme(),

View File

@@ -119,7 +119,6 @@ private fun MaterialPreview(
}
}
@Composable
private fun TextPreview(
name: String,

View File

@@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.map
enum class Theme {
System,
Dark,
Light;
Light,
}
val themes = listOf(Theme.System, Theme.Dark, Theme.Light)