Compose Broadcast
5.42K subscribers
313 photos
84 videos
509 links
Все о Jetpack Compose и Compose Multiplatform

YouTubе канал: https://youtube.com/androidBroadcast
Android - @android_broadcast
iOS - @ios_broadcast
Kotlin - @kotlin_broadcast
Download Telegram
⚙️ Paging3 в стиле Compose: секретный DSL, о котором молчат все Android-разработчики (11м)

Автор статьи написал простое DSL для упрощения работы с пагинацией через JetPack Paging3, вместо решения в лоб от Google. Исходны код на 🐱 GitHub

@Composable
fun ArticlesPage(
articles: LazyPagingItems<Article>,
onAction: (NewsListAction) -> Unit,
) {
val newsListState = rememberLazyListState()

HandlePagingItems(articles) {
onRefresh { CircularProgressIndicator() }
onEmpty { // UI for empty list }
onError { error -> // UI for error }
onSuccess { items ->
LazyColumn(newsListState) {
onPagingItems(key = { it.id }) { article -> // UI for article }
onAppendItem { CircularProgressIndicator(Modifier.padding(6.dp)) }
onLastItem { // UI for end of the list }
}
}
}
}


#compose #dsl
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥43👍10