mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-07 09:09:26 +00:00
update InfinityPagedComponents
This commit is contained in:
@@ -54,7 +54,8 @@ class InfinityPagedComponentContext<T> internal constructor(
|
||||
* @param page Initial page number.
|
||||
* @param size Number of items per page.
|
||||
* @param loader Suspended function that loads paginated data.
|
||||
* @param block Composable function that renders the UI with the loaded data.
|
||||
* @param block Composable function that renders the UI with the loaded data. When data is in loading state, block will
|
||||
* receive null as `it` parameter
|
||||
*/
|
||||
@Composable
|
||||
internal fun <T> InfinityPagedComponent(
|
||||
@@ -74,10 +75,8 @@ internal fun <T> InfinityPagedComponent(
|
||||
context.dataState.value = (context.dataState.value ?: emptyList()) + paginationResult.results
|
||||
}
|
||||
|
||||
context.dataState.value ?.let {
|
||||
context.block(context.dataState.value)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded composable function for an infinitely paged component.
|
||||
@@ -85,7 +84,8 @@ internal fun <T> InfinityPagedComponent(
|
||||
* @param T The type of the paginated data.
|
||||
* @param pageInfo Initial pagination information.
|
||||
* @param loader Suspended function that loads paginated data.
|
||||
* @param block Composable function that renders the UI with the loaded data.
|
||||
* @param block Composable function that renders the UI with the loaded data. When data is in loading state, block will
|
||||
* receive null as `it` parameter
|
||||
*/
|
||||
@Composable
|
||||
fun <T> InfinityPagedComponent(
|
||||
@@ -107,7 +107,8 @@ fun <T> InfinityPagedComponent(
|
||||
* @param T The type of the paginated data.
|
||||
* @param size Number of items per page.
|
||||
* @param loader Suspended function that loads paginated data.
|
||||
* @param block Composable function that renders the UI with the loaded data.
|
||||
* @param block Composable function that renders the UI with the loaded data. When data is in loading state, block will
|
||||
* receive null as `it` parameter
|
||||
*/
|
||||
@Composable
|
||||
fun <T> InfinityPagedComponent(
|
||||
|
@@ -29,7 +29,13 @@ class InfinityPagedComponentTests {
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (it == null) {
|
||||
if (this.iterationState.value.second != null) {
|
||||
assertEquals(0, (this.iterationState.value.second as? SimplePagination) ?.page)
|
||||
}
|
||||
} else {
|
||||
assertEquals(expectedList, it)
|
||||
}
|
||||
|
||||
LaunchedEffect(it ?.size) {
|
||||
loadNext()
|
||||
|
Reference in New Issue
Block a user