Skip to content

Instantly share code, notes, and snippets.

@Pouyaa91
Last active October 19, 2023 20:44
Show Gist options
  • Save Pouyaa91/3c1508df42d96e938b2409d1f440cc37 to your computer and use it in GitHub Desktop.
Save Pouyaa91/3c1508df42d96e938b2409d1f440cc37 to your computer and use it in GitHub Desktop.
@Composable
private fun CategoryImageView(
modifier: Modifier = Modifier,
categoryName: String,
imageUrl: String
) {
val painter = rememberAsyncImagePainter(
model = ImageRequest.Builder(LocalContext.current)
.data(imageUrl)
.crossfade(200)
.build()
)
Image(
painter = painter,
contentDescription = categoryName,
contentScale = ContentScale.Crop,
modifier = modifier.fillMaxSize().run {
if (painter.state is AsyncImagePainter.State.Loading) {
background(brush = ShimmerEffectBrush())
} else {
padding(16.dp)
}
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment