TP-00000 || Visual Transformation support for TextRenderer (#134)

* TP-00000 || Visual Transformation support for TextRenderer

* TP-00000 || Visual Text Format

* TP-00000 || Resolved PR comments
This commit is contained in:
Sangaraboina Rishvik Vardhan
2023-07-25 14:57:44 +05:30
committed by GitHub
parent d098878996
commit de9c6fb25d
6 changed files with 15 additions and 4 deletions

View File

@@ -24,7 +24,8 @@ data class TextProperty(
var overflow: String? = null,
var softWrap: Boolean? = null,
var maxLines : Int? = null,
var textBrushData: BrushData? = null
var textBrushData: BrushData? = null,
var valueTransformation: OutlinedTextFieldValueTransformation? = null
) : BaseProperty() {
override fun copyNonNullFrom(property: BaseProperty?) {
super.copyNonNullFrom(property)
@@ -42,5 +43,6 @@ data class TextProperty(
textProperty?.softWrap?.let { softWrap = it }
textProperty?.maxLines?.let { maxLines = it }
textProperty?.textBrushData?.let { textBrushData = it }
textProperty?.valueTransformation?.let { valueTransformation = it }
}
}

View File

@@ -271,7 +271,8 @@ enum class VisualTransformationType {
enum class InputTransformationType {
NUMBER_TO_WORDS,
DOB_TO_READABLE_STRING
DOB_TO_READABLE_STRING,
MONEY_WITH_RUPEE_SYMBOL
}
enum class GravityType {

View File

@@ -35,6 +35,7 @@ import getText
import getTextAlignment
import getTextDecoration
import getTextOverflow
import getTransformedText
import hexToComposeColor
import orFalse
import orTrue
@@ -86,7 +87,7 @@ class TextRenderer : Renderer<TextProperty> {
if (property.visible.orTrue()) {
Text(
text = uiTronTextData?.text?.getText(uiTronTextData.textFormatter).orEmpty(),
text = (getTransformedText(property.valueTransformation, uiTronTextData?.text.orEmpty())?:uiTronTextData?.text)?.getText(uiTronTextData?.textFormatter).orEmpty(),
fontFamily = UiTronSdkManager.getDependencyProvider()
.getFontFamily(property.fontFamily),
fontWeight = UiTronSdkManager.getDependencyProvider()

View File

@@ -297,6 +297,7 @@ fun getTransformedText(
inputText,
valueTransformation.formatPattern
)
InputTransformationType.MONEY_WITH_RUPEE_SYMBOL.name -> moneyFormat(inputText).let { "$it" }
else -> null
}
} ?: return null

View File

@@ -118,6 +118,12 @@ private fun getDateValueIndices(
"yyyy" -> IntRange(0, 3)
else -> IntRange(-1, -1)
}
"yyyy-MM-dd"-> when (dateType) {
"dd" -> IntRange(8, inputLength - 1)
"MM" -> IntRange(5, 6)
"yyyy" -> IntRange(0, 3)
else -> IntRange(-1, -1)
}
else -> IntRange(0, 0)
}
}

View File

@@ -28,7 +28,7 @@ class NumberCommaTransformation : VisualTransformation {
}
}
private fun moneyFormat(value: String): String {
fun moneyFormat(value: String): String {
if (value.isEmpty()) return value
var tempValue = value.toDoubleWithSafe().toLong().toString()
var result = ""