From 6cd04a7617e351e3435ad911fb9542cc66c89897 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 8 Mar 2024 21:51:56 -0500 Subject: [PATCH] Fixes space after clickable user display --- .../amethyst/ui/components/ClickableRoute.kt | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 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 f5743f460..4659778df 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 @@ -300,15 +300,12 @@ private fun RenderUserAsClickableText( userDisplayName?.let { CreateClickableTextWithEmoji( clickablePart = it, + suffix = additionalChars.ifBlank { null }, maxLines = 1, route = route, nav = nav, tags = userTags, ) - - additionalChars.ifBlank { null }?.let { - Text(text = it, maxLines = 1) - } } } @@ -587,6 +584,7 @@ fun CreateClickableTextWithEmoji( @Composable fun CreateClickableTextWithEmoji( clickablePart: String, + suffix: String? = null, maxLines: Int = Int.MAX_VALUE, overrideColor: Color? = null, fontWeight: FontWeight = FontWeight.Normal, @@ -599,9 +597,16 @@ fun CreateClickableTextWithEmoji( text = clickablePart, tags = tags, onRegularText = { - CreateClickableText(it, null, maxLines, overrideColor, fontWeight, fontSize, route, nav) + CreateClickableText(it, suffix, maxLines, overrideColor, fontWeight, fontSize, route, nav) }, onEmojiText = { + val nonClickablePartStyle = + SpanStyle( + fontSize = fontSize, + color = overrideColor ?: MaterialTheme.colorScheme.onBackground, + fontWeight = fontWeight, + ) + val clickablePartStyle = SpanStyle( fontSize = fontSize, @@ -613,6 +618,8 @@ fun CreateClickableTextWithEmoji( it, maxLines, clickablePartStyle, + suffix, + nonClickablePartStyle, ) { nav(route) } @@ -625,6 +632,8 @@ fun ClickableInLineIconRenderer( wordsInOrder: ImmutableList, maxLines: Int = Int.MAX_VALUE, style: SpanStyle, + suffix: String? = null, + nonClickableStype: SpanStyle? = null, onClick: (Int) -> Unit, ) { val placeholderSize = @@ -675,6 +684,12 @@ fun ClickableInLineIconRenderer( } } } + + if (suffix != null && nonClickableStype != null) { + withStyle(nonClickableStype) { + append(suffix) + } + } } val layoutResult = remember { mutableStateOf(null) }