Fixes icons size in onboarding and restores LocalInspection for images (#909)

* Fixes icons size in onboarding and restores LocalInspection for images
pull/912/head
Jose Alcérreca 2 years ago committed by GitHub
parent 6645ec9fce
commit 6c0d6ad82e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -31,6 +31,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage import coil.compose.AsyncImage
@ -60,11 +61,12 @@ fun DynamicAsyncImage(
isError = state is Error isError = state is Error
}, },
) )
val isLocalInspection = LocalInspectionMode.current
Box( Box(
modifier = modifier, modifier = modifier,
contentAlignment = Alignment.Center, contentAlignment = Alignment.Center,
) { ) {
if (isLoading) { if (isLoading && !isLocalInspection) {
// Display a progress bar while loading // Display a progress bar while loading
CircularProgressIndicator( CircularProgressIndicator(
modifier = Modifier modifier = Modifier
@ -75,10 +77,9 @@ fun DynamicAsyncImage(
} }
Image( Image(
contentScale = ContentScale.Crop, contentScale = ContentScale.Crop,
painter = if (isError.not()) imageLoader else placeholder, painter = if (isError.not() && !isLocalInspection) imageLoader else placeholder,
contentDescription = contentDescription, contentDescription = contentDescription,
colorFilter = if (iconTint != null) ColorFilter.tint(iconTint) else null, colorFilter = if (iconTint != null) ColorFilter.tint(iconTint) else null,
modifier = modifier,
) )
} }
} }

@ -158,6 +158,7 @@ fun NewsResourceHeaderImage(
isError = state is AsyncImagePainter.State.Error isError = state is AsyncImagePainter.State.Error
}, },
) )
val isLocalInspection = LocalInspectionMode.current
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
@ -179,7 +180,11 @@ fun NewsResourceHeaderImage(
.fillMaxWidth() .fillMaxWidth()
.height(180.dp), .height(180.dp),
contentScale = ContentScale.Crop, 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 // TODO b/226661685: Investigate using alt text of image to populate content description
contentDescription = null, // decorative image, contentDescription = null, // decorative image,
) )

Loading…
Cancel
Save