Skip to content

Commit

Permalink
ANDROID-14416 Allow tint for RowItem icons (#334)
Browse files Browse the repository at this point in the history
* ANDROID-14416 Update. Allow tint for RowItem icons

* ANDROID-14416 Add. Trailing comma and Preview example with new parameter
  • Loading branch information
haynlo authored Mar 7, 2024
1 parent f25e2dd commit 98877ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,13 +31,15 @@ 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(
val painter: Painter? = null,
val backgroundColor: Color = Color.Transparent,
private val description: String? = null,
val modifier: Modifier = Modifier,
val tint: Color? = null,
) : ListRowIcon(description)

data class SmallAsset(
Expand Down Expand Up @@ -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),
)
}
}
Expand All @@ -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),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 98877ee

Please sign in to comment.