CamoPagedList
A list screen that loads from an API: skeleton rows while a page loads, the next page when the user nears the
end, pull to refresh on touch devices, an empty state, and a retry when a page fails. It's controlled: it
renders state and never fetches. onLoadMore fires once per state when the last visible row is within
prefetchDistance of the end, and never while loading, after endReached or with a next-page error.
onRefresh enables the pull gesture (there's no gesture with a mouse: offer a refresh action too).
itemKey must be unique and stable.
API
- Kotlin
- Dart
public fun <T> CamoPagedList(
state: CamoPagedListState<T>,
itemKey: (T) -> Any,
onLoadMore: () -> Unit,
onRetry: () -> Unit,
item: @Composable LazyItemScope.(item: T, index: Int) -> Unit,
modifier: Modifier = Modifier,
listState: LazyListState = rememberLazyListState(),
onRefresh: (() -> Unit)? = null,
skeleton: (@Composable () -> Unit)? = null,
empty: (@Composable () -> Unit)? = null,
firstPageError: (@Composable (message: String) -> Unit)? = null,
header: (@Composable () -> Unit)? = null,
separator: (@Composable (index: Int) -> Unit)? = null,
contentPadding: PaddingValues = PaddingValues(0.dp),
)
| Name | Type | Default |
|---|---|---|
state | CamoPagedListState<T> | required |
itemKey | (T) -> Any | required |
onLoadMore | () -> Unit | required |
onRetry | () -> Unit | required |
item | @Composable LazyItemScope.(item: T, index: Int) -> Unit | required |
modifier | Modifier | Modifier |
listState | LazyListState | rememberLazyListState() |
onRefresh | (() -> Unit)? | null |
skeleton | (@Composable () -> Unit)? | null |
empty | (@Composable () -> Unit)? | null |
firstPageError | (@Composable (message: String) -> Unit)? | null |
header | (@Composable () -> Unit)? | null |
separator | (@Composable (index: Int) -> Unit)? | null |
contentPadding | PaddingValues | PaddingValues(0.dp) |
Design notes
Why CamoPagedList works this way, its states and its edge cases: contributor docs.