🛠️ Improve HighlightedText

This commit is contained in:
Acclorite 2025-01-07 00:42:47 +02:00
parent 1231117f8b
commit f43059d5ec

View file

@ -31,9 +31,8 @@ fun HighlightedText(
val textWord = word.text.filterDigitsAtStartAndEnd() val textWord = word.text.filterDigitsAtStartAndEnd()
val digitsAtStart = word.text.digitsAtStart() val digitsAtStart = word.text.digitsAtStart()
val focusArea = when (textWord.length) { val highlightArea = when (textWord.length) {
in 1..3 -> 1 3 -> 1
4 -> 2
else -> (textWord.length * 0.5f).roundToInt() else -> (textWord.length * 0.5f).roundToInt()
} + digitsAtStart } + digitsAtStart
@ -42,10 +41,10 @@ fun HighlightedText(
} }
withStyle(style = SpanStyle(fontWeight = highlightThickness)) { withStyle(style = SpanStyle(fontWeight = highlightThickness)) {
append(word.subSequence(digitsAtStart, focusArea)) append(word.subSequence(digitsAtStart, highlightArea))
} }
append(word.subSequence(focusArea, word.text.length)) append(word.subSequence(highlightArea, word.text.length))
append(" ") append(" ")
} }
} }