Harshad Pawar
01/23/2024, 2:46 PMNikolas Guillen Leon
01/23/2024, 2:57 PMHarshad Pawar
01/23/2024, 3:04 PMNikolas Guillen Leon
01/23/2024, 3:05 PMHarshad Pawar
01/23/2024, 4:21 PMNikolas Guillen Leon
01/24/2024, 10:44 AM@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PullRefreshExample(
onUpdate: () -> Unit,
isRefreshing: Boolean
) {
val pullToRefreshState = rememberPullToRefreshState()
if (pullToRefreshState.isRefreshing) {
LaunchedEffect(key1 = true) {
onUpdate()
pullToRefreshState.endRefresh()
}
}
Box(
modifier = Modifier
.nestedScroll(pullToRefreshState.nestedScrollConnection)
.clipToBounds()
) {
Crossfade(targetState = isRefreshing, label = "PlaceholderTransition") {
if (it) {
PlaceholderList()
} else {
LazyColumn(
modifier = Modifier.fillMaxSize()
) {
items(
items = items,
) {
// items
}
}
PullToRefreshContainer(
state = pullToRefreshState,
modifier = Modifier.align(Alignment.TopCenter)
)
}
}
}
}
Nikolas Guillen Leon
01/24/2024, 10:47 AMModifier.nestedScroll(pullToRefreshState.nestedScrollConnection)
.clipToBounds()
Nikolas Guillen Leon
01/24/2024, 10:48 AMHarshad Pawar
01/24/2024, 10:49 AMNikolas Guillen Leon
01/24/2024, 10:51 AMHarshad Pawar
01/24/2024, 10:52 AMNikolas Guillen Leon
01/24/2024, 10:57 AMHarshad Pawar
01/24/2024, 10:59 AMNikolas Guillen Leon
01/24/2024, 10:59 AM