TP-56907 add include font padding property in text renderer (#330)

This commit is contained in:
Hitesh Kumar
2024-02-15 15:27:09 +05:30
committed by GitHub
parent c7b89e7448
commit 027d702a36
12 changed files with 50 additions and 11 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 129 B

View File

@@ -59,7 +59,8 @@ data class OutlinedTextFieldTextStyle(
val color: String? = null,
val fontFamily: String? = null,
val fontWeight: String? = null,
val textAlign: String? = null
val textAlign: String? = null,
var includeFontPadding: Boolean? = null
)
data class OutlinedTextFieldColors(

View File

@@ -2,7 +2,8 @@ package com.navi.uitron.model.ui
data class SpannableProperty(
var textAlign: String? = null,
val spanProperty: List<SpanProperty>
val spanProperty: List<SpanProperty>,
var includeFontPadding: Boolean? = null
) : BaseProperty()
data class SpanProperty(

View File

@@ -26,7 +26,8 @@ data class TextProperty(
var maxLines : Int? = null,
var textBrushData: BrushData? = null,
var valueTransformation: OutlinedTextFieldValueTransformation? = null,
var textShadow: TextShadow? = null
var textShadow: TextShadow? = null,
var includeFontPadding: Boolean? = null
) : BaseProperty() {
override fun copyNonNullFrom(property: BaseProperty?) {
super.copyNonNullFrom(property)
@@ -45,6 +46,7 @@ data class TextProperty(
textProperty?.maxLines?.let { maxLines = it }
textProperty?.textBrushData?.let { textBrushData = it }
textProperty?.valueTransformation?.let { valueTransformation = it }
textProperty?.includeFontPadding?.let { includeFontPadding = it }
}
data class TextShadow(

View File

@@ -41,6 +41,7 @@ import androidx.compose.ui.platform.LocalTextToolbar
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.TextToolbar
import androidx.compose.ui.platform.TextToolbarStatus
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
@@ -287,7 +288,10 @@ class CustomTextFieldRenderer(
fontFamily = UiTronSdkManager.getDependencyProvider()
.getFontFamily(property.inputTextProperty?.textStyle?.fontFamily),
fontWeight = UiTronSdkManager.getDependencyProvider()
.getFontWeight(property.inputTextProperty?.textStyle?.fontWeight)
.getFontWeight(property.inputTextProperty?.textStyle?.fontWeight),
platformStyle = PlatformTextStyle(
includeFontPadding = property.inputTextProperty?.textStyle?.includeFontPadding.orTrue()
)
),
keyboardOptions = KeyboardOptions(
capitalization = KeyboardUtil.getKeyboardCapitalization(property.keyboardOptions?.capitalization),

View File

@@ -31,6 +31,7 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
@@ -212,7 +213,10 @@ class JackpotTextRendererV2 : Renderer<JackpotTextProperty> {
textDecoration = getTextDecoration(property.textProperty?.textDecoration),
letterSpacing = property.textProperty?.letterSpacing?.sp ?: 0.sp,
style = TextStyle(
textAlign = TextAlign.Center
textAlign = TextAlign.Center,
platformStyle = PlatformTextStyle(
includeFontPadding = property.textProperty?.includeFontPadding.orTrue()
)
),
modifier = Modifier
.widthIn(

View File

@@ -40,6 +40,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextAlign
@@ -344,7 +345,10 @@ class OtpBoxRenderer : Renderer<OtpBoxProperty> {
.getFontFamily(property.inputTextProperty?.textStyle?.fontFamily),
fontWeight = UiTronSdkManager.getDependencyProvider()
.getFontWeight(property.inputTextProperty?.textStyle?.fontWeight),
textAlign = TextAlign.Center
textAlign = TextAlign.Center,
platformStyle = PlatformTextStyle(
includeFontPadding = property.inputTextProperty?.textStyle?.includeFontPadding.orTrue()
)
),
keyboardOptions = KeyboardOptions(
capitalization = KeyboardUtil.getKeyboardCapitalization(property.keyboardOptions?.capitalization),

View File

@@ -24,6 +24,7 @@ import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
@@ -149,7 +150,10 @@ class OutlinedTextFieldRenderer(
fontFamily = UiTronSdkManager.getDependencyProvider()
.getFontFamily(property.textStyle.fontFamily),
fontWeight = UiTronSdkManager.getDependencyProvider()
.getFontWeight(property.textStyle.fontWeight)
.getFontWeight(property.textStyle.fontWeight),
platformStyle = PlatformTextStyle(
includeFontPadding = property.textStyle.includeFontPadding.orTrue()
)
),
keyboardOptions = KeyboardOptions(
capitalization = KeyboardUtil.getKeyboardCapitalization(property.keyboardOptions?.capitalization),

View File

@@ -47,6 +47,7 @@ import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
@@ -368,7 +369,10 @@ class SlideToActButtonRenderer(
.layoutId(property.layoutId.orEmpty())
.alpha(visibility),
style = TextStyle(
brush = shimmerBrush(showShimmer = showShimmer, property.shimmerColors)
brush = shimmerBrush(showShimmer = showShimmer, property.shimmerColors),
platformStyle = PlatformTextStyle(
includeFontPadding = property.textProperty?.includeFontPadding.orTrue()
)
)
)
AnimatedVisibility(

View File

@@ -10,6 +10,7 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.buildAnnotatedString
@@ -172,7 +173,10 @@ class SpannableTextRenderer : Renderer<SpannableProperty> {
id = property.layoutId.orEmpty()
)},
style = TextStyle(
textAlign = getTextAlignment(property.textAlign)
textAlign = getTextAlignment(property.textAlign),
platformStyle = PlatformTextStyle(
includeFontPadding = property.includeFontPadding.orTrue()
)
)
)
} ?: run {
@@ -197,7 +201,10 @@ class SpannableTextRenderer : Renderer<SpannableProperty> {
.alpha(property.alpha ?: 1.0f)
},
style = TextStyle(
textAlign = getTextAlignment(property.textAlign)
textAlign = getTextAlignment(property.textAlign),
platformStyle = PlatformTextStyle(
includeFontPadding = property.includeFontPadding.orTrue()
)
),
onClick = { offset ->
spannableData?.spanData?.forEach { spanData ->

View File

@@ -18,6 +18,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shadow
import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.unit.TextUnit
@@ -123,6 +124,9 @@ class TextRenderer : Renderer<TextProperty> {
dpToPx(property.textShadow?.offset?.y.orZero())
),
blurRadius = dpToPx(property.textShadow?.blurRadius.orZero())
),
platformStyle = PlatformTextStyle(
includeFontPadding = property.includeFontPadding.orTrue()
)
),
modifier =

View File

@@ -40,6 +40,7 @@ import androidx.compose.ui.layout.boundsInWindow
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
@@ -709,7 +710,10 @@ fun getTextStyle(textStyle: OutlinedTextFieldTextStyle): TextStyle {
color = textStyle.color?.hexToComposeColor ?: Color.Black,
fontFamily = UiTronSdkManager.getDependencyProvider().getFontFamily(textStyle.fontFamily),
fontWeight = UiTronSdkManager.getDependencyProvider().getFontWeight(textStyle.fontWeight),
textAlign = getTextAlignment(textStyle.textAlign)
textAlign = getTextAlignment(textStyle.textAlign),
platformStyle = PlatformTextStyle(
includeFontPadding = textStyle.includeFontPadding.orTrue()
)
)
}