From 98877ee32650206bbc37e36faeb53779cc0126d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Lid=C3=B3n?= Date: Thu, 7 Mar 2024 11:28:12 +0100 Subject: [PATCH] ANDROID-14416 Allow tint for RowItem icons (#334) * ANDROID-14416 Update. Allow tint for RowItem icons * ANDROID-14416 Add. Trailing comma and Preview example with new parameter --- .../com/telefonica/mistica/compose/list/ListRowIcon.kt | 10 ++++++++-- .../com/telefonica/mistica/compose/list/ListRowItem.kt | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/telefonica/mistica/compose/list/ListRowIcon.kt b/library/src/main/java/com/telefonica/mistica/compose/list/ListRowIcon.kt index c6d61ff77..6c7b2104c 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/list/ListRowIcon.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/list/ListRowIcon.kt @@ -9,6 +9,8 @@ import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Icon +import androidx.compose.material.LocalContentAlpha +import androidx.compose.material.LocalContentColor import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -29,6 +31,7 @@ sealed class ListRowIcon(val contentDescription: String?) { val painter: Painter? = null, private val description: String? = null, val modifier: Modifier = Modifier, + val tint: Color? = null, ) : ListRowIcon(description) data class CircleIcon( @@ -36,6 +39,7 @@ sealed class ListRowIcon(val contentDescription: String?) { val backgroundColor: Color = Color.Transparent, private val description: String? = null, val modifier: Modifier = Modifier, + val tint: Color? = null, ) : ListRowIcon(description) data class SmallAsset( @@ -88,7 +92,8 @@ sealed class ListRowIcon(val contentDescription: String?) { Icon( painter = painter, modifier = Modifier.size(24.dp), - contentDescription = contentDescription + contentDescription = contentDescription, + tint = tint ?: LocalContentColor.current.copy(alpha = LocalContentAlpha.current), ) } } @@ -104,7 +109,8 @@ sealed class ListRowIcon(val contentDescription: String?) { painter?.let { Icon( painter = painter, - contentDescription = contentDescription + contentDescription = contentDescription, + tint = tint ?: LocalContentColor.current.copy(alpha = LocalContentAlpha.current), ) } } diff --git a/library/src/main/java/com/telefonica/mistica/compose/list/ListRowItem.kt b/library/src/main/java/com/telefonica/mistica/compose/list/ListRowItem.kt index a61b11d9e..920239eab 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/list/ListRowItem.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/list/ListRowItem.kt @@ -304,9 +304,10 @@ fun ListRowItemPreview() { subtitle = "Subtitle", description = "Description", listRowIcon = ListRowIcon.CircleIcon( - painter = painterResource(id = R.drawable.icn_arrow), + painter = painterResource(id = R.drawable.icn_creditcard), backgroundColor = MisticaTheme.colors.neutralLow, - description = null + description = null, + tint = Color.Red ), trailing = { Checkbox(