From 48d09aac5569d06bde969dac7d0d39845407ae5d Mon Sep 17 00:00:00 2001 From: Xavier Molloy Date: Tue, 18 Jun 2024 09:41:08 +0200 Subject: [PATCH] feat: [ANDROAPP-5739] small corrections --- .../common/screens/previews/ListCardDataSamples.kt | 5 +++-- .../mobile/ui/designsystem/component/ListCard.kt | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/previews/ListCardDataSamples.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/previews/ListCardDataSamples.kt index 9c87e3d20..cb15ba74e 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/previews/ListCardDataSamples.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/previews/ListCardDataSamples.kt @@ -31,7 +31,7 @@ val basicAdditionalItemListWithLongValue = listOf( val enrollmentCompletedList = listOf( AdditionalInfoItem(key = "Phone:", value = "+234 123 111 6785"), AdditionalInfoItem(key = "Date of birth:", value = "12/12/1945"), - AdditionalInfoItem(key = "Address:", value = "134 Main Road, Behind the temple, Citytown, Basil District, Granite State"), + AdditionalInfoItem(key = "Address:", value = "134 Main Road, Behind the temple, Citytown, Basil District"), AdditionalInfoItem(key = "Enrolled in:", value = "12/12/1945"), AdditionalInfoItem( key = lorem, @@ -57,7 +57,7 @@ val teiDetailList = listOf( AdditionalInfoItem(key = "National ID:", value = "001-224-789"), AdditionalInfoItem( key = lorem, - value = "+234 123 111 6785", + value = "+234 554", icon = { Icon( imageVector = Icons.Filled.PhoneEnabled, @@ -70,6 +70,7 @@ val teiDetailList = listOf( ), AdditionalInfoItem(key = lorem, value = lorem), AdditionalInfoItem(key = "Enrolled in:", value = "PHC Blueberry"), + AdditionalInfoItem(value = "PHC Blueberry"), AdditionalInfoItem( key = lorem, value = "Tuberculosis, Nutrition, " + diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/ListCard.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/ListCard.kt index badbf9213..dffb2820f 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/ListCard.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/ListCard.kt @@ -418,7 +418,7 @@ private fun KeyValue( isDetailCard: Boolean = false, modifier: Modifier = Modifier, ) { - BoxWithConstraints(modifier = modifier.fillMaxWidth()) { + BoxWithConstraints(modifier = modifier) { val maxKeyWidth = maxWidth / 2 - Spacing.Spacing16 ProvideKeyValueItem(additionalInfoItem, maxKeyWidth, isDetailCard) } @@ -442,7 +442,7 @@ fun ProvideKeyValueItem(additionalInfoItem: AdditionalInfoItem, maxKeyWidth: Dp, val keyTrimmedText = if (keyWidth > maxKeyWidth) { getKeyTrimmedText(keyText ?: "", maxKeyWidth, textMeasurer) } else { - additionalInfoItem.key ?: " " + additionalInfoItem.key ?: "" } val additionalInfoKey = buildAnnotatedString { @@ -463,7 +463,7 @@ fun ProvideKeyValueItem(additionalInfoItem: AdditionalInfoItem, maxKeyWidth: Dp, withStyle( style = valueStyle, ) { - append(" $valueText") + append(if (keyText?.isNotEmpty() == true) " $valueText" else valueText) } } } @@ -491,7 +491,7 @@ fun ProvideKeyValueItem(additionalInfoItem: AdditionalInfoItem, maxKeyWidth: Dp, ) Row( - modifier = Modifier.fillMaxWidth() + modifier = Modifier .clip(shape = RoundedCornerShape(Radius.XS)) .conditional(additionalInfoItem.action != null && isDetailCard, { clickable( @@ -563,12 +563,12 @@ fun getKeyTrimmedText(text: String, maxKeyWidth: Dp, textMeasurer: TextMeasurer) var trimmedText = remember { text.substring(IntRange(0, lastCharIndex)) } var newKeyWidth = measureTextWidth(trimmedText, textMeasurer) - while (newKeyWidth < maxKeyWidth) { + while (newKeyWidth < maxKeyWidth && lastCharIndex < text.length) { lastCharIndex++ trimmedText = text.substring(IntRange(0, lastCharIndex)) newKeyWidth = measureTextWidth(trimmedText, textMeasurer) } - return trimmedText.dropLast(1) + "...: " + return trimmedText.dropLast(1).trimEnd() + "...: " } enum class