From a3c2f1538130ebf4b492331b755e6f69b290171f Mon Sep 17 00:00:00 2001 From: Siddharth Agarwal Date: Wed, 4 Sep 2024 13:02:31 +0530 Subject: [PATCH] Fix `MenuItem` Label and supporting text truncate --- .../mobile/ui/designsystem/component/menuItem/MenuItem.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/menuItem/MenuItem.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/menuItem/MenuItem.kt index 40badb3bc..a07976bd9 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/menuItem/MenuItem.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/menuItem/MenuItem.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.testTag +import androidx.compose.ui.text.style.TextOverflow import org.hisp.dhis.mobile.ui.designsystem.component.menuItem.MenuItemTestTags.MENU_ITEM_CONTAINER import org.hisp.dhis.mobile.ui.designsystem.component.menuItem.MenuItemTestTags.MENU_ITEM_DIVIDER import org.hisp.dhis.mobile.ui.designsystem.component.menuItem.MenuItemTestTags.MENU_ITEM_LEADING_ICON @@ -85,6 +86,8 @@ fun MenuItem( modifier = Modifier.weight(1f), ) { Text( + maxLines = if (!menuItemData.supportingText.isNullOrEmpty()) 1 else 2, + overflow = TextOverflow.Ellipsis, modifier = Modifier.testTag(MENU_ITEM_TEXT), style = MaterialTheme.typography.bodyLarge, color = if (menuItemData.style == MenuItemStyle.ALERT) SurfaceColor.Error else TextColor.OnSurface, @@ -92,6 +95,8 @@ fun MenuItem( ) if (!menuItemData.supportingText.isNullOrEmpty()) { Text( + maxLines = 1, + overflow = TextOverflow.Ellipsis, modifier = Modifier.testTag(MENU_ITEM_SUPPORTING_TEXT), style = MaterialTheme.typography.bodyMedium, color = if (menuItemData.style == MenuItemStyle.ALERT) TextColor.OnErrorContainer else TextColor.OnSurfaceVariant,