diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ExpandableListCardScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ExpandableListCardScreen.kt index e4afe9359..082575718 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ExpandableListCardScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ExpandableListCardScreen.kt @@ -8,7 +8,7 @@ import androidx.compose.material.icons.outlined.SyncDisabled import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import org.hisp.dhis.common.screens.previews.lorem_medium +import org.hisp.dhis.common.screens.previews.lorem import org.hisp.dhis.mobile.ui.designsystem.component.AdditionalInfoItem import org.hisp.dhis.mobile.ui.designsystem.component.Avatar import org.hisp.dhis.mobile.ui.designsystem.component.AvatarStyleData @@ -51,8 +51,9 @@ fun ExpandableListCardScreen() { } add( AdditionalInfoItem( - value = lorem_medium, + value = lorem, color = TextColor.OnSurfaceLight, + truncate = false, ), ) } diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BaseCard.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BaseCard.kt index 0561ab189..2ad2d587a 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BaseCard.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BaseCard.kt @@ -105,7 +105,8 @@ fun BaseCard( fun ExpandableItemColumn( modifier: Modifier = Modifier, itemList: List, - itemSpacing: Dp = 16.dp, + itemSpacing: Dp = Spacing16, + contentPadding: Dp = Spacing16, itemLayout: @Composable (T, itemVerticalPadding: Dp, onSizeChanged: (IntSize) -> Unit) -> Unit, ) { val density = LocalDensity.current @@ -123,8 +124,11 @@ fun ExpandableItemColumn( val itemVerticalPadding by remember(childrenSize) { derivedStateOf { val value = if (childrenSize.size == itemCount) { - var availableHeight = - parentSize - childrenSize.values.sum() - with(density) { itemSpacing.toPx() * (itemCount - 1) } + var availableHeight = parentSize - + childrenSize.values.sum() - + with(density) { + itemSpacing.toPx() * (itemCount - 1) + contentPadding.toPx() * 2 + } if (itemCount == 1) availableHeight /= 4 with(density) { (availableHeight / (2 * itemCount)).toDp() }.takeIf { it >= 16.dp } ?: 16.dp @@ -143,7 +147,7 @@ fun ExpandableItemColumn( } }, verticalArrangement = spacedBy(itemSpacing), - contentPadding = PaddingValues(Spacing16), + contentPadding = PaddingValues(contentPadding), ) { itemList.forEachIndexed { index, item -> item { 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 4e840ce20..fa4e3e839 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 @@ -119,7 +119,9 @@ fun ListCard( ) listCardState.lastUpdateBasedOnLoading()?.let { ListCardLastUpdated(it) } } - listCardState.descriptionBasedOnLoading()?.let { ListCardDescription(it, Modifier) } + listCardState.descriptionBasedOnLoading()?.let { + ListCardDescription(it, Modifier.padding(bottom = Spacing.Spacing8)) + } AdditionalInfoColumn( additionalInfoColumnState = listCardState.additionalInfoColumnState, @@ -256,7 +258,7 @@ fun VerticalInfoListCard( Column( modifier = Modifier.wrapContentHeight(), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = spacedBy(Spacing.Spacing4), + verticalArrangement = spacedBy(Spacing4), ) { ListCardTitle( title = listCardState.title, @@ -264,7 +266,7 @@ fun VerticalInfoListCard( .padding(bottom = if (listCardState.description?.text != null) Spacing.Spacing0 else Spacing4), ) listCardState.descriptionBasedOnLoading()?.let { - ListCardDescription(it, Modifier) + ListCardDescription(it) } listCardState.lastUpdateBasedOnLoading()?.let { ListCardLastUpdated(it) @@ -673,8 +675,14 @@ fun ProvideKeyValueItem( text = finalAnnotatedString, textAlign = TextAlign.Start, style = MaterialTheme.typography.bodyMedium, - overflow = TextOverflow.Ellipsis, - maxLines = 2, + overflow = when { + additionalInfoItem.truncate -> TextOverflow.Ellipsis + else -> TextOverflow.Clip + }, + maxLines = when { + additionalInfoItem.truncate -> 2 + else -> Int.MAX_VALUE + }, modifier = Modifier, ) @@ -811,6 +819,7 @@ data class AdditionalInfoItem( val value: String, val isConstantItem: Boolean = false, val color: Color? = null, + val truncate: Boolean = true, val action: (() -> Unit)? = null, ) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Text.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Text.kt index 9e07b66af..71269f396 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Text.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Text.kt @@ -151,7 +151,7 @@ internal fun ListCardDescription( description.text, color = description.color ?: TextColor.OnSurface, style = description.style ?: MaterialTheme.typography.bodyMedium, - modifier = modifier.padding(bottom = Spacing.Spacing8), + modifier = modifier, ) } } diff --git a/designsystem/src/test/snapshots/images/org.hisp.dhis.mobile.ui.designsystem_ExpandableItemColumnSnapshotTest_launchAvatarTest.png b/designsystem/src/test/snapshots/images/org.hisp.dhis.mobile.ui.designsystem_ExpandableItemColumnSnapshotTest_launchAvatarTest.png index 32085bdc3..82d3bcdc1 100644 Binary files a/designsystem/src/test/snapshots/images/org.hisp.dhis.mobile.ui.designsystem_ExpandableItemColumnSnapshotTest_launchAvatarTest.png and b/designsystem/src/test/snapshots/images/org.hisp.dhis.mobile.ui.designsystem_ExpandableItemColumnSnapshotTest_launchAvatarTest.png differ