Status Update
Comments
ma...@google.com <ma...@google.com>
an...@google.com <an...@google.com>
ap...@google.com <ap...@google.com> #2
Branch: androidx-main
commit e49f41b5b0518f0c3d808e89eb0c116f797d8d5a
Author: Mihai Popa <popam@google.com>
Date: Wed Oct 27 15:32:10 2021
Add support for spans in LazyVerticalGrid
Relnote: Support for horizontal spans was added to LazyVerticalGrid.
Test: LazyGridTest
Fixes: 176758183
Change-Id: I7e2fa4e915b28aa96980a53c4b9ad79bdb7aeeb2
M compose/foundation/foundation/api/restricted_1.1.0-beta03.txt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/public_plus_experimental_1.1.0-beta03.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyGrid.kt
M compose/foundation/foundation/api/current.txt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyGridSpan.kt
M compose/foundation/foundation/api/1.1.0-beta03.txt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyGridTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/TempListUtils.kt
jo...@gmail.com <jo...@gmail.com> #3
I am trying this new spans method, but I am not getting expected behaviors. If the items between the headers matches the correct number of spans it looks as expected but when there is an empty space the header gets put in the same row.
LazyVerticalGrid(
cells = GridCells.Fixed(2),
modifier = modifier,
contentPadding = PaddingValues(8.dp)
) {
items(
items = data,
spans = {
when (it) {
is Header -> GridItemSpan(2)
is Value -> GridItemSpan(1)
}
},
itemContent = {
when (it) {
is Header -> TextHeader(text = it.value, modifier = Modifier.fillMaxWidth())
is Value -> Box(
modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.padding(8.dp)
.background(Color.Red)
)
}
}
)
}
ld...@gmail.com <ld...@gmail.com> #4
jo...@gmail.com <jo...@gmail.com> #5
I have found a solution for this so long as I know how many columns there are, I mainly use GridCells.Adaptive. If the number of columns can be passed to the content block I am good to go.
po...@google.com <po...@google.com> #6
Re
te...@gmail.com <te...@gmail.com> #7
Also doesn't LazyVerticalGrid have a key that you can specify for each item like LazyColumn? Won't scroll position get lost if that's the case?
po...@google.com <po...@google.com> #8
How does this work if we are using GridCells.Adaptive(300.dp)
The number of columns will be calculated according to the available width and then the behaviour will be the same as with GridCells.Fixed
I've tried specifying GridItemSpan(Int.MAX_VALUE) but it doesn't seem to work.
Hmm, what would be the expected behaviour here? The span will just be limited to the number of columns.
doesn't LazyVerticalGrid have a key It will. Note LazyVerticalGrid is still experimental and not feature complete / API stable.
Description