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
This commit is contained in:
OneWay authored and Evgenii committed 2026-10-15 13:50:31 +08:00
1 parent 5832e2db4a
commit 460c50bfd9
1 file changed
+12 -20
@@ -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,
)
}