https://kotlinlang.org logo
v

vityokkv73

06/30/2020, 10:03 AM
Hi guys, I try to create test application and I need to implement pagination for LazyColumnItems. But I couldn't find how to get current visible item position to trigger loading of next page. Should I just get index of itemContent and compare it with items count?
m

molikto

06/30/2020, 12:05 PM
Currently there is no support for it. I've seen a PR experiment to add API for this, but not merged yet. I guess they are still not sure what kind of API is the best
It is pretty easy to add though, if you are willing to make the extra effort to change & compile Compose yourself. (Edit: you can also copy the code out
a

Andrey Kulikov

06/30/2020, 12:06 PM
hey! unfortunately this is not yet supported, but planned. maybe you can try to temporary implement it manually if you add Modifier.onPositioned() for the last item and do your logic when the boundsInRoot are not empty - which means visible
v

vityokkv73

06/30/2020, 12:35 PM
Thanks, guys, it's just test project, so I can try any working solutions :)
a

amar_1995

06/30/2020, 2:33 PM
Where is this PR experiment API. Can anyone please provide a link
t

Timo Drick

07/15/2020, 8:52 AM
If you want you can use this alternative implementation of LazyColumnItems (VerticalLayoutList) it is used the same way. But in addition you can define a LayoutListPosition which includes state of the list. But for you use case maybe you should add a callback to the constructor which is called when end of list is reached or something like that. https://gitlab.com/timod/compose-playground/-/blob/master/compose_list/src/main/java/de/drick/compose/list/LayoutList.kt
👍 1
v

vityokkv73

07/17/2020, 1:43 PM
Thanks, Timo, I will look into your implementation 💪