From b12d14d6f5e9a84c73939b8d2473b3baf54633ce Mon Sep 17 00:00:00 2001 From: Believethehype <1097224+believethehype@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:19:16 +0200 Subject: [PATCH] add a shortpreview to not mess up grid layout on load --- .../amethyst/ui/note/BlankNote.kt | 8 +++- .../amethyst/ui/note/WatchNoteEvent.kt | 2 + .../ui/screen/RememberForeverStates.kt | 1 + .../ui/screen/loggedIn/ProfileGallery.kt | 46 +------------------ .../ui/screen/loggedIn/ProfileScreen.kt | 31 ++++++------- amethyst/src/main/res/values/strings.xml | 1 + 6 files changed, 27 insertions(+), 62 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/BlankNote.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/BlankNote.kt index 75af3272e..4f8e2c6d1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/BlankNote.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/BlankNote.kt @@ -59,6 +59,7 @@ fun BlankNotePreview() { fun BlankNote( modifier: Modifier = Modifier, idHex: String? = null, + shortPreview: Boolean = false, ) { Column(modifier = modifier) { Row { @@ -75,7 +76,12 @@ fun BlankNote( horizontalArrangement = Arrangement.Center, ) { Text( - text = stringRes(R.string.post_not_found) + if (idHex != null) ": $idHex" else "", + text = + if (shortPreview) { + stringRes(R.string.post_not_found_short) + } else { + stringRes(R.string.post_not_found) + if (idHex != null) ": $idHex" else "" + }, modifier = Modifier.padding(30.dp), color = Color.Gray, textAlign = TextAlign.Center, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/WatchNoteEvent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/WatchNoteEvent.kt index 33db44e8b..1983a4ba3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/WatchNoteEvent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/WatchNoteEvent.kt @@ -37,6 +37,7 @@ fun WatchNoteEvent( baseNote: Note, accountViewModel: AccountViewModel, modifier: Modifier = Modifier, + shortPreview: Boolean = false, onNoteEventFound: @Composable () -> Unit, ) { WatchNoteEvent( @@ -54,6 +55,7 @@ fun WatchNoteEvent( onLongClick = showPopup, ) }, + shortPreview = shortPreview, ) } }, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/RememberForeverStates.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/RememberForeverStates.kt index b47a2fec0..c44bafda9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/RememberForeverStates.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/RememberForeverStates.kt @@ -45,6 +45,7 @@ object ScrollStateKeys { const val DISCOVER_SCREEN = "Discover" val HOME_FOLLOWS = Route.Home.base + "Follows" val HOME_REPLIES = Route.Home.base + "FollowsReplies" + val PROFILE_GALLERY = Route.Home.base + "ProfileGallery" val DRAFTS = Route.Home.base + "Drafts" diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileGallery.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileGallery.kt index 9dfe05e10..2520a8dd1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileGallery.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileGallery.kt @@ -163,7 +163,7 @@ fun GalleryCardCompose( accountViewModel: AccountViewModel, nav: (String) -> Unit, ) { - WatchNoteEvent(baseNote = baseNote, accountViewModel = accountViewModel) { + WatchNoteEvent(baseNote = baseNote, accountViewModel = accountViewModel, shortPreview = true) { CheckHiddenFeedWatchBlockAndReport( note = baseNote, modifier = modifier, @@ -228,7 +228,6 @@ private fun CheckNewAndRenderChannelCard( showPopup = showPopup, nav = nav, ) { - // baseNote.event?.let { Text(text = it.pubKey()) } InnerGalleryCardWithReactions( baseNote = baseNote, accountViewModel = accountViewModel, @@ -342,7 +341,6 @@ fun InnerRenderGalleryThumb( videoUri = it, mimeType = null, title = "", - dimensions = "1x1", authorName = note.author?.toBestDisplayName(), roundedCorner = false, gallery = true, @@ -361,48 +359,6 @@ fun InnerRenderGalleryThumb( } ?: run { DisplayGalleryAuthorBanner(note) } } - - /* Row( - Modifier - .fillMaxWidth() - .background(Color.Black.copy(0.6f)) - .padding(Size5dp), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - card.title?.let { - Text( - text = it, - fontWeight = FontWeight.Medium, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - color = Color.White, - modifier = Modifier.weight(1f), - ) - } - - card.price?.let { - val priceTag = - remember(card) { - val newAmount = it.amount.toBigDecimalOrNull()?.let { showAmountAxis(it) } ?: it.amount - - if (it.frequency != null && it.currency != null) { - "$newAmount ${it.currency}/${it.frequency}" - } else if (it.currency != null) { - "$newAmount ${it.currency}" - } else { - newAmount - } - } - - Text( - text = priceTag, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - color = Color.White, - ) - } - } - }*/ } @Composable diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt index 638f0d492..2aedc388e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt @@ -42,7 +42,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.grid.LazyGridState import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.PagerState @@ -153,11 +152,13 @@ import com.vitorpamplona.amethyst.ui.screen.NostrUserProfileGalleryFeedViewModel import com.vitorpamplona.amethyst.ui.screen.NostrUserProfileNewThreadsFeedViewModel import com.vitorpamplona.amethyst.ui.screen.NostrUserProfileReportFeedViewModel import com.vitorpamplona.amethyst.ui.screen.NostrUserProfileZapsFeedViewModel +import com.vitorpamplona.amethyst.ui.screen.RefresheableBox import com.vitorpamplona.amethyst.ui.screen.RefresheableFeedView import com.vitorpamplona.amethyst.ui.screen.RefreshingFeedUserFeedView import com.vitorpamplona.amethyst.ui.screen.RelayFeedView import com.vitorpamplona.amethyst.ui.screen.RelayFeedViewModel import com.vitorpamplona.amethyst.ui.screen.SaveableGridFeedState +import com.vitorpamplona.amethyst.ui.screen.ScrollStateKeys import com.vitorpamplona.amethyst.ui.screen.UserFeedViewModel import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange @@ -1567,24 +1568,22 @@ fun TabGallery( ) { LaunchedEffect(Unit) { feedViewModel.invalidateData() } - Column(Modifier.fillMaxHeight()) { - Column( - modifier = Modifier.padding(vertical = 0.dp), - ) { - var state = LazyGridState() + // Column(Modifier.fillMaxHeight()) { - SaveableGridFeedState(feedViewModel, scrollStateKey = "gallery") { listState -> - RenderGalleryFeed( - feedViewModel, - null, - 0, - state, - accountViewModel = accountViewModel, - nav = nav, - ) - } + RefresheableBox(feedViewModel, true) { + SaveableGridFeedState(feedViewModel, scrollStateKey = ScrollStateKeys.PROFILE_GALLERY) { listState -> + RenderGalleryFeed( + feedViewModel, + null, + 0, + listState, + accountViewModel = accountViewModel, + nav = nav, + ) } } + + // } } /*@Composable diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml index 75a83cc4c..ebf7df349 100644 --- a/amethyst/src/main/res/values/strings.xml +++ b/amethyst/src/main/res/values/strings.xml @@ -10,6 +10,7 @@ This post was hidden because it mentions your hidden users or words Post was muted or reported by Event is loading or can\'t be found in your relay list + 👀 Channel Image Referenced event not found Could not decrypt the message