mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-17 21:31:57 +01:00
Allowing multiple images on a single event to be displayed in the Profile gallery
This commit is contained in:
parent
4bfacbc11e
commit
5c0c1acc4a
@ -53,6 +53,7 @@ import com.vitorpamplona.amethyst.commons.richtext.RichTextParser.Companion.isVi
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.service.okhttp.HttpClientManager
|
||||
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
||||
import com.vitorpamplona.amethyst.ui.components.AutoNonlazyGrid
|
||||
import com.vitorpamplona.amethyst.ui.components.ClickableUrl
|
||||
import com.vitorpamplona.amethyst.ui.components.DisplayBlurHash
|
||||
import com.vitorpamplona.amethyst.ui.components.DisplayUrlWithLoadingSymbol
|
||||
@ -60,6 +61,7 @@ import com.vitorpamplona.amethyst.ui.components.GetMediaItem
|
||||
import com.vitorpamplona.amethyst.ui.components.GetVideoController
|
||||
import com.vitorpamplona.amethyst.ui.components.ImageUrlWithDownloadButton
|
||||
import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
|
||||
import com.vitorpamplona.amethyst.ui.components.UrlImageView
|
||||
import com.vitorpamplona.amethyst.ui.navigation.INav
|
||||
import com.vitorpamplona.amethyst.ui.note.DownloadForOfflineIcon
|
||||
import com.vitorpamplona.amethyst.ui.note.WatchAuthor
|
||||
@ -82,35 +84,31 @@ fun GalleryThumbnail(
|
||||
|
||||
val content =
|
||||
if (noteEvent is ProfileGalleryEntryEvent) {
|
||||
val url = noteEvent.url()
|
||||
if (url == null) {
|
||||
null
|
||||
} else if (isVideoUrl(url)) {
|
||||
MediaUrlVideo(
|
||||
url = url,
|
||||
description = noteEvent.content,
|
||||
hash = null,
|
||||
blurhash = noteEvent.blurhash(),
|
||||
dim = noteEvent.dimensions(),
|
||||
uri = null,
|
||||
mimeType = noteEvent.mimeType(),
|
||||
)
|
||||
} else {
|
||||
MediaUrlImage(
|
||||
url = url,
|
||||
description = noteEvent.content,
|
||||
hash = null, // We don't want to show the hash banner here
|
||||
blurhash = noteEvent.blurhash(),
|
||||
dim = noteEvent.dimensions(),
|
||||
uri = null,
|
||||
mimeType = noteEvent.mimeType(),
|
||||
)
|
||||
noteEvent.urls().map { url ->
|
||||
if (isVideoUrl(url)) {
|
||||
MediaUrlVideo(
|
||||
url = url,
|
||||
description = noteEvent.content,
|
||||
hash = null,
|
||||
blurhash = noteEvent.blurhash(),
|
||||
dim = noteEvent.dimensions(),
|
||||
uri = null,
|
||||
mimeType = noteEvent.mimeType(),
|
||||
)
|
||||
} else {
|
||||
MediaUrlImage(
|
||||
url = url,
|
||||
description = noteEvent.content,
|
||||
hash = null, // We don't want to show the hash banner here
|
||||
blurhash = noteEvent.blurhash(),
|
||||
dim = noteEvent.dimensions(),
|
||||
uri = null,
|
||||
mimeType = noteEvent.mimeType(),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if (noteEvent is PictureEvent) {
|
||||
val imeta = noteEvent.imetaTags().firstOrNull()
|
||||
if (imeta?.url == null) {
|
||||
null
|
||||
} else {
|
||||
noteEvent.imetaTags().map { imeta ->
|
||||
MediaUrlImage(
|
||||
url = imeta.url,
|
||||
description = noteEvent.content,
|
||||
@ -122,11 +120,7 @@ fun GalleryThumbnail(
|
||||
)
|
||||
}
|
||||
} else if (noteEvent is VideoEvent) {
|
||||
val imeta = noteEvent.imetaTags().firstOrNull()
|
||||
|
||||
if (imeta?.url == null) {
|
||||
null
|
||||
} else {
|
||||
noteEvent.imetaTags().map { imeta ->
|
||||
MediaUrlVideo(
|
||||
url = imeta.url,
|
||||
description = noteEvent.content,
|
||||
@ -138,7 +132,7 @@ fun GalleryThumbnail(
|
||||
)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
emptyList()
|
||||
}
|
||||
|
||||
InnerRenderGalleryThumb(content, baseNote, accountViewModel)
|
||||
@ -146,15 +140,12 @@ fun GalleryThumbnail(
|
||||
|
||||
@Composable
|
||||
fun InnerRenderGalleryThumb(
|
||||
content: MediaUrlContent?,
|
||||
content: List<MediaUrlContent>,
|
||||
note: Note,
|
||||
accountViewModel: AccountViewModel,
|
||||
) {
|
||||
if (content != null) {
|
||||
GalleryContentView(
|
||||
content = content,
|
||||
accountViewModel = accountViewModel,
|
||||
)
|
||||
if (content.isNotEmpty()) {
|
||||
GalleryContentView(content, accountViewModel)
|
||||
} else {
|
||||
DisplayGalleryAuthorBanner(note)
|
||||
}
|
||||
@ -170,18 +161,20 @@ fun DisplayGalleryAuthorBanner(note: Note) {
|
||||
@androidx.annotation.OptIn(UnstableApi::class)
|
||||
@Composable
|
||||
fun GalleryContentView(
|
||||
content: MediaUrlContent,
|
||||
contentList: List<MediaUrlContent>,
|
||||
accountViewModel: AccountViewModel,
|
||||
) {
|
||||
when (content) {
|
||||
is MediaUrlImage ->
|
||||
SensitivityWarning(content.contentWarning != null, accountViewModel) {
|
||||
UrlImageView(content, accountViewModel)
|
||||
}
|
||||
is MediaUrlVideo ->
|
||||
SensitivityWarning(content.contentWarning != null, accountViewModel) {
|
||||
UrlVideoView(content, accountViewModel)
|
||||
}
|
||||
AutoNonlazyGrid(contentList.size) { contentIndex ->
|
||||
when (val content = contentList[contentIndex]) {
|
||||
is MediaUrlImage ->
|
||||
SensitivityWarning(content.contentWarning != null, accountViewModel) {
|
||||
UrlImageView(content, accountViewModel)
|
||||
}
|
||||
is MediaUrlVideo ->
|
||||
SensitivityWarning(content.contentWarning != null, accountViewModel) {
|
||||
UrlVideoView(content, accountViewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user