Camouflage
sinew-camouflage / sinew_camouflage: the glue between Sinew's paging and Camouflage, the component library.
One call turns a PagingState into what CamoPagedList shows: the skeleton, the items, load more, retry, refresh and the end of the list. It is the only Sinew module that depends on Camouflage.
- Kotlin
- Dart
CamoPagedList(
state = state.orders.toCamo(),
itemKey = { it.id },
onLoadMore = { viewModel.onEvent(OrderListEvent.EndReached) },
onRetry = { viewModel.onEvent(OrderListEvent.RetryTapped) },
onRefresh = { viewModel.onEvent(OrderListEvent.Refreshed) },
item = { order, _ -> CamoListItem(order.title, supporting = order.status) },
)
toCamo() uses Sinew's localizer for the current language. toCamo(localizer) takes your own.
Good to know
- Only a next-page load or failure keeps the items. A refresh drops them, so the list shows its skeleton.
- An error's text is rendered when you build the UI, so it follows the current language.
sinew-camouflagedeclares the Camouflage version range it was tested with, so an app can't silently combine incompatible versions.