"Added support for Text Alignment in Spannable Text in UITRON" (#196)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.navi.uitron.model.ui
|
||||
|
||||
data class SpannableProperty(
|
||||
var textAlign: String? = null,
|
||||
val spanProperty: List<SpanProperty>
|
||||
) : BaseProperty()
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.layoutId
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.unit.sp
|
||||
@@ -19,6 +20,7 @@ import com.navi.uitron.model.ui.SpannableProperty
|
||||
import com.navi.uitron.utils.EMPTY
|
||||
import com.navi.uitron.viewmodel.UiTronViewModel
|
||||
import getText
|
||||
import getTextAlignment
|
||||
import getTextDecoration
|
||||
import getTransformedText
|
||||
import hexToComposeColor
|
||||
@@ -144,7 +146,10 @@ class SpannableTextRenderer : Renderer<SpannableProperty> {
|
||||
property.backgroundColor, property.shape, property.backGroundBrushData
|
||||
)
|
||||
.setPadding(property.padding)
|
||||
.alpha(property.alpha ?: 1.0f)
|
||||
.alpha(property.alpha ?: 1.0f),
|
||||
style = TextStyle(
|
||||
textAlign = getTextAlignment(property.textAlign)
|
||||
)
|
||||
)
|
||||
} ?: run {
|
||||
ClickableText(text = annotatedString,
|
||||
@@ -156,6 +161,9 @@ class SpannableTextRenderer : Renderer<SpannableProperty> {
|
||||
)
|
||||
.setPadding(property.padding)
|
||||
.alpha(property.alpha ?: 1.0f),
|
||||
style = TextStyle(
|
||||
textAlign = getTextAlignment(property.textAlign)
|
||||
),
|
||||
onClick = { offset ->
|
||||
spannableData?.spanData?.forEach { spanData ->
|
||||
if (spanData.tag != null) {
|
||||
|
||||
Reference in New Issue
Block a user