From 460c50bfd960fe7f7ab07d917eba9d8dda937182 Mon Sep 17 00:00:00 2001 From: OneWay Date: Thu, 15 Oct 2026 13:42:05 +0800 Subject: [PATCH] Fix photo viewer flicker when opening an image - Keep the grid composed under the viewer instead of swapping it for a black box, removing the momentary black flash while the pager draws its first frame after tapping a photo - Restore the pre-audit fade: thumbnail stays fully opaque under the fading-in full image instead of crossfading both over black --- .../onecamera/ui/gallery/GalleryScreen.kt | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/example/onecamera/ui/gallery/GalleryScreen.kt b/app/src/main/java/com/example/onecamera/ui/gallery/GalleryScreen.kt index db68067..e97a852 100644 --- a/app/src/main/java/com/example/onecamera/ui/gallery/GalleryScreen.kt +++ b/app/src/main/java/com/example/onecamera/ui/gallery/GalleryScreen.kt @@ -49,8 +49,8 @@ import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource @@ -408,14 +408,6 @@ fun GalleryScreen( Box(modifier = Modifier.fillMaxSize()) { when { - uiState.selectedPhoto != null -> { - Box( - modifier = Modifier - .fillMaxSize() - .background(Color.Black), - ) - } - !uiState.viewPreferencesLoaded -> { Box(modifier = Modifier.fillMaxSize()) } @@ -670,16 +662,16 @@ private fun ZoomablePhoto( Box(modifier = modifier.fillMaxSize()) { - AsyncImage( - model = remember(photo.uri, context, fadeMs) { - thumbnailDraftRequest(context, photo.uri, crossfadeMillis = fadeMs) - }, - contentDescription = null, - contentScale = ContentScale.Fit, - modifier = Modifier - .fillMaxSize() - .graphicsLayer { alpha = 1f - fullAlpha }, - ) + if (fullAlpha < 1f) { + AsyncImage( + model = remember(photo.uri, context, fadeMs) { + thumbnailDraftRequest(context, photo.uri, crossfadeMillis = fadeMs) + }, + contentDescription = null, + contentScale = ContentScale.Fit, + modifier = Modifier.fillMaxSize(), + ) + } CoilZoomAsyncImage( model = fullImageRequest, contentDescription = photo.name, @@ -688,7 +680,7 @@ private fun ZoomablePhoto( onError = { isFullReady = false }, modifier = Modifier .fillMaxSize() - .graphicsLayer { alpha = fullAlpha }, + .alpha(fullAlpha), zoomState = zoomState, ) }