Fix icon color.

Leading icon should be iconSecondary
Trailing icon should be iconPrimary
See Figma https://www.figma.com/design/G1xy0HDZKJf5TCRFmKb5d5/Compound-Android-Components?node-id=628-25757
This commit is contained in:
Benoit Marty
2025-03-05 11:42:05 +01:00
parent f820a210eb
commit 7d85c0bfa3
3 changed files with 26 additions and 7 deletions

View File

@@ -28,3 +28,21 @@ fun Boolean.toSecondaryEnabledColor(): Color {
ElementTheme.colors.textDisabled
}
}
@Composable
fun Boolean.toIconEnabledColor(): Color {
return if (this) {
ElementTheme.colors.iconPrimary
} else {
ElementTheme.colors.iconDisabled
}
}
@Composable
fun Boolean.toIconSecondaryEnabledColor(): Color {
return if (this) {
ElementTheme.colors.iconSecondary
} else {
ElementTheme.colors.iconDisabled
}
}

View File

@@ -25,7 +25,7 @@ import io.element.android.libraries.designsystem.components.list.ListItemContent
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
import io.element.android.libraries.designsystem.preview.PreviewGroup
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.toSecondaryEnabledColor
import io.element.android.libraries.designsystem.toIconSecondaryEnabledColor
@Composable
fun preferenceIcon(
@@ -68,7 +68,7 @@ private fun PreferenceIcon(
imageVector = icon,
resourceId = iconResourceId,
contentDescription = null,
tint = tintColor ?: enabled.toSecondaryEnabledColor(),
tint = tintColor ?: enabled.toIconSecondaryEnabledColor(),
modifier = Modifier
.size(24.dp),
)

View File

@@ -193,14 +193,14 @@ sealed interface ListItemStyle {
@Composable
fun leadingIconColor() = when (this) {
Default -> ListItemDefaultColors.icon
Default -> ListItemDefaultColors.leadingIcon
Primary -> ElementTheme.colors.iconPrimary
Destructive -> ElementTheme.colors.iconCriticalPrimary
}
@Composable
fun trailingIconColor() = when (this) {
Default -> ListItemDefaultColors.icon
Default -> ListItemDefaultColors.trailingIcon
Primary -> ElementTheme.colors.iconPrimary
Destructive -> ElementTheme.colors.iconCriticalPrimary
}
@@ -210,15 +210,16 @@ object ListItemDefaultColors {
val headline: Color @Composable get() = ElementTheme.colors.textPrimary
val headlineDisabled: Color @Composable get() = ElementTheme.colors.textDisabled
val supportingText: Color @Composable get() = ElementTheme.materialColors.onSurfaceVariant
val icon: Color @Composable get() = ElementTheme.colors.iconTertiary
val leadingIcon: Color @Composable get() = ElementTheme.colors.iconSecondary
val trailingIcon: Color @Composable get() = ElementTheme.colors.iconPrimary
val iconDisabled: Color @Composable get() = ElementTheme.colors.iconDisabled
val colors: ListItemColors
@Composable get() = ListItemDefaults.colors(
headlineColor = headline,
supportingColor = supportingText,
leadingIconColor = icon,
trailingIconColor = icon,
leadingIconColor = leadingIcon,
trailingIconColor = trailingIcon,
disabledHeadlineColor = headlineDisabled,
disabledLeadingIconColor = iconDisabled,
disabledTrailingIconColor = iconDisabled,