diff --git a/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/DynamicAsyncImage.kt b/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/DynamicAsyncImage.kt index 3bd3471ad..cc352107b 100644 --- a/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/DynamicAsyncImage.kt +++ b/core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/DynamicAsyncImage.kt @@ -31,6 +31,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import coil.compose.AsyncImage @@ -60,11 +61,12 @@ fun DynamicAsyncImage( isError = state is Error }, ) + val isLocalInspection = LocalInspectionMode.current Box( modifier = modifier, contentAlignment = Alignment.Center, ) { - if (isLoading) { + if (isLoading && !isLocalInspection) { // Display a progress bar while loading CircularProgressIndicator( modifier = Modifier @@ -75,10 +77,9 @@ fun DynamicAsyncImage( } Image( contentScale = ContentScale.Crop, - painter = if (isError.not()) imageLoader else placeholder, + painter = if (isError.not() && !isLocalInspection) imageLoader else placeholder, contentDescription = contentDescription, colorFilter = if (iconTint != null) ColorFilter.tint(iconTint) else null, - modifier = modifier, ) } } diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt index 908e3352c..de4aec9d7 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt @@ -158,6 +158,7 @@ fun NewsResourceHeaderImage( isError = state is AsyncImagePainter.State.Error }, ) + val isLocalInspection = LocalInspectionMode.current Box( modifier = Modifier .fillMaxWidth() @@ -179,7 +180,11 @@ fun NewsResourceHeaderImage( .fillMaxWidth() .height(180.dp), contentScale = ContentScale.Crop, - painter = if (isError.not()) imageLoader else painterResource(drawable.ic_placeholder_default), + painter = if (isError.not() && !isLocalInspection) { + imageLoader + } else { + painterResource(drawable.ic_placeholder_default) + }, // TODO b/226661685: Investigate using alt text of image to populate content description contentDescription = null, // decorative image, )