From f43059d5ecc1e0071e23d905df357d0f4de85577 Mon Sep 17 00:00:00 2001 From: Acclorite <140836141+Acclorite@users.noreply.github.com> Date: Tue, 7 Jan 2025 00:42:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Improve=20HighlightedTe?= =?UTF-8?q?xt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/components/common/HighlightedText.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/core/components/common/HighlightedText.kt b/app/src/main/java/ua/acclorite/book_story/presentation/core/components/common/HighlightedText.kt index 22e4c016..211f9ab9 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/core/components/common/HighlightedText.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/core/components/common/HighlightedText.kt @@ -31,9 +31,8 @@ fun HighlightedText( val textWord = word.text.filterDigitsAtStartAndEnd() val digitsAtStart = word.text.digitsAtStart() - val focusArea = when (textWord.length) { - in 1..3 -> 1 - 4 -> 2 + val highlightArea = when (textWord.length) { + 3 -> 1 else -> (textWord.length * 0.5f).roundToInt() } + digitsAtStart @@ -42,10 +41,10 @@ fun HighlightedText( } 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(" ") } }