From 2d551d4adfc05f3ef24c443aeaa6ddd6c160f33a Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 22 Oct 2025 18:27:53 -0400 Subject: [PATCH] Fixes the visual references to communities and hashtags in the top right of the post --- .../ui/note/elements/DisplayCommunity.kt | 37 +++++++------------ .../ui/note/elements/DisplayHashtags.kt | 19 ++++------ 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayCommunity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayCommunity.kt index 2ccccdf26..e60b4fc4b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayCommunity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayCommunity.kt @@ -22,14 +22,12 @@ package com.vitorpamplona.amethyst.ui.note.elements import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember import androidx.compose.ui.Alignment +import androidx.compose.ui.text.style.TextOverflow import com.vitorpamplona.amethyst.model.Note -import com.vitorpamplona.amethyst.ui.components.buildLinkString +import com.vitorpamplona.amethyst.ui.components.ClickableTextColor import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.routes.Route import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -53,29 +51,20 @@ private fun DisplayCommunity( note: Note, nav: INav, ) { - val communityTag = - remember(note) { note.event?.communityAddress() } ?: return + val communityTag = note.event?.communityAddress() ?: return - val displayTag = - remember(note) { - buildLinkString( - getCommunityShortName(communityTag), - ) { - nav.nav(Route.Community(communityTag.kind, communityTag.pubKeyHex, communityTag.dTag)) + ClickableTextColor( + getCommunityShortName(communityTag), + linkColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.52f), + overflow = TextOverflow.Ellipsis, + maxLines = 1, + ) { + nav.nav { + note.event?.communityAddress()?.let { communityTag -> + Route.Community(communityTag.kind, communityTag.pubKeyHex, communityTag.dTag) } } - - Text( - text = displayTag, - style = - LocalTextStyle.current.copy( - color = - MaterialTheme.colorScheme.primary.copy( - alpha = 0.52f, - ), - ), - maxLines = 1, - ) + } } fun getCommunityShortName(communityAddress: Address): String { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayHashtags.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayHashtags.kt index 13a3f70c0..9700d74d8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayHashtags.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayHashtags.kt @@ -23,9 +23,7 @@ package com.vitorpamplona.amethyst.ui.note.elements import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -36,7 +34,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.text.style.TextOverflow import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.model.Note -import com.vitorpamplona.amethyst.ui.components.buildLinkString +import com.vitorpamplona.amethyst.ui.components.ClickableTextColor import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.routes.Route import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -82,15 +80,12 @@ private fun DisplayTagList( accountViewModel: AccountViewModel, nav: INav, ) { - Text( - text = - remember(firstTag) { - buildLinkString(" #$firstTag") { - nav.nav(Route.Hashtag(firstTag)) - } - }, - style = LocalTextStyle.current.copy(MaterialTheme.colorScheme.primary.copy(alpha = 0.52f)), + ClickableTextColor( + "#$firstTag", + linkColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.52f), overflow = TextOverflow.Ellipsis, maxLines = 1, - ) + ) { + nav.nav(Route.Hashtag(firstTag)) + } }