mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 23:06:38 +01:00
Fixes the visual references to communities and hashtags in the top right of the post
This commit is contained in:
@@ -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) {
|
getCommunityShortName(communityTag),
|
||||||
buildLinkString(
|
linkColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.52f),
|
||||||
getCommunityShortName(communityTag),
|
overflow = TextOverflow.Ellipsis,
|
||||||
) {
|
maxLines = 1,
|
||||||
nav.nav(Route.Community(communityTag.kind, communityTag.pubKeyHex, communityTag.dTag))
|
) {
|
||||||
|
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 {
|
fun getCommunityShortName(communityAddress: Address): String {
|
||||||
|
|||||||
@@ -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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user