Code Monkey home page Code Monkey logo

ios.blog.swiftui_pull_to_refresh's Introduction

SwiftUI Pull to Refresh

⬇️🔄 SwiftUI Pull to Refresh (for iOS 13 and iOS 14) condensed into a single modifier.

Complementary repository for article 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()
            }
        }
    }
}

Quick Start

See details in OnRefreshModifier.swift and RefreshableModifier.swift in Refreshable package. Find the examples above in the Examples folder.

For your own projects, simply use Refreshable Swift Package.

License

Licensed under the MIT License.

ios.blog.swiftui_pull_to_refresh's People

Contributors

geri-borbas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ios.blog.swiftui_pull_to_refresh's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.