mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-10 20:53:42 +02:00
gallery is visualised
This commit is contained in:
@@ -2226,7 +2226,6 @@ class Account(
|
|||||||
GalleryListEvent.removeReplaceable(
|
GalleryListEvent.removeReplaceable(
|
||||||
galleryentries,
|
galleryentries,
|
||||||
note.address,
|
note.address,
|
||||||
false,
|
|
||||||
signer,
|
signer,
|
||||||
) {
|
) {
|
||||||
Client.send(it)
|
Client.send(it)
|
||||||
@@ -2236,7 +2235,6 @@ class Account(
|
|||||||
GalleryListEvent.removeEvent(
|
GalleryListEvent.removeEvent(
|
||||||
galleryentries,
|
galleryentries,
|
||||||
note.idHex,
|
note.idHex,
|
||||||
false,
|
|
||||||
signer,
|
signer,
|
||||||
) {
|
) {
|
||||||
Client.send(it)
|
Client.send(it)
|
||||||
|
@@ -27,26 +27,26 @@ import com.vitorpamplona.amethyst.model.User
|
|||||||
|
|
||||||
class UserProfileGalleryFeedFilter(val user: User, val account: Account) : FeedFilter<Note>() {
|
class UserProfileGalleryFeedFilter(val user: User, val account: Account) : FeedFilter<Note>() {
|
||||||
override fun feedKey(): String {
|
override fun feedKey(): String {
|
||||||
return account.userProfile().pubkeyHex + "-" + user.pubkeyHex
|
return account.userProfile().pubkeyHex + "-Gallery-" + user.pubkeyHex
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun feed(): List<Note> {
|
override fun feed(): List<Note> {
|
||||||
val notes =
|
val notes =
|
||||||
user.latestGalleryList
|
user.latestGalleryList
|
||||||
?.taggedEvents()
|
?.taggedGalleryEntries()
|
||||||
?.mapNotNull { LocalCache.checkGetOrCreateNote(it) }
|
?.mapNotNull { LocalCache.checkGetOrCreateNote(it.id) }
|
||||||
?.toSet()
|
?.toSet()
|
||||||
?: emptySet()
|
?: emptySet()
|
||||||
|
|
||||||
val addresses =
|
/*val addresses =
|
||||||
user.latestGalleryList
|
user.latestGalleryList
|
||||||
?.taggedAddresses()
|
?.taggedAddresses()
|
||||||
?.map { LocalCache.getOrCreateAddressableNote(it) }
|
?.map { LocalCache.getOrCreateAddressableNote(it) }
|
||||||
?.toSet()
|
?.toSet()
|
||||||
?: emptySet()
|
?: emptySet() */
|
||||||
|
|
||||||
return (notes + addresses)
|
// .sortedWith(DefaultFeedOrder)
|
||||||
|
return (notes)
|
||||||
.filter { account.isAcceptable(it) }
|
.filter { account.isAcceptable(it) }
|
||||||
.sortedWith(DefaultFeedOrder)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,8 +32,10 @@ import androidx.compose.foundation.layout.fillMaxSize
|
|||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.grid.GridCells
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.grid.LazyGridState
|
||||||
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
|
import androidx.compose.foundation.lazy.grid.itemsIndexed
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
@@ -63,7 +65,6 @@ import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
|
|||||||
import com.vitorpamplona.amethyst.ui.note.CheckHiddenFeedWatchBlockAndReport
|
import com.vitorpamplona.amethyst.ui.note.CheckHiddenFeedWatchBlockAndReport
|
||||||
import com.vitorpamplona.amethyst.ui.note.ClickableNote
|
import com.vitorpamplona.amethyst.ui.note.ClickableNote
|
||||||
import com.vitorpamplona.amethyst.ui.note.LongPressToQuickAction
|
import com.vitorpamplona.amethyst.ui.note.LongPressToQuickAction
|
||||||
import com.vitorpamplona.amethyst.ui.note.NormalChannelCard
|
|
||||||
import com.vitorpamplona.amethyst.ui.note.WatchAuthor
|
import com.vitorpamplona.amethyst.ui.note.WatchAuthor
|
||||||
import com.vitorpamplona.amethyst.ui.note.WatchNoteEvent
|
import com.vitorpamplona.amethyst.ui.note.WatchNoteEvent
|
||||||
import com.vitorpamplona.amethyst.ui.note.calculateBackgroundColor
|
import com.vitorpamplona.amethyst.ui.note.calculateBackgroundColor
|
||||||
@@ -78,19 +79,18 @@ import com.vitorpamplona.amethyst.ui.theme.FeedPadding
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.HalfPadding
|
import com.vitorpamplona.amethyst.ui.theme.HalfPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
|
import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
||||||
import com.vitorpamplona.quartz.events.GalleryListEvent
|
import com.vitorpamplona.quartz.events.TextNoteEvent
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun RenderGalleryFeed(
|
fun RenderGalleryFeed(
|
||||||
viewModel: FeedViewModel,
|
viewModel: FeedViewModel,
|
||||||
routeForLastRead: String?,
|
routeForLastRead: String?,
|
||||||
forceEventKind: Int?,
|
forceEventKind: Int?,
|
||||||
listState: LazyListState,
|
listState: LazyGridState,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
val feedState by viewModel.feedContent.collectAsStateWithLifecycle()
|
val feedState by viewModel.feedContent.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
CrossfadeIfEnabled(
|
CrossfadeIfEnabled(
|
||||||
targetState = feedState,
|
targetState = feedState,
|
||||||
animationSpec = tween(durationMillis = 100),
|
animationSpec = tween(durationMillis = 100),
|
||||||
@@ -126,12 +126,13 @@ private fun RenderGalleryFeed(
|
|||||||
private fun GalleryFeedLoaded(
|
private fun GalleryFeedLoaded(
|
||||||
state: FeedState.Loaded,
|
state: FeedState.Loaded,
|
||||||
routeForLastRead: String?,
|
routeForLastRead: String?,
|
||||||
listState: LazyListState,
|
listState: LazyGridState,
|
||||||
forceEventKind: Int?,
|
forceEventKind: Int?,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
LazyColumn(
|
LazyVerticalGrid(
|
||||||
|
columns = GridCells.Fixed(3),
|
||||||
contentPadding = FeedPadding,
|
contentPadding = FeedPadding,
|
||||||
state = listState,
|
state = listState,
|
||||||
) {
|
) {
|
||||||
@@ -142,7 +143,7 @@ private fun GalleryFeedLoaded(
|
|||||||
GalleryCardCompose(
|
GalleryCardCompose(
|
||||||
baseNote = item,
|
baseNote = item,
|
||||||
routeForLastRead = routeForLastRead,
|
routeForLastRead = routeForLastRead,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier,
|
||||||
forceEventKind = forceEventKind,
|
forceEventKind = forceEventKind,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
@@ -167,25 +168,30 @@ fun GalleryCardCompose(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
/* baseNote.event?.let {
|
||||||
|
Text(text = it.id() + " " + it.firstTaggedUrl() + " ") // TODO why does it.taggedGalleryEntries() not return something? whats different?
|
||||||
|
} baseNote.event?.let {
|
||||||
|
for (entry in it.taggedGalleryEntries()) {
|
||||||
|
Text(text = entry.url + " " + entry.id)
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
WatchNoteEvent(baseNote = baseNote, accountViewModel = accountViewModel) {
|
WatchNoteEvent(baseNote = baseNote, accountViewModel = accountViewModel) {
|
||||||
if (forceEventKind == null || baseNote.event?.kind() == forceEventKind) {
|
CheckHiddenFeedWatchBlockAndReport(
|
||||||
CheckHiddenFeedWatchBlockAndReport(
|
note = baseNote,
|
||||||
note = baseNote,
|
modifier = modifier,
|
||||||
|
ignoreAllBlocksAndReports = isHiddenFeed,
|
||||||
|
showHiddenWarning = false,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav,
|
||||||
|
) { canPreview ->
|
||||||
|
GalleryCard(
|
||||||
|
baseNote = baseNote,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
ignoreAllBlocksAndReports = isHiddenFeed,
|
parentBackgroundColor = parentBackgroundColor,
|
||||||
showHiddenWarning = false,
|
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
) { canPreview ->
|
)
|
||||||
NormalChannelCard(
|
|
||||||
baseNote = baseNote,
|
|
||||||
routeForLastRead = routeForLastRead,
|
|
||||||
modifier = modifier,
|
|
||||||
parentBackgroundColor = parentBackgroundColor,
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
nav = nav,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,7 +241,6 @@ fun ProfileGallery(
|
|||||||
@Composable
|
@Composable
|
||||||
fun GalleryCard(
|
fun GalleryCard(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
url: String,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
@@ -246,7 +251,6 @@ fun GalleryCard(
|
|||||||
|
|
||||||
CheckNewAndRenderChannelCard(
|
CheckNewAndRenderChannelCard(
|
||||||
baseNote,
|
baseNote,
|
||||||
url,
|
|
||||||
modifier,
|
modifier,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
@@ -259,7 +263,6 @@ fun GalleryCard(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun CheckNewAndRenderChannelCard(
|
private fun CheckNewAndRenderChannelCard(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
url: String,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
@@ -284,7 +287,6 @@ private fun CheckNewAndRenderChannelCard(
|
|||||||
// baseNote.event?.let { Text(text = it.pubKey()) }
|
// baseNote.event?.let { Text(text = it.pubKey()) }
|
||||||
InnerGalleryCardWithReactions(
|
InnerGalleryCardWithReactions(
|
||||||
baseNote = baseNote,
|
baseNote = baseNote,
|
||||||
url = url,
|
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
@@ -294,17 +296,15 @@ private fun CheckNewAndRenderChannelCard(
|
|||||||
@Composable
|
@Composable
|
||||||
fun InnerGalleryCardWithReactions(
|
fun InnerGalleryCardWithReactions(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
url: String,
|
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
InnerGalleryCardBox(baseNote, url, accountViewModel, nav)
|
InnerGalleryCardBox(baseNote, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun InnerGalleryCardBox(
|
fun InnerGalleryCardBox(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
url: String,
|
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
@@ -313,14 +313,13 @@ fun InnerGalleryCardBox(
|
|||||||
note = baseNote,
|
note = baseNote,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
) {
|
) {
|
||||||
RenderGalleryThumb(baseNote, url, accountViewModel, nav)
|
RenderGalleryThumb(baseNote, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
data class GalleryThumb(
|
data class GalleryThumb(
|
||||||
val baseNote: Note?,
|
|
||||||
val id: String?,
|
val id: String?,
|
||||||
val image: String?,
|
val image: String?,
|
||||||
val title: String?,
|
val title: String?,
|
||||||
@@ -330,34 +329,31 @@ data class GalleryThumb(
|
|||||||
@Composable
|
@Composable
|
||||||
fun RenderGalleryThumb(
|
fun RenderGalleryThumb(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
url: String,
|
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
val noteEvent = baseNote.event as? GalleryListEvent ?: return
|
val noteEvent = baseNote.event as? TextNoteEvent ?: return
|
||||||
|
|
||||||
val card by
|
val card by
|
||||||
baseNote
|
baseNote
|
||||||
.live()
|
.live()
|
||||||
.metadata
|
.metadata
|
||||||
.map {
|
.map {
|
||||||
val noteEvent = baseNote.event as GalleryListEvent
|
val noteEvent = baseNote.event as TextNoteEvent
|
||||||
|
|
||||||
GalleryThumb(
|
GalleryThumb(
|
||||||
baseNote = baseNote,
|
|
||||||
id = "",
|
id = "",
|
||||||
image = url,
|
image = noteEvent.firstTaggedUrl(),
|
||||||
title = "Hello",
|
title = noteEvent.content(),
|
||||||
// noteEvent?.title(),
|
// noteEvent?.title(),
|
||||||
// price = noteEvent?.price(),
|
// price = noteEvent?.price(),
|
||||||
)
|
)
|
||||||
}.distinctUntilChanged()
|
}.distinctUntilChanged()
|
||||||
.observeAsState(
|
.observeAsState(
|
||||||
GalleryThumb(
|
GalleryThumb(
|
||||||
baseNote = baseNote,
|
|
||||||
id = "",
|
id = "",
|
||||||
image = "https://gokaygokay-aurasr.hf.space/file=/tmp/gradio/68292f324a38d7071453cf6912dfb1da9d1305c8/image3.png",
|
image = noteEvent.firstTaggedUrl(),
|
||||||
title = "Hello",
|
title = noteEvent.content(),
|
||||||
// image = noteEvent.image(),
|
// image = noteEvent.image(),
|
||||||
// title = noteEvent.title(),
|
// title = noteEvent.title(),
|
||||||
// price = noteEvent.price(),
|
// price = noteEvent.price(),
|
||||||
@@ -374,7 +370,6 @@ fun RenderGalleryThumbPreview() {
|
|||||||
InnerRenderGalleryThumb(
|
InnerRenderGalleryThumb(
|
||||||
card =
|
card =
|
||||||
GalleryThumb(
|
GalleryThumb(
|
||||||
baseNote = null,
|
|
||||||
id = "",
|
id = "",
|
||||||
image = null,
|
image = null,
|
||||||
title = "Like New",
|
title = "Like New",
|
||||||
|
@@ -42,6 +42,7 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.lazy.grid.LazyGridState
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.pager.HorizontalPager
|
import androidx.compose.foundation.pager.HorizontalPager
|
||||||
import androidx.compose.foundation.pager.PagerState
|
import androidx.compose.foundation.pager.PagerState
|
||||||
@@ -1569,10 +1570,12 @@ fun TabGallery(
|
|||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(vertical = 0.dp),
|
modifier = Modifier.padding(vertical = 0.dp),
|
||||||
) {
|
) {
|
||||||
RefresheableFeedView(
|
var state = LazyGridState()
|
||||||
|
RenderGalleryFeed(
|
||||||
feedViewModel,
|
feedViewModel,
|
||||||
null,
|
null,
|
||||||
enablePullRefresh = false,
|
0,
|
||||||
|
state,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
@@ -72,3 +72,21 @@ data class EmojiUrl(val code: String, val url: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
data class GalleryUrl(val id: String, val url: String) {
|
||||||
|
fun encode(): String {
|
||||||
|
return ":$id:$url"
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun decode(encodedGallerySetup: String): EmojiUrl? {
|
||||||
|
val emojiParts = encodedGallerySetup.split(":", limit = 3)
|
||||||
|
return if (emojiParts.size > 2) {
|
||||||
|
EmojiUrl(emojiParts[1], emojiParts[2])
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -119,6 +119,8 @@ open class Event(
|
|||||||
|
|
||||||
override fun taggedEvents() = tags.filter { it.size > 1 && it[0] == "e" }.map { it[1] }
|
override fun taggedEvents() = tags.filter { it.size > 1 && it[0] == "e" }.map { it[1] }
|
||||||
|
|
||||||
|
override fun taggedGalleryEntries() = tags.filter { it.size > 2 && it[0] == "g" }.map { GalleryUrl(it[1], it[2]) }
|
||||||
|
|
||||||
override fun taggedUrls() = tags.filter { it.size > 1 && it[0] == "r" }.map { it[1] }
|
override fun taggedUrls() = tags.filter { it.size > 1 && it[0] == "r" }.map { it[1] }
|
||||||
|
|
||||||
override fun firstTagFor(vararg key: String) = tags.firstOrNull { it.size > 1 && it[0] in key }?.let { it[1] }
|
override fun firstTagFor(vararg key: String) = tags.firstOrNull { it.size > 1 && it[0] in key }?.let { it[1] }
|
||||||
|
@@ -145,6 +145,8 @@ interface EventInterface {
|
|||||||
|
|
||||||
fun firstTaggedK(): Int?
|
fun firstTaggedK(): Int?
|
||||||
|
|
||||||
|
fun taggedGalleryEntries(): List<GalleryUrl>
|
||||||
|
|
||||||
fun taggedEmojis(): List<EmojiUrl>
|
fun taggedEmojis(): List<EmojiUrl>
|
||||||
|
|
||||||
fun matchTag1With(text: String): Boolean
|
fun matchTag1With(text: String): Boolean
|
||||||
|
Reference in New Issue
Block a user