Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-android-max-lines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'voltra': patch
---

Fix `maxLines` text truncation on Android widgets so line limits apply correctly.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ fun RenderText(
val text = extractTextFromNode(element.c)
val renderAsBitmap = element.p?.get("renderAsBitmap") as? Boolean ?: false
val textStyle = resolvedStyle?.text ?: voltra.styling.TextStyle.Default
val maxLines =
(element.p?.get("maxLines") as? Number)?.toInt()
?: textStyle.lineLimit
?: Int.MAX_VALUE

if (renderAsBitmap && textStyle.fontFamily != null) {
val context = LocalContext.current
Expand All @@ -67,6 +71,7 @@ fun RenderText(
val bitmapTextStyle =
textStyle.copy(
color = textStyle.color?.let { VoltraColorValue.Static(it.resolveColor(context)) },
lineLimit = maxLines,
)
// Use screen width as max constraint
val maxWidthPx = (context.resources.displayMetrics.widthPixels * 0.9f).toInt()
Expand Down Expand Up @@ -95,7 +100,7 @@ fun RenderText(
}

val glanceTextStyle = textStyle.toGlanceTextStyle()
Text(text = text, modifier = finalModifier, style = glanceTextStyle)
Text(text = text, modifier = finalModifier, style = glanceTextStyle, maxLines = maxLines)
}

@Composable
Expand Down
Loading