Component - Pull-to-refresh (refreshable)
This UI component allows users to refresh the content of a list by pulling down on the screen. It shows a spinner while loading new data, then updates the list when done.
This UI component allows users to refresh the content of a list by pulling down on the screen. It shows a spinner while loading new data, then updates the list when done.
UIViewController
└── UITableView
└── UIRefreshControl.refreshable modifier do in a SwiftUI List?.refreshable.refreshable modifier adds pull-to-refresh functionality to scrollable views like List..refreshable with an async closure..refreshable { await loadData() } which is correct syntax.List(items, id: \.self) { item in
Text(item)
}
.refreshable {
await fetchNewItems()
}.refreshable with async closurefetchNewItems() runs asynchronously to update data.fetchNewItems() completes, the list reloads showing updated items.List(data) { item in
Text(item.name)
}
.refreshable {
fetchData()
}.refreshable modifier works on ScrollView and accepts an async closure.Pass the test and this pattern moves unknown