https://github.com/viacheslav-chugunov/pagedeffect
An android library that helps implement pagination in Compose for LazyList, LazyGrid and LazyStaggeredGrid.
https://github.com/viacheslav-chugunov/pagedeffect
android compose library paging paging-library ui
Last synced: about 2 months ago
JSON representation
An android library that helps implement pagination in Compose for LazyList, LazyGrid and LazyStaggeredGrid.
- Host: GitHub
- URL: https://github.com/viacheslav-chugunov/pagedeffect
- Owner: viacheslav-chugunov
- License: mit
- Created: 2024-03-16T11:33:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-16T13:34:04.000Z (over 2 years ago)
- Last Synced: 2025-07-18T06:56:07.685Z (12 months ago)
- Topics: android, compose, library, paging, paging-library, ui
- Language: Kotlin
- Homepage:
- Size: 10.7 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PagedEffect
## Description
An android library that helps implement pagination in Compose for LazyList, LazyGrid and LazyStaggeredGrid.
## Setup
Add it in your root build.gradle at the end of repositories:
```gradle
allprojects {
repositories {
maven { setUrl("https://jitpack.io") }
}
}
```
Add the dependency:
```gradle
dependencies {
implementation("com.github.viacheslav-chugunov:PagedEffect:1.0")
}
```
## Usage
|Argument|Description|
| --- | --- |
|`state`|State of LazyList, LazyGrid or LazyStaggeredGrid.|
|`totalItems`|Maximum number of elements in LazyList, LazyGrid or LazyStaggeredGrid. The value must be 1 or greater.|
|`requestOffset`|Offset of elements from the end after which the pagination request begins. The value must be 0 or greater|
|`requestNewItems`|A function called when the list has been scrolled to the end and new list elements need to be requested in order to display them.|
```kotlin
@Composable
fun PagedEffect(
state: LazyListState,
totalItems: Int,
requestOffset: Int,
requestNewItems: suspend () -> Unit
)
@Composable
fun PagedEffect(
state: LazyGridState,
totalItems: Int,
requestOffset: Int,
requestNewItems: suspend () -> Unit
)
@Composable
fun PagedEffect(
state: LazyStaggeredGridState,
totalItems: Int,
requestOffset: Int,
requestNewItems: suspend () -> Unit
)
```
|Argument|Description|
| --- | --- |
|`state`|State of LazyList, LazyGrid or LazyStaggeredGrid.|
|`totalItems`|Maximum number of elements in LazyList, LazyGrid or LazyStaggeredGrid. The value must be 1 or greater.|
|`visibleItems`|Number of items already displayed in LazyList. The value must be 1 or greater.|
|`step`|Number of items to request after pagination.|
|`requestOffset`|Offset of elements from the end after which the pagination request begins. The value must be 0 or greater.|
|`onVisibleItemsChanged`|A function called when the number of visible elements in the list needs to be updated.|
```kotlin
@Composable
fun PagedEffect(
state: LazyListState,
totalItems: Int,
visibleItems: Int,
step: Int,
requestOffset: Int,
onVisibleItemsChanged: suspend (Int) -> Unit
)
@Composable
fun PagedEffect(
state: LazyGridState,
totalItems: Int,
visibleItems: Int,
step: Int,
requestOffset: Int,
onVisibleItemsChanged: suspend (Int) -> Unit
)
@Composable
fun PagedEffect(
state: LazyStaggeredGridState,
totalItems: Int,
visibleItems: Int,
step: Int,
requestOffset: Int,
onVisibleItemsChanged: suspend (Int) -> Unit
)
```
You can also check [example of implementation](https://github.com/viacheslav-chugunov/PagedEffect/blob/main/app/src/main/java/viacheslav/chugunov/pagedeffect/ExampleComposable.kt).