Last active
October 19, 2023 20:44
-
-
Save Pouyaa91/3c1508df42d96e938b2409d1f440cc37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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