add a shortpreview to not mess up grid layout on load

This commit is contained in:
Believethehype 2024-07-01 09:19:16 +02:00
parent 1d42440e26
commit b12d14d6f5
6 changed files with 27 additions and 62 deletions

View File

@ -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,

View File

@ -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,
)
}
},

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -10,6 +10,7 @@
<string name="post_was_hidden">This post was hidden because it mentions your hidden users or words</string>
<string name="post_was_flagged_as_inappropriate_by">Post was muted or reported by</string>
<string name="post_not_found">Event is loading or can\'t be found in your relay list</string>
<string name="post_not_found_short">👀</string>
<string name="channel_image">Channel Image</string>
<string name="referenced_event_not_found">Referenced event not found</string>
<string name="could_not_decrypt_the_message">Could not decrypt the message</string>