Fixes the visual references to communities and hashtags in the top right of the post

This commit is contained in:
Vitor Pamplona
2025-10-22 18:27:53 -04:00
parent 35da3b4efe
commit 2d551d4adf
2 changed files with 20 additions and 36 deletions

View File

@@ -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(
ClickableTextColor(
getCommunityShortName(communityTag),
) {
nav.nav(Route.Community(communityTag.kind, communityTag.pubKeyHex, communityTag.dTag))
}
}
Text(
text = displayTag,
style =
LocalTextStyle.current.copy(
color =
MaterialTheme.colorScheme.primary.copy(
alpha = 0.52f,
),
),
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)
}
}
}
}
fun getCommunityShortName(communityAddress: Address): String {

View File

@@ -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))
}
}