Refreshable

✳️ SwiftUI Pull to Refresh (for iOS 13 and iOS 14) package.

See complementary article at SwiftUI Pull to Refresh (for iOS 13 and iOS 14). With this extension you can backport the iOS 15 refreshable modifier to iOS 13 and iOS 14, and use the exact same code across the board.

SwiftUI_Pull_to_Refresh_iOS_13_iOS_14.mp4
struct ContentView: View {
    
	...
    
    var body: some View {
        List {
            ...
        }
        .refreshable {
            await viewModel.fetch()
        }
    }
}

Alternatively, you can opt into the closure-based API below to spare using async await API.

struct ContentView: View {
    
	...
    
    var body: some View {
        List {
            ...
        }
        .onRefresh { refreshControl in
            viewModel.fetch {
                refreshControl.endRefreshing()
            }
        }
    }
}

License

Licensed under the MIT License.

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

Last updated: Wed Apr 17 2024 00:54:38 GMT-0900 (Hawaii-Aleutian Daylight Time)