Tony Kazanjian
01/29/2021, 9:46 PMScrollableColumn
to display a list of a set number of items, i.e.:
ScrollableColumn(modifier.padding(bottom = 56.dp)) {
collections.forEach {
ProductCollection(collection = it)
}
}
The ProductCollection
essentially contains a composable that is a LazyRow
for showing LazyPagingItems
@Composable
fun ProductItemListWithId(
collectionId: Int,
modifier: Modifier = Modifier,
content: @Composable LazyItemScope.(ProductItem) -> Unit){
val viewModel: ProductListViewModel = getViewModel()
val products = viewModel.getPagingFlowForCollection(collectionId).collectAsLazyPagingItems()
LazyRow{
items(products){
product -> product?.let { content(it) }
}
}
}
ScrollableColumn
has been deprecated now, but it's only the row items that I want lazy loaded. Trying to use a LazyColumn
a la :
LazyColumn(
modifier = modifier.padding(bottom = 56.dp)) {
item {
collections.forEach {
ProductCollection(it)
}
}
}
Results in the row items not always getting loaded since they are coming from a Flow<PagingData>
that is fired lazily. What can I do to work around this, or to just simply make a normal Column
scrollable again in Alpha 11?Column(modifier.verticalScroll(rememberScrollState()).padding(bottom = 56.dp)) {
...
}