
LazyRow(
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth()
) {
items(favoriteBooks.size, key = { index ->
favoriteBooks[index].id
}) {
val painter = remember {
mutableStateOf(null)
}
Column(
modifier = Modifier
.wrapContentWidth()
.wrapContentHeight()
.padding(end = 16.dp)
.border(2.dp, color = Color.Magenta),
horizontalAlignment = Alignment.Start
) {
painter.value = rememberAsyncImagePainter(
model = ImageRequest.Builder(context)
.data(
if (favoriteBooks.get(it).thumbnail.isNullOrEmpty())
R.drawable.placeholder
else
favoriteBooks.get(it).thumbnail
)
.crossfade(true)
.placeholder(R.drawable.placeholder)
//.transformations(RoundedCornersTransformation(1f))
.size(Size.ORIGINAL)
.build()
)
Image(
painter = painter.value as AsyncImagePainter,
contentDescription = null,
contentScale = ContentScale.FillHeight,
alignment =Alignment.BottomStart,
modifier = Modifier
.fillMaxHeight(0.3f)
.aspectRatio(1f)
.width(IntrinsicSize.Min)
//.wrapContentWidth()
)
Text(text = favoriteBooks[it].categories[0], color = Color.Green)
Text(text = favoriteBooks[it].title, color = MaterialTheme.colors.onSurface)
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/759 ... pack-compo
Мобильная версия