Skip to content

Commit

Permalink
Added the inner padding config in CompoundText (#3589)
Browse files Browse the repository at this point in the history
* Added the inner padding config in CompoundText

* Unit Tests
  • Loading branch information
Aleem92 authored Nov 15, 2024
1 parent 16d027d commit 2b53916
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ data class CompoundTextProperties(
val textCase: TextCase? = null,
val overflow: TextOverFlow? = null,
val letterSpacing: Int = 0,
val textInnerPadding: Int = 0,
) : ViewProperties(), Parcelable {
override fun interpolate(computedValuesMap: Map<String, Any>): CompoundTextProperties {
return this.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class CompoundTextTest {
primaryTextColor = "#000000",
primaryTextFontWeight = TextFontWeight.SEMI_BOLD,
padding = 16,
primaryTextBackgroundColor = "#FFA500",
textInnerPadding = 4,
),
resourceData = ResourceData("id", ResourceType.Patient, emptyMap(), emptyMap()),
navController = TestNavHostController(LocalContext.current),
Expand All @@ -67,6 +69,7 @@ class CompoundTextTest {
separator = ".",
secondaryTextBackgroundColor = "#FFA500",
fontSize = 18.0f,
textInnerPadding = 4,
),
resourceData = ResourceData("id", ResourceType.Patient, emptyMap(), emptyMap()),
navController = TestNavHostController(LocalContext.current),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ fun CompoundText(
navController = navController,
overflow = compoundTextProperties.overflow,
letterSpacing = compoundTextProperties.letterSpacing,
textInnerPadding = compoundTextProperties.textInnerPadding,
)
}
// Separate the primary and secondary text
Expand Down Expand Up @@ -128,6 +129,7 @@ fun CompoundText(
resourceData = resourceData,
overflow = compoundTextProperties.overflow,
letterSpacing = compoundTextProperties.letterSpacing,
textInnerPadding = compoundTextProperties.textInnerPadding,
)
}
}
Expand All @@ -153,6 +155,7 @@ private fun CompoundTextPart(
resourceData: ResourceData,
overflow: TextOverFlow?,
letterSpacing: Int = 0,
textInnerPadding: Int = 0,
) {
Text(
text =
Expand All @@ -175,7 +178,7 @@ private fun CompoundTextPart(
)
.clip(RoundedCornerShape(borderRadius.dp))
.background(backgroundColor.parseColor())
.padding(0.dp),
.padding(textInnerPadding.dp),
fontSize = fontSize.sp,
fontWeight = textFontWeight.fontWeight,
textAlign =
Expand Down

0 comments on commit 2b53916

Please sign in to comment.