Skip to content

Commit b2c7ea0

Browse files
committed
Design : allow passing ListItemColor to ListItem composable to customise as you want.
1 parent d22d9f0 commit b2c7ea0

File tree

1 file changed

+34
-0
lines changed
  • libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components

1 file changed

+34
-0
lines changed

libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/ListItem.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,41 @@ fun ListItem(
6565
disabledLeadingIconColor = ListItemDefaultColors.iconDisabled,
6666
disabledTrailingIconColor = ListItemDefaultColors.iconDisabled,
6767
)
68+
ListItem(
69+
headlineContent = headlineContent,
70+
modifier = modifier,
71+
supportingContent = supportingContent,
72+
leadingContent = leadingContent,
73+
trailingContent = trailingContent,
74+
colors = colors,
75+
enabled = enabled,
76+
onClick = onClick,
77+
)
78+
}
6879

80+
/**
81+
* A List Item component to be used in lists and menus with simple layouts, matching the Material 3 guidelines.
82+
* @param headlineContent The main content of the list item, usually a text.
83+
* @param modifier The modifier to be applied to the list item.
84+
* @param supportingContent The content to be displayed below the headline content.
85+
* @param leadingContent The content to be displayed before the headline content.
86+
* @param trailingContent The content to be displayed after the headline content.
87+
* @param colors The colors to use for the list item.
88+
* @param enabled Whether the list item is enabled. When disabled, will change the color of the headline content and the leading content to use disabled tokens.
89+
* @param onClick The callback to be called when the list item is clicked.
90+
*/
91+
@Suppress("LongParameterList")
92+
@Composable
93+
fun ListItem(
94+
headlineContent: @Composable () -> Unit,
95+
colors: ListItemColors,
96+
modifier: Modifier = Modifier,
97+
supportingContent: @Composable (() -> Unit)? = null,
98+
leadingContent: ListItemContent? = null,
99+
trailingContent: ListItemContent? = null,
100+
enabled: Boolean = true,
101+
onClick: (() -> Unit)? = null,
102+
) {
69103
// We cannot just pass the disabled colors, they must be set manually: https://issuetracker.google.com/issues/280480132
70104
val headlineColor = if (enabled) colors.headlineColor else colors.disabledHeadlineColor
71105
val leadingContentColor = if (enabled) colors.leadingIconColor else colors.disabledLeadingIconColor

0 commit comments

Comments
 (0)