Implementation of pull down to refresh in SwiftUI compatible with iOS 13.
You can use it as a modifier to your existing views
var body: some View {
LazyVStack {
if isLoading {
ProgressView()
}
ForEach(posts) { post in
PostView(post: post)
}
}
.modifier(GFRefreshableScrollViewModifier(action: refreshAction))
}
Or use it instead of a ScrollView
var body: some View {
GFRefreshableScrollView(action: refreshList) {
if isLoading {
VStack {
ProgressView()
Text("loading...")
}
}
VStack {
ForEach(posts) { post in
PostView(post: post)
}
}
}
}
If you want to find out more about the implementation please refer to my blog post
GFRefreshableScrollView is available under the MIT license. See the LICENSE file for more info.