From ae291d278fd41e73b3967829b0d1d78e4b4e36e9 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 20 Feb 2024 12:28:46 -0500 Subject: [PATCH] Fixes text's vertical alignment when emoji's are present. --- .../amethyst/ui/components/ClickableRoute.kt | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt index 93fc8ee20..1bf1cfe03 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRoute.kt @@ -23,7 +23,6 @@ package com.vitorpamplona.amethyst.ui.components import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.text.BasicText import androidx.compose.foundation.text.InlineTextContent import androidx.compose.foundation.text.appendInlineContent import androidx.compose.material3.LocalContentColor @@ -566,24 +565,29 @@ fun CreateClickableTextWithEmoji( if (emojiLists == null) { CreateClickableText(clickablePart, suffix, maxLines, overrideColor, fontWeight, route, nav) } else { + val clickablePartStyle = + SpanStyle( + color = overrideColor ?: MaterialTheme.colorScheme.primary, + fontWeight = fontWeight, + ) + + val nonClickablePartStyle = + SpanStyle( + color = overrideColor ?: MaterialTheme.colorScheme.onBackground, + fontWeight = fontWeight, + ) + ClickableInLineIconRenderer( emojiLists!!.part1, maxLines, - LocalTextStyle.current - .copy(color = overrideColor ?: MaterialTheme.colorScheme.primary, fontWeight = fontWeight) - .toSpanStyle(), + clickablePartStyle, ) { nav(route) } InLineIconRenderer( emojiLists!!.part2, - LocalTextStyle.current - .copy( - color = overrideColor ?: MaterialTheme.colorScheme.onBackground, - fontWeight = fontWeight, - ) - .toSpanStyle(), + nonClickablePartStyle, maxLines = maxLines, ) } @@ -677,7 +681,7 @@ fun ClickableInLineIconRenderer( } } - BasicText( + Text( text = annotatedText, modifier = pressIndicator, inlineContent = inlineContent,