Hi guys, I try to create test application and I ne...
# compose
v
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
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
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
Thanks, guys, it's just test project, so I can try any working solutions :)
a
Where is this PR experiment API. Can anyone please provide a link
t
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
Thanks, Timo, I will look into your implementation 💪