Browse Source

trailingContent and supportingContent should be null if there is nothing to display.

pull/2922/head
Benoit Marty 4 months ago
parent
commit
f743934e0f
  1. 64
      libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceText.kt

64
libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceText.kt

@ -82,48 +82,56 @@ fun PreferenceText(
color = tintColor ?: enabled.toEnabledColor(), color = tintColor ?: enabled.toEnabledColor(),
) )
}, },
supportingContent = { supportingContent = if (subtitle != null) {
if (subtitle != null) { {
Text( Text(
style = ElementTheme.typography.fontBodyMdRegular, style = ElementTheme.typography.fontBodyMdRegular,
text = subtitle, text = subtitle,
color = tintColor ?: enabled.toSecondaryEnabledColor(), color = tintColor ?: enabled.toSecondaryEnabledColor(),
) )
} else if (subtitleAnnotated != null) { }
} else if (subtitleAnnotated != null) {
{
Text( Text(
style = ElementTheme.typography.fontBodyMdRegular, style = ElementTheme.typography.fontBodyMdRegular,
text = subtitleAnnotated, text = subtitleAnnotated,
color = tintColor ?: enabled.toSecondaryEnabledColor(), color = tintColor ?: enabled.toSecondaryEnabledColor(),
) )
} }
} else {
null
}, },
trailingContent = ListItemContent.Custom { trailingContent = if (currentValue != null || loadingCurrentValue || showEndBadge) {
Row( ListItemContent.Custom {
verticalAlignment = Alignment.CenterVertically, Row(
) { verticalAlignment = Alignment.CenterVertically,
if (currentValue != null) { ) {
Text( if (currentValue != null) {
text = currentValue, Text(
style = ElementTheme.typography.fontBodyXsMedium, text = currentValue,
color = enabled.toSecondaryEnabledColor(), style = ElementTheme.typography.fontBodyXsMedium,
) color = enabled.toSecondaryEnabledColor(),
} else if (loadingCurrentValue) { )
CircularProgressIndicator( } else if (loadingCurrentValue) {
modifier = Modifier CircularProgressIndicator(
.progressSemantics() modifier = Modifier
.size(20.dp), .progressSemantics()
strokeWidth = 2.dp .size(20.dp),
) strokeWidth = 2.dp
} )
if (showEndBadge) { }
val endBadgeStartPadding = if (currentValue != null || loadingCurrentValue) 16.dp else 0.dp if (showEndBadge) {
RedIndicatorAtom( val endBadgeStartPadding = if (currentValue != null || loadingCurrentValue) 16.dp else 0.dp
modifier = Modifier RedIndicatorAtom(
.padding(start = endBadgeStartPadding) modifier = Modifier
) .padding(start = endBadgeStartPadding)
)
}
} }
} }
}, } else {
null
}
) )
} }

Loading…
Cancel
Save