TP-79518|Venkat Praneeth| Addition of overFlow and maxLines properties for spannableTextRenderer (#545)

This commit is contained in:
Venkat Praneeth Reddy
2024-09-04 17:33:58 +05:30
committed by GitHub
parent 588ff9932d
commit 2eba44e3fd
2 changed files with 14 additions and 1 deletions

View File

@@ -13,6 +13,8 @@ data class SpannableProperty(
var includeFontPadding: Boolean? = null,
var brushData: BrushData? = null,
var lineHeight: Float? = null,
var maxLines: Int? = null,
var overflow: String? = null
) : BaseProperty() {
override fun copyNonNullFrom(property: BaseProperty?) {
super.copyNonNullFrom(property)
@@ -22,6 +24,8 @@ data class SpannableProperty(
spannableProperty?.includeFontPadding?.let { includeFontPadding = it }
spannableProperty?.brushData?.let { brushData = it }
spannableProperty?.lineHeight?.let { lineHeight = it }
spannableProperty?.maxLines?.let { maxLines = it }
spannableProperty?.overflow?.let { overflow = it }
}
}

View File

@@ -41,6 +41,7 @@ import com.navi.uitron.utils.clip
import com.navi.uitron.utils.getText
import com.navi.uitron.utils.getTextAlignment
import com.navi.uitron.utils.getTextDecoration
import com.navi.uitron.utils.getTextOverflow
import com.navi.uitron.utils.getTransformedText
import com.navi.uitron.utils.hexToComposeColor
import com.navi.uitron.utils.isNotNull
@@ -137,12 +138,20 @@ class SpannableTextRenderer : Renderer<SpannableProperty> {
// Render
if (spannableData?.textMap.isNotNull()) {
BasicText(text = annotatedString, modifier = textModifier, style = textStyle)
BasicText(
text = annotatedString,
modifier = textModifier,
style = textStyle,
maxLines = property.maxLines ?: Int.MAX_VALUE,
overflow = getTextOverflow(property.overflow)
)
} else {
ClickableText(
text = annotatedString,
modifier = textModifier,
style = textStyle,
maxLines = property.maxLines ?: Int.MAX_VALUE,
overflow = getTextOverflow(property.overflow),
onClick = { offset ->
spannableData?.spanData?.forEach { spanData ->
if (spanData.tag != null) {