diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt index 2e991ee7a..378a2dddc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.components import android.util.Log import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.AnimatedVisibilityScope import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.foundation.clickable @@ -264,7 +265,9 @@ fun LocalImageView( ) } } else { - DisplayUrlWithLoadingSymbol(content) + WaitAndDisplay { + DisplayUrlWithLoadingSymbol(content) + } } } is AsyncImagePainter.State.Error -> { @@ -370,7 +373,9 @@ fun UrlImageView( ) } } else { - DisplayUrlWithLoadingSymbol(content) + WaitAndDisplay { + DisplayUrlWithLoadingSymbol(content) + } } } is AsyncImagePainter.State.Error -> { @@ -520,6 +525,27 @@ fun aspectRatio(dim: DimensionTag?): Float? { return dim.width.toFloat() / dim.height.toFloat() } +@Composable +fun WaitAndDisplay( + content: + @Composable() + (AnimatedVisibilityScope.() -> Unit), +) { + val visible = remember { mutableStateOf(false) } + + LaunchedEffect(Unit) { + delay(200) + visible.value = true + } + + AnimatedVisibility( + visible = visible.value, + enter = fadeIn(), + exit = fadeOut(), + content = content, + ) +} + @Composable fun DisplayUrlWithLoadingSymbol(content: BaseMediaContent) { val uri = LocalUriHandler.current diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt index 5e27dec94..71d3b9651 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt @@ -61,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.WaitAndDisplay import com.vitorpamplona.amethyst.ui.navigation.INav import com.vitorpamplona.amethyst.ui.note.DownloadForOfflineIcon import com.vitorpamplona.amethyst.ui.note.WatchAuthor @@ -216,7 +217,9 @@ fun UrlImageView( defaultModifier, ) } else { - DisplayUrlWithLoadingSymbol(content) + WaitAndDisplay { + DisplayUrlWithLoadingSymbol(content) + } } } is AsyncImagePainter.State.Error -> {