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.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.text.style.TextOverflow
import com.vitorpamplona.amethyst.model.Note 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.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.routes.Route import com.vitorpamplona.amethyst.ui.navigation.routes.Route
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -53,29 +51,20 @@ private fun DisplayCommunity(
note: Note, note: Note,
nav: INav, nav: INav,
) { ) {
val communityTag = val communityTag = note.event?.communityAddress() ?: return
remember(note) { note.event?.communityAddress() } ?: return
val displayTag = ClickableTextColor(
remember(note) {
buildLinkString(
getCommunityShortName(communityTag), getCommunityShortName(communityTag),
) { linkColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.52f),
nav.nav(Route.Community(communityTag.kind, communityTag.pubKeyHex, communityTag.dTag)) overflow = TextOverflow.Ellipsis,
}
}
Text(
text = displayTag,
style =
LocalTextStyle.current.copy(
color =
MaterialTheme.colorScheme.primary.copy(
alpha = 0.52f,
),
),
maxLines = 1, maxLines = 1,
) ) {
nav.nav {
note.event?.communityAddress()?.let { communityTag ->
Route.Community(communityTag.kind, communityTag.pubKeyHex, communityTag.dTag)
}
}
}
} }
fun getCommunityShortName(communityAddress: Address): String { 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.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@@ -36,7 +34,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.model.Note 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.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.routes.Route import com.vitorpamplona.amethyst.ui.navigation.routes.Route
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -82,15 +80,12 @@ private fun DisplayTagList(
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav, nav: INav,
) { ) {
Text( ClickableTextColor(
text = "#$firstTag",
remember(firstTag) { linkColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.52f),
buildLinkString(" #$firstTag") {
nav.nav(Route.Hashtag(firstTag))
}
},
style = LocalTextStyle.current.copy(MaterialTheme.colorScheme.primary.copy(alpha = 0.52f)),
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
maxLines = 1, maxLines = 1,
) ) {
nav.nav(Route.Hashtag(firstTag))
}
} }