Skip to content

Instantly share code, notes, and snippets.

@chiragthummar
Created December 25, 2023 06:41
Show Gist options
  • Save chiragthummar/6a323d55fd3130c458d3f0cb2913d7c3 to your computer and use it in GitHub Desktop.
Save chiragthummar/6a323d55fd3130c458d3f0cb2913d7c3 to your computer and use it in GitHub Desktop.
@Composable
fun MyListView(
images: List<Image>
) {
LazyVerticalGrid(
contentPadding = PaddingValues(4.dp),
columns = GridCells.Fixed(2),
modifier = Modifier.fillMaxSize()
) {
items(images, key = {
it.id
}) { img ->
ImageItem(img.srcSmall)
}
}
}
@Composable
fun ImageItem(url: String) {
Box(
modifier = Modifier
.padding(6.dp)
.fillMaxWidth()
.clip(shape = RoundedCornerShape(12.dp))
.background(color = MaterialTheme.colorScheme.onPrimaryContainer),
) {
Image(
painter = rememberAsyncImagePainter(model = url),
contentDescription = "",
contentScale = ContentScale.FillWidth,
modifier = Modifier
.fillMaxWidth()
.height(170.dp)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment