Is there a way to have a modifier for the `items` ...
# compose-desktop
a
Is there a way to have a modifier for the
items
block? I don't want to set a modifier for the whole
LazyColumn
.
m
No because `items`is not a node, for that you have to have a nested (Lazy)Column with the modifier wrapping these items.
a
But I can't nest
LazyColumn
.
m
So you're left with Column. This is ofc. if you can't just pass the modifier to individual children
a
If I use a
Column
then it defeats the purpose of
LazyColumn
.
m
Oh OK, you want the modifier for all the items in the column. Then you can't do what you ask for, but what exactly is that modifier that you neither want it on the whole LazyColumn nor each item?
a
I have an
item
which has a border around it. I want to do the same thing with
items
so they also have a single border around them (not on each item but the whole list) so then, they would look separated.
m
All the items are wrapped by the LazyColumn, so you can set the border on it. If you want it to be scrollable, I think you can wrap the LazyColumn in some Box.fillMaxHeight() and have to scrollbar inside of it, something like that should work.
a
I'm trying to use two borders and not one. One around the first element and the second around the items.
m
So [ first item ] [ other items ] ?
a
Exactly
m
Or [ [ first item ] other items ] ?
ok
Then I don't know how to do that 😞
a
It's okay. I don't think it's possible unfortunately.
m
But couldn't you have
Copy code
Column {
   FirstItem(Modifier.border())
   LazyColumn(Modifier.border()) {
       items(otherItems)
   }
}
a
The problem with this, is that the
FirstItem
won't be scrollable.
I'm thinking of adding an item (which has border) and set its size to the sum of all the items, I haven't tried it yet
m
Ah right
Well, you can for sure write your own implementation of the border (with the use of `LazyListState.layoutInfo`but it may be not super easy
a
I can't find an API to set custom layoutInfo and layoutInfo doesn't contain any params about layout shape.
f
Have you explored sticky header? You may be able to twist it to do that
👍 1
a
Can you please elaborate more? 🤔