Merge branch 'develop' into feature/fga/user_status_last_pieces

This commit is contained in:
ganfra
2026-08-07 11:35:19 +02:00
629 changed files with 1360 additions and 1361 deletions
@@ -45,7 +45,7 @@ fun AvatarListItem(
) {
ListItem(
modifier = modifier,
headlineContent = { Text(headline) },
content = { Text(headline) },
supportingContent = supportingText?.let { @Composable { Text(it) } },
leadingContent = ListItemContent.Custom { _ ->
Avatar(
@@ -28,7 +28,7 @@ fun CheckboxListItem(
) {
ListItem(
modifier = modifier,
headlineContent = { Text(headline) },
content = { Text(headline) },
supportingContent = supportingText?.let { @Composable { Text(it) } },
leadingContent = ListItemContent.Checkbox(
checked = checked,
@@ -68,7 +68,7 @@ fun MultipleSelectionListItem(
ListItem(
modifier = modifier,
headlineContent = { Text(text = headline) },
content = { Text(text = headline) },
supportingContent = decoratedSupportedText,
leadingContent = leadingContent,
trailingContent = trailingContent,
@@ -28,7 +28,7 @@ fun RadioButtonListItem(
) {
ListItem(
modifier = modifier,
headlineContent = { Text(headline) },
content = { Text(headline) },
supportingContent = supportingText?.let { @Composable { Text(it) } },
leadingContent = ListItemContent.RadioButton(
selected = selected,
@@ -67,7 +67,7 @@ fun SingleSelectionListItem(
ListItem(
modifier = modifier,
headlineContent = { Text(text = headline) },
content = { Text(text = headline) },
supportingContent = decoratedSupportedText,
leadingContent = leadingContent,
trailingContent = trailingContent,
@@ -27,7 +27,7 @@ fun SwitchListItem(
) {
ListItem(
modifier = modifier,
headlineContent = { Text(headline) },
content = { Text(headline) },
supportingContent = supportingText?.let { @Composable { Text(it) } },
leadingContent = leadingContent,
trailingContent = ListItemContent.Switch(
@@ -45,7 +45,7 @@ fun PreferenceCheckbox(
iconResourceId = iconResourceId,
showIconAreaIfNoIcon = showIconAreaIfNoIcon,
),
headlineContent = {
content = {
Text(
style = ElementTheme.typography.fontBodyLgRegular,
text = title,
@@ -66,7 +66,7 @@ fun <T : DropdownOption> PreferenceDropdown(
iconResourceId = iconResourceId,
showIconAreaIfNoIcon = showIconAreaIfNoIcon,
),
headlineContent = {
content = {
Text(
style = ElementTheme.typography.fontBodyLgRegular,
modifier = Modifier.fillMaxWidth(),
@@ -30,7 +30,7 @@ fun PreferenceRow(
) {
ListItem(
modifier = modifier,
headlineContent = {
content = {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
@@ -46,7 +46,7 @@ fun PreferenceSlide(
iconResourceId = iconResourceId,
showIconAreaIfNoIcon = showIconAreaIfNoIcon,
),
headlineContent = {
content = {
Column {
Text(
style = ElementTheme.typography.fontBodyLgRegular,
@@ -44,7 +44,7 @@ fun PreferenceSwitch(
iconResourceId = iconResourceId,
showIconAreaIfNoIcon = showIconAreaIfNoIcon,
),
headlineContent = {
content = {
Text(
style = ElementTheme.typography.fontBodyLgRegular,
text = title,
@@ -42,7 +42,7 @@ fun PreferenceTextField(
ListItem(
modifier = modifier,
headlineContent = { Text(headline) },
content = { Text(headline) },
supportingContent = valueToDisplay?.let { @Composable { Text(it) } },
trailingContent = trailingContent,
style = style,
@@ -35,20 +35,19 @@ import io.element.android.libraries.designsystem.preview.PreviewGroup
/**
* A List Item component to be used in lists and menus with simple layouts, matching the Material 3 guidelines.
* @param headlineContent The main content of the list item, usually a text.
* @param modifier The modifier to be applied to the list item.
* @param supportingContent The content to be displayed below the headline content.
* @param leadingContent The content to be displayed before the headline content.
* @param trailingContent The content to be displayed after the headline content.
* @param supportingContent The content to be displayed below the content.
* @param leadingContent The content to be displayed before the content.
* @param trailingContent The content to be displayed after the content.
* @param style The style to use for the list item. This may change the color and text styles of the contents. [ListItemStyle.Default] is used by default.
* @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.
* @param enabled Whether the list item is enabled. When disabled, will change the color of the content and the leading content to use disabled tokens.
* @param alwaysClickable Whether the list item should always be clickable, even when disabled.
* @param onClick The callback to be called when the list item is clicked.
* @param content The main content of the list item, usually a text.
*/
@Suppress("LongParameterList")
@Composable
fun ListItem(
headlineContent: @Composable () -> Unit,
modifier: Modifier = Modifier,
supportingContent: @Composable (() -> Unit)? = null,
leadingContent: ListItemContent? = null,
@@ -57,19 +56,19 @@ fun ListItem(
enabled: Boolean = true,
alwaysClickable: Boolean = false,
onClick: (() -> Unit)? = null,
content: @Composable () -> Unit,
) {
val colors = ListItemDefaults.colors(
containerColor = Color.Transparent,
headlineColor = style.headlineColor(),
headlineColor = style.contentColor(),
leadingIconColor = style.leadingIconColor(),
trailingIconColor = style.trailingIconColor(),
supportingColor = style.supportingTextColor(),
disabledHeadlineColor = ListItemDefaultColors.headlineDisabled,
disabledHeadlineColor = ListItemDefaultColors.contentDisabled,
disabledLeadingIconColor = ListItemDefaultColors.iconDisabled,
disabledTrailingIconColor = ListItemDefaultColors.iconDisabled,
)
ListItem(
headlineContent = headlineContent,
modifier = modifier,
supportingContent = supportingContent,
leadingContent = leadingContent,
@@ -78,25 +77,25 @@ fun ListItem(
enabled = enabled,
alwaysClickable = alwaysClickable,
onClick = onClick,
content = content,
)
}
/**
* A List Item component to be used in lists and menus with simple layouts, matching the Material 3 guidelines.
* @param headlineContent The main content of the list item, usually a text.
* @param colors The colors to use for the list item. You can use [ListItemDefaults.colors] to create this.
* @param modifier The modifier to be applied to the list item.
* @param supportingContent The content to be displayed below the headline content.
* @param leadingContent The content to be displayed before the headline content.
* @param trailingContent The content to be displayed after the headline content.
* @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.
* @param supportingContent The content to be displayed below the content.
* @param leadingContent The content to be displayed before the content.
* @param trailingContent The content to be displayed after the content.
* @param enabled Whether the list item is enabled. When disabled, will change the color of the content and the leading content to use disabled tokens.
* @param alwaysClickable Whether the list item should always be clickable, even when disabled.
* @param onClick The callback to be called when the list item is clicked.
* @param content The main content of the list item, usually a text.
*/
@Suppress("LongParameterList")
@Composable
fun ListItem(
headlineContent: @Composable () -> Unit,
colors: ListItemColors,
modifier: Modifier = Modifier,
supportingContent: @Composable (() -> Unit)? = null,
@@ -105,53 +104,53 @@ fun ListItem(
enabled: Boolean = true,
alwaysClickable: Boolean = false,
onClick: (() -> Unit)? = null,
content: @Composable () -> Unit,
) {
// We cannot just pass the disabled colors, they must be set manually: https://issuetracker.google.com/issues/280480132
val headlineColor = if (enabled) colors.contentColor else colors.disabledContentColor
val contentColor = if (enabled) colors.contentColor else colors.disabledContentColor
val supportingColor = if (enabled) colors.supportingContentColor else colors.disabledContentColor.copy(alpha = 0.80f)
val leadingContentColor = if (enabled) colors.leadingContentColor else colors.disabledLeadingContentColor
val trailingContentColor = if (enabled) colors.trailingContentColor else colors.disabledTrailingContentColor
val decoratedHeadlineContent: @Composable () -> Unit = {
val decoratedContent: @Composable () -> Unit = {
CompositionLocalProvider(
LocalTextStyle provides ElementTheme.typography.fontBodyLgRegular,
LocalContentColor provides headlineColor,
LocalContentColor provides contentColor,
) {
headlineContent()
content()
}
}
val decoratedSupportingContent: (@Composable () -> Unit)? = supportingContent?.let { content ->
val decoratedSupportingContent: (@Composable () -> Unit)? = supportingContent?.let { safeContent ->
{
CompositionLocalProvider(
LocalTextStyle provides ElementTheme.typography.fontBodyMdRegular,
LocalContentColor provides supportingColor,
) {
content()
safeContent()
}
}
}
val decoratedLeadingContent: (@Composable () -> Unit)? = leadingContent?.let { content ->
val decoratedLeadingContent: (@Composable () -> Unit)? = leadingContent?.let { safeContent ->
{
CompositionLocalProvider(
LocalContentColor provides leadingContentColor,
) {
content.View(isItemEnabled = enabled)
safeContent.View(isItemEnabled = enabled)
}
}
}
val decoratedTrailingContent: (@Composable () -> Unit)? = trailingContent?.let { content ->
val decoratedTrailingContent: (@Composable () -> Unit)? = trailingContent?.let { safeContent ->
{
CompositionLocalProvider(
LocalTextStyle provides ElementTheme.typography.fontBodyMdRegular,
LocalContentColor provides trailingContentColor,
) {
content.View(isItemEnabled = enabled)
safeContent.View(isItemEnabled = enabled)
}
}
}
androidx.compose.material3.ListItem(
headlineContent = decoratedHeadlineContent,
modifier = if (onClick != null) {
Modifier
.clickable(enabled = enabled || alwaysClickable, onClick = onClick)
@@ -169,8 +168,8 @@ fun ListItem(
leadingContent = decoratedLeadingContent,
trailingContent = decoratedTrailingContent,
colors = colors,
tonalElevation = 0.dp,
shadowElevation = 0.dp,
elevation = ListItemDefaults.elevation(elevation = 0.dp),
content = decoratedContent,
)
}
@@ -223,8 +222,8 @@ sealed interface ListItemStyle {
data object Destructive : ListItemStyle
@Composable
fun headlineColor() = when (this) {
Default, Primary -> ListItemDefaultColors.headline
fun contentColor() = when (this) {
Default, Primary -> ListItemDefaultColors.content
Destructive -> ElementTheme.colors.textCriticalPrimary
}
@@ -251,8 +250,8 @@ sealed interface ListItemStyle {
}
object ListItemDefaultColors {
val headline: Color @Composable get() = ElementTheme.colors.textPrimary
val headlineDisabled: Color @Composable get() = ElementTheme.colors.textDisabled
val content: Color @Composable get() = ElementTheme.colors.textPrimary
val contentDisabled: Color @Composable get() = ElementTheme.colors.textDisabled
val supportingText: Color @Composable get() = ElementTheme.materialColors.onSurfaceVariant
val leadingIcon: Color @Composable get() = ElementTheme.colors.iconSecondary
val trailingIcon: Color @Composable get() = ElementTheme.colors.iconPrimary
@@ -260,11 +259,11 @@ object ListItemDefaultColors {
val colors: ListItemColors
@Composable get() = ListItemDefaults.colors(
headlineColor = headline,
headlineColor = content,
supportingColor = supportingText,
leadingIconColor = leadingIcon,
trailingIconColor = trailingIcon,
disabledHeadlineColor = headlineDisabled,
disabledHeadlineColor = contentDisabled,
disabledLeadingIconColor = iconDisabled,
disabledTrailingIconColor = iconDisabled,
)
@@ -523,7 +522,7 @@ private object PreviewItems {
) {
EnabledDisabledElementThemedPreview {
ListItem(
headlineContent = headline(),
content = content(),
supportingContent = text(),
leadingContent = leadingContent,
trailingContent = trailingContent,
@@ -543,7 +542,7 @@ private object PreviewItems {
) {
EnabledDisabledElementThemedPreview {
ListItem(
headlineContent = headline(),
content = content(),
supportingContent = textSingleLine(),
leadingContent = leadingContent,
trailingContent = trailingContent,
@@ -563,7 +562,7 @@ private object PreviewItems {
) {
EnabledDisabledElementThemedPreview {
ListItem(
headlineContent = headline(),
content = content(),
leadingContent = leadingContent,
trailingContent = trailingContent,
enabled = it,
@@ -574,7 +573,7 @@ private object PreviewItems {
}
@Composable
fun headline() = @Composable {
fun content() = @Composable {
Text("List item")
}
@@ -134,7 +134,7 @@ internal fun ListSupportingTextNoPaddingPreview() {
internal fun ListSupportingTextDefaultPaddingPreview() {
ElementThemedPreview {
Column {
ListItem(headlineContent = { Text("A title") })
ListItem(content = { Text("A title") })
ListSupportingText(
text = "Supporting line text lorem ipsum dolor sit amet, consectetur. Read more",
contentPadding = ListSupportingTextDefaults.Padding.Default,
@@ -149,7 +149,7 @@ internal fun ListSupportingTextSmallPaddingPreview() {
ElementThemedPreview {
Column {
ListItem(
headlineContent = { Text("A title") },
content = { Text("A title") },
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.ShareAndroid()))
)
ListSupportingText(
@@ -165,7 +165,7 @@ internal fun ListSupportingTextSmallPaddingPreview() {
internal fun ListSupportingTextLargePaddingPreview() {
ElementThemedPreview {
Column {
ListItem(headlineContent = { Text("A title") }, leadingContent = ListItemContent.Switch(checked = true))
ListItem(content = { Text("A title") }, leadingContent = ListItemContent.Switch(checked = true))
ListSupportingText(
text = "Supporting line text lorem ipsum dolor sit amet, consectetur. Read more",
contentPadding = ListSupportingTextDefaults.Padding.LargeLeadingContent,
@@ -179,7 +179,7 @@ internal fun ListSupportingTextLargePaddingPreview() {
internal fun ListSupportingTextCustomPaddingPreview() {
ElementThemedPreview {
Column {
ListItem(headlineContent = { Text("A title") })
ListItem(content = { Text("A title") })
ListSupportingText(
text = "Supporting line text lorem ipsum dolor sit amet, consectetur. Read more",
contentPadding = ListSupportingTextDefaults.Padding.Custom(24.dp),
@@ -96,7 +96,7 @@ private fun AvatarActionBottomSheetContent(
) { action ->
ListItem(
modifier = Modifier.clickable { onActionClick(action) },
headlineContent = {
content = {
Text(
text = stringResource(action.titleResId),
style = ElementTheme.typography.fontBodyLgRegular,
@@ -113,14 +113,14 @@ fun MediaDetailsBottomSheet(
}
ListItem(
leadingContent = icon,
headlineContent = { Text(wording) },
content = { Text(wording) },
onClick = {
onOpenWith(state.eventId)
}
)
ListItem(
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.VisibilityOn())),
headlineContent = { Text(stringResource(CommonStrings.action_view_in_timeline)) },
content = { Text(stringResource(CommonStrings.action_view_in_timeline)) },
onClick = {
onViewInTimeline(state.eventId)
}
@@ -128,14 +128,14 @@ fun MediaDetailsBottomSheet(
if (state.fromGallery) {
ListItem(
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.ShareAndroid())),
headlineContent = { Text(stringResource(CommonStrings.action_share)) },
content = { Text(stringResource(CommonStrings.action_share)) },
onClick = {
onShare(state.eventId)
}
)
ListItem(
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Download())),
headlineContent = { Text(stringResource(CommonStrings.action_download)) },
content = { Text(stringResource(CommonStrings.action_download)) },
onClick = {
onDownload(state.eventId)
}
@@ -143,7 +143,7 @@ fun MediaDetailsBottomSheet(
}
ListItem(
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Forward())),
headlineContent = { Text(stringResource(CommonStrings.action_forward)) },
content = { Text(stringResource(CommonStrings.action_forward)) },
onClick = {
onForward(state.eventId)
}
@@ -152,7 +152,7 @@ fun MediaDetailsBottomSheet(
HorizontalDivider()
ListItem(
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Delete())),
headlineContent = { Text(stringResource(CommonStrings.action_delete_file)) },
content = { Text(stringResource(CommonStrings.action_delete_file)) },
style = ListItemStyle.Destructive,
onClick = {
onDelete(state.eventId)
@@ -179,7 +179,7 @@ private fun EditLinkDialog(
}
item {
ListItem(
headlineContent = {
content = {
Text(
text = stringResource(R.string.rich_text_editor_remove_link),
color = ElementTheme.colors.textCriticalPrimary
@@ -68,7 +68,7 @@ private fun ColumnScope.TroubleshootTestView(
val status = testState.status
if ((status as? Status.Idle)?.visible == false) return
ListItem(
headlineContent = { Text(text = testState.name) },
content = { Text(text = testState.name) },
supportingContent = { Text(text = testState.description) },
trailingContent = when (status) {
is Status.Idle -> null
@@ -108,7 +108,7 @@ private fun ColumnScope.TroubleshootTestView(
)
if (status is Status.Failure && status.hasQuickFix) {
ListItem(
headlineContent = { },
content = { },
trailingContent = ListItemContent.Custom {
Button(
text = status.quickFixButtonString ?: stringResource(id = R.string.troubleshoot_notifications_screen_quick_fix_action),
@@ -137,7 +137,7 @@ private fun ColumnScope.TroubleshootNotificationsContent(state: TroubleshootNoti
}
when (state.testSuiteState.mainState) {
AsyncAction.Uninitialized -> {
ListItem(headlineContent = {
ListItem(content = {
Text(
text = stringResource(id = R.string.troubleshoot_notifications_screen_notice)
)
@@ -146,20 +146,20 @@ private fun ColumnScope.TroubleshootNotificationsContent(state: TroubleshootNoti
}
AsyncAction.Loading -> Unit
is AsyncAction.Failure -> {
ListItem(headlineContent = {
ListItem(content = {
Text(text = stringResource(id = R.string.troubleshoot_notifications_screen_failure))
})
RunTestButton(state = state)
}
is AsyncAction.Confirming -> {
ListItem(headlineContent = {
ListItem(content = {
Text(
text = stringResource(id = R.string.troubleshoot_notifications_screen_waiting)
)
})
}
is AsyncAction.Success -> {
ListItem(headlineContent = {
ListItem(content = {
Text(
text = stringResource(id = R.string.troubleshoot_notifications_screen_success)
)
@@ -171,7 +171,7 @@ private fun ColumnScope.TroubleshootNotificationsContent(state: TroubleshootNoti
@Composable
private fun RunTestButton(state: TroubleshootNotificationsState) {
ListItem(
headlineContent = {
content = {
Button(
text = stringResource(
id = if (state.testSuiteState.mainState is AsyncAction.Failure) {
@@ -156,7 +156,7 @@ private fun PushHistoryContent(
modifier = modifier.fillMaxWidth()
) {
ListItem(
headlineContent = { Text("Total number of received push") },
content = { Text("Total number of received push") },
trailingContent = ListItemContent.Text(state.pushCounter.toString()),
)
LazyColumn(