Skip to content

Commit

Permalink
Fix MenuItem Label and supporting text truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Sep 4, 2024
1 parent 48486fe commit 02b7aab
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,13 +86,17 @@ 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,
text = menuItemData.label,
)
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,
Expand Down

0 comments on commit 02b7aab

Please sign in to comment.