adds description to the follow card ui

This commit is contained in:
Vitor Pamplona
2025-11-10 17:36:07 -05:00
parent 8bdd9d0979
commit ddfe61eb9f
4 changed files with 109 additions and 39 deletions
@@ -708,7 +708,7 @@ private fun RenderNoteRow(
is BadgeAwardEvent -> RenderBadgeAward(baseNote, backgroundColor, accountViewModel, nav) is BadgeAwardEvent -> RenderBadgeAward(baseNote, backgroundColor, accountViewModel, nav)
is FhirResourceEvent -> RenderFhirResource(baseNote, accountViewModel, nav) is FhirResourceEvent -> RenderFhirResource(baseNote, accountViewModel, nav)
is PeopleListEvent -> DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav) is PeopleListEvent -> DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav)
is FollowListEvent -> DisplayFollowList(baseNote, accountViewModel, nav) is FollowListEvent -> DisplayFollowList(baseNote, true, accountViewModel, nav)
is RelaySetEvent -> DisplayRelaySet(baseNote, backgroundColor, accountViewModel, nav) is RelaySetEvent -> DisplayRelaySet(baseNote, backgroundColor, accountViewModel, nav)
is ChatMessageRelayListEvent -> DisplayDMRelayList(baseNote, backgroundColor, accountViewModel, nav) is ChatMessageRelayListEvent -> DisplayDMRelayList(baseNote, backgroundColor, accountViewModel, nav)
is AdvertisedRelayListEvent -> DisplayNIP65RelayList(baseNote, backgroundColor, accountViewModel, nav) is AdvertisedRelayListEvent -> DisplayNIP65RelayList(baseNote, backgroundColor, accountViewModel, nav)
@@ -32,6 +32,8 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.CenterVertically import androidx.compose.ui.Alignment.Companion.CenterVertically
@@ -42,9 +44,11 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.LocalCache
import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNoteEventAndMap import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNoteEventAndMap
import com.vitorpamplona.amethyst.ui.components.MyAsyncImage import com.vitorpamplona.amethyst.ui.components.MyAsyncImage
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
import com.vitorpamplona.amethyst.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.ui.navigation.navs.EmptyNav
import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.INav
import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor
@@ -60,6 +64,8 @@ import com.vitorpamplona.amethyst.ui.theme.SpacedBy5dp
import com.vitorpamplona.amethyst.ui.theme.StdPadding import com.vitorpamplona.amethyst.ui.theme.StdPadding
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
import com.vitorpamplona.amethyst.ui.theme.blackTagModifier import com.vitorpamplona.amethyst.ui.theme.blackTagModifier
import com.vitorpamplona.quartz.nip01Core.core.EmptyTagList
import com.vitorpamplona.quartz.nip01Core.core.toImmutableListOfLists
import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent
import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList import kotlinx.collections.immutable.toImmutableList
@@ -68,6 +74,7 @@ import kotlinx.collections.immutable.toImmutableList
@Composable @Composable
fun DisplayFollowList( fun DisplayFollowList(
baseNote: Note, baseNote: Note,
makeItShort: Boolean,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav, nav: INav,
) { ) {
@@ -93,6 +100,7 @@ fun DisplayFollowList(
RenderFollowSetThumbEmbed( RenderFollowSetThumbEmbed(
card.value, card.value,
baseNote, baseNote,
makeItShort,
accountViewModel, accountViewModel,
nav, nav,
) )
@@ -102,6 +110,7 @@ fun DisplayFollowList(
fun RenderFollowSetThumbEmbed( fun RenderFollowSetThumbEmbed(
card: FollowSetCard, card: FollowSetCard,
baseNote: Note, baseNote: Note,
makeItShort: Boolean,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav, nav: INav,
) { ) {
@@ -152,6 +161,26 @@ fun RenderFollowSetThumbEmbed(
modifier = MaterialTheme.colorScheme.blackTagModifier, modifier = MaterialTheme.colorScheme.blackTagModifier,
) )
} }
if (!makeItShort) {
card.description?.let {
val defaultBackground = MaterialTheme.colorScheme.background
val background = remember { mutableStateOf(defaultBackground) }
TranslatableRichTextViewer(
content = it,
canPreview = true,
quotesLeft = 2,
modifier = Modifier.fillMaxWidth(),
tags = baseNote.event?.tags?.toImmutableListOfLists() ?: EmptyTagList,
backgroundColor = background,
id = it,
callbackUri = null,
accountViewModel = accountViewModel,
nav = nav,
)
}
}
} }
} }
@@ -160,22 +189,44 @@ fun RenderFollowSetThumbEmbed(
fun RenderFollowSetThumbPreview() { fun RenderFollowSetThumbPreview() {
val accountViewModel = mockAccountViewModel() val accountViewModel = mockAccountViewModel()
val followCard =
FollowListEvent(
id = "eca31634fce7c9068b56fa8db9f387da70bdcceb3986a77ca1a9844f3128eb5f",
pubKey = "3c39a7b53dec9ac85acf08b267637a9841e6df7b7b0f5e2ac56a8cf107de37da",
createdAt = 1761736286,
tags =
arrayOf(
arrayOf("title", "Retro Computer Fans"),
arrayOf("d", "xmbspe8rddsq"),
arrayOf("image", "https://blog.johnnovak.net/2022/04/15/achieving-period-correct-graphics-in-personal-computer-emulators-part-1-the-amiga/img/dream-setup.jpg"),
arrayOf("p", "3c39a7b53dec9ac85acf08b267637a9841e6df7b7b0f5e2ac56a8cf107de37da"),
arrayOf("p", "9a9a4aa0e43e57873380ab22e8a3df12f3c4cf5bb3a804c6e3fed0069a6e2740"),
arrayOf("p", "4f5dd82517b11088ce00f23d99f06fe8f3e2e45ecf47bc9c2f90f34d5c6f7382"),
arrayOf("p", "ac92102a2ecb873c488e0125354ef5a97075a16198668c360eda050007ed42cd"),
arrayOf("p", "47f54409a4620eb35208a3bc1b53555bf3d0656b246bf0471a93208e20672f6f"),
arrayOf("p", "2624911545afb7a2b440cf10f5c69308afa33aae26fca664d8c94623dc0f1baf"),
arrayOf("p", "6641f26f5c59f7010dbe3e42e4593398e27c087497cb7d20e0e7633a17e48a94"),
arrayOf("description", "Retro computer fans and enthusiasts "),
),
content = "",
sig = "3aa388edafad151e81cb0228fe04e115dbbcaa851c666bfe3c8740b6cd99575f0fc3ba2d47acda86f7626564a05e9dbc05ef452a7bd0ac00f828dbad0e1bae6c",
)
LocalCache.justConsume(followCard, null, false)
val card =
FollowSetCard(
name = followCard.title()?.ifBlank { null } ?: followCard.dTag(),
media = followCard.image()?.ifBlank { null },
description = followCard.description()?.ifBlank { null },
users = followCard.followIds().toImmutableList(),
)
ThemeComparisonColumn { ThemeComparisonColumn {
RenderFollowSetThumbEmbed( RenderFollowSetThumbEmbed(
card = card = card,
FollowSetCard( baseNote = LocalCache.getOrCreateNote(followCard.id),
"Orange Pill Perú", makeItShort = false,
"https://i.postimg.cc/GtDgGY5v/5062563795762785335.jpg",
"Desc",
persistentListOf(
accountViewModel.userProfile().pubkeyHex,
accountViewModel.userProfile().pubkeyHex,
accountViewModel.userProfile().pubkeyHex,
accountViewModel.userProfile().pubkeyHex,
accountViewModel.userProfile().pubkeyHex,
),
),
baseNote = Note(""),
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = EmptyNav(), nav = EmptyNav(),
) )
@@ -38,6 +38,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.LocalCache
import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNoteAndMap import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNoteAndMap
import com.vitorpamplona.amethyst.ui.components.MyAsyncImage import com.vitorpamplona.amethyst.ui.components.MyAsyncImage
@@ -63,7 +64,6 @@ import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.HexKey
import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent
import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList import kotlinx.collections.immutable.toImmutableList
@Immutable @Immutable
@@ -109,28 +109,47 @@ fun RenderFollowSetThumbPreview() {
val accountViewModel = mockAccountViewModel() val accountViewModel = mockAccountViewModel()
val nav = EmptyNav() val nav = EmptyNav()
ThemeComparisonColumn( val followCard =
toPreview = { FollowListEvent(
RenderFollowSetThumb( id = "eca31634fce7c9068b56fa8db9f387da70bdcceb3986a77ca1a9844f3128eb5f",
card = pubKey = "3c39a7b53dec9ac85acf08b267637a9841e6df7b7b0f5e2ac56a8cf107de37da",
FollowSetCard( createdAt = 1761736286,
"Orange Pill Perú", tags =
"https://i.postimg.cc/GtDgGY5v/5062563795762785335.jpg", arrayOf(
"Desc", arrayOf("title", "Retro Computer Fans"),
persistentListOf( arrayOf("d", "xmbspe8rddsq"),
accountViewModel.userProfile().pubkeyHex, arrayOf("image", "https://blog.johnnovak.net/2022/04/15/achieving-period-correct-graphics-in-personal-computer-emulators-part-1-the-amiga/img/dream-setup.jpg"),
accountViewModel.userProfile().pubkeyHex, arrayOf("p", "3c39a7b53dec9ac85acf08b267637a9841e6df7b7b0f5e2ac56a8cf107de37da"),
accountViewModel.userProfile().pubkeyHex, arrayOf("p", "9a9a4aa0e43e57873380ab22e8a3df12f3c4cf5bb3a804c6e3fed0069a6e2740"),
accountViewModel.userProfile().pubkeyHex, arrayOf("p", "4f5dd82517b11088ce00f23d99f06fe8f3e2e45ecf47bc9c2f90f34d5c6f7382"),
accountViewModel.userProfile().pubkeyHex, arrayOf("p", "ac92102a2ecb873c488e0125354ef5a97075a16198668c360eda050007ed42cd"),
), arrayOf("p", "47f54409a4620eb35208a3bc1b53555bf3d0656b246bf0471a93208e20672f6f"),
), arrayOf("p", "2624911545afb7a2b440cf10f5c69308afa33aae26fca664d8c94623dc0f1baf"),
baseNote = Note(""), arrayOf("p", "6641f26f5c59f7010dbe3e42e4593398e27c087497cb7d20e0e7633a17e48a94"),
accountViewModel = accountViewModel, arrayOf("description", "Retro computer fans and enthusiasts "),
nav = nav, ),
) content = "",
}, sig = "3aa388edafad151e81cb0228fe04e115dbbcaa851c666bfe3c8740b6cd99575f0fc3ba2d47acda86f7626564a05e9dbc05ef452a7bd0ac00f828dbad0e1bae6c",
) )
LocalCache.justConsume(followCard, null, false)
val card =
FollowSetCard(
name = followCard.title()?.ifBlank { null } ?: followCard.dTag(),
media = followCard.image()?.ifBlank { null },
description = followCard.description(),
users = followCard.followIds().toImmutableList(),
)
ThemeComparisonColumn {
RenderFollowSetThumb(
card = card,
baseNote = LocalCache.getOrCreateNote(followCard.id),
accountViewModel = accountViewModel,
nav = nav,
)
}
} }
@Composable @Composable
@@ -578,7 +578,7 @@ private fun FullBleedNoteCompose(
} else if (noteEvent is PeopleListEvent) { } else if (noteEvent is PeopleListEvent) {
DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav) DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav)
} else if (noteEvent is FollowListEvent) { } else if (noteEvent is FollowListEvent) {
DisplayFollowList(baseNote, accountViewModel, nav) DisplayFollowList(baseNote, false, accountViewModel, nav)
} else if (noteEvent is AudioTrackEvent) { } else if (noteEvent is AudioTrackEvent) {
AudioTrackHeader(noteEvent, baseNote, ContentScale.FillWidth, accountViewModel, nav) AudioTrackHeader(noteEvent, baseNote, ContentScale.FillWidth, accountViewModel, nav)
} else if (noteEvent is AudioHeaderEvent) { } else if (noteEvent is AudioHeaderEvent) {