SwiftUI-RefreshableScrollView
I was stuck at not able to find a reliable SwiftUI library to support "pull to refresh".
So I made my own.
Introspect
is needed as a dependency for this solution.
Warning: package Demo:
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-07-03.at.21.15.27.mp4
Usage:
struct __DEMO_VRSV: View {
var body: some View {
VanRefreshableScrollView(
useInputOffsetY: false,
inputOffsetY: 0,
refreshIcon: "ic_mg_information_history",
refreshHint: "Pull to refresh",
isDisableRefreshHint: false,
onRefresh: { completion in
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
completion()
}
}) {
// Put any view, list, or any content inside this area
LazyVStack(spacing: 0) {
ForEach(0 ..< 100) {i in
Text("Item \(i)")
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
.frame(height: 30)
}
}
}
}
}