Fixes space after clickable user display

This commit is contained in:
Vitor Pamplona
2024-03-08 21:51:56 -05:00
parent 632bd77db3
commit 6cd04a7617
@@ -300,15 +300,12 @@ private fun RenderUserAsClickableText(
userDisplayName?.let { userDisplayName?.let {
CreateClickableTextWithEmoji( CreateClickableTextWithEmoji(
clickablePart = it, clickablePart = it,
suffix = additionalChars.ifBlank { null },
maxLines = 1, maxLines = 1,
route = route, route = route,
nav = nav, nav = nav,
tags = userTags, tags = userTags,
) )
additionalChars.ifBlank { null }?.let {
Text(text = it, maxLines = 1)
}
} }
} }
@@ -587,6 +584,7 @@ fun CreateClickableTextWithEmoji(
@Composable @Composable
fun CreateClickableTextWithEmoji( fun CreateClickableTextWithEmoji(
clickablePart: String, clickablePart: String,
suffix: String? = null,
maxLines: Int = Int.MAX_VALUE, maxLines: Int = Int.MAX_VALUE,
overrideColor: Color? = null, overrideColor: Color? = null,
fontWeight: FontWeight = FontWeight.Normal, fontWeight: FontWeight = FontWeight.Normal,
@@ -599,9 +597,16 @@ fun CreateClickableTextWithEmoji(
text = clickablePart, text = clickablePart,
tags = tags, tags = tags,
onRegularText = { onRegularText = {
CreateClickableText(it, null, maxLines, overrideColor, fontWeight, fontSize, route, nav) CreateClickableText(it, suffix, maxLines, overrideColor, fontWeight, fontSize, route, nav)
}, },
onEmojiText = { onEmojiText = {
val nonClickablePartStyle =
SpanStyle(
fontSize = fontSize,
color = overrideColor ?: MaterialTheme.colorScheme.onBackground,
fontWeight = fontWeight,
)
val clickablePartStyle = val clickablePartStyle =
SpanStyle( SpanStyle(
fontSize = fontSize, fontSize = fontSize,
@@ -613,6 +618,8 @@ fun CreateClickableTextWithEmoji(
it, it,
maxLines, maxLines,
clickablePartStyle, clickablePartStyle,
suffix,
nonClickablePartStyle,
) { ) {
nav(route) nav(route)
} }
@@ -625,6 +632,8 @@ fun ClickableInLineIconRenderer(
wordsInOrder: ImmutableList<Nip30CustomEmoji.Renderable>, wordsInOrder: ImmutableList<Nip30CustomEmoji.Renderable>,
maxLines: Int = Int.MAX_VALUE, maxLines: Int = Int.MAX_VALUE,
style: SpanStyle, style: SpanStyle,
suffix: String? = null,
nonClickableStype: SpanStyle? = null,
onClick: (Int) -> Unit, onClick: (Int) -> Unit,
) { ) {
val placeholderSize = val placeholderSize =
@@ -675,6 +684,12 @@ fun ClickableInLineIconRenderer(
} }
} }
} }
if (suffix != null && nonClickableStype != null) {
withStyle(nonClickableStype) {
append(suffix)
}
}
} }
val layoutResult = remember { mutableStateOf<TextLayoutResult?>(null) } val layoutResult = remember { mutableStateOf<TextLayoutResult?>(null) }