Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,7 @@ public class TextAttributeProps private constructor() {
isUnderlineTextDecorationSet = false
isLineThroughTextDecorationSet = false
if (textDecorationLineString != null) {
for (textDecorationLineSubString in
textDecorationLineString
.split("-".toRegex())
.dropLastWhile { it.isEmpty() }
.toTypedArray()) {
for (textDecorationLineSubString in textDecorationLineString.split('-')) {
if ("underline" == textDecorationLineSubString) {
isUnderlineTextDecorationSet = true
} else if ("strikethrough" == textDecorationLineSubString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ class TextAttributePropsTest {
assertThat(textAttributes.lineHeight).isCloseTo(20f * DENSITY, within(0.001f))
}

@Test
fun mapBufferSetsTextDecorationLine() {
assertThat(textDecorationLine("none")).isEqualTo(false to false)
assertThat(textDecorationLine("underline")).isEqualTo(true to false)
assertThat(textDecorationLine("strikethrough")).isEqualTo(false to true)
assertThat(textDecorationLine("underline-strikethrough")).isEqualTo(true to true)
}

/** Returns whether underline and line-through are set for the given textDecorationLine. */
private fun textDecorationLine(value: String): Pair<Boolean, Boolean> {
val textAttributes =
TextAttributeProps.fromMapBuffer(
WritableMapBuffer().put(TextAttributeProps.TA_KEY_TEXT_DECORATION_LINE, value),
)
return textAttributes.isUnderlineTextDecorationSet to
textAttributes.isLineThroughTextDecorationSet
}

private fun setFontScale(fontScale: Float) {
DisplayMetricsHolder.setScreenDisplayMetrics(
DisplayMetrics().apply {
Expand Down
Loading