Nat Strangerweather
07/01/2021, 8:17 PMNat Strangerweather
07/01/2021, 8:18 PMColumn(Modifier.fillMaxSize()) {
LazyVerticalGrid(
cells = GridCells.Fixed(2),
contentPadding = PaddingValues(start = 20.dp, end = 20.dp, top = 20.dp)
) {
items(4) {
CardItem(feature = features[it])
}
}
}
Nat Strangerweather
07/01/2021, 8:18 PM4
I'd like 0..3
Nat Strangerweather
07/01/2021, 8:20 PM4..7
to be in an AnimatedVisibility
so they slide in when my button is pressed.Jesse Hill
07/01/2021, 8:48 PMwindowed
to get the first and last window of items then show them conditionally using AnimatedVisibility
instead of the if
statement in the example. You could remember the calculation of the windows or something so you don’t have to recalculate them each recompose. Something like this:
val itemList = listOf(1..7).windowed(size = 4, step = 1)
val lastFour = itemList.last()
val firstFour = itemList.first()
var showSecondWindow by remember { mutableStateOf(false) }
Column(Modifier.fillMaxSize()) {
LazyVerticalGrid(
cells = GridCells.Fixed(2),
contentPadding = PaddingValues(start = 20.dp, end = 20.dp, top = 20.dp)
) {
if (showSecondWindow)
items(lastFour) {
CardItem(feature = features[it])
}
else
items(firstFour) {
CardItem(feature = features[it])
}
}
}
I’m not sure how that’d affect the Performance of the Lazy part of the grid though or if swapping the items out is really what you want. Maybe it will give you another idea though 🙂Nat Strangerweather
07/01/2021, 8:56 PMNat Strangerweather
07/01/2021, 9:12 PMitemsIndexed
😊Andrey Kulikov
07/01/2021, 10:56 PM(0..3).toList()