Coder Social home page Coder Social logo

refreshablescrollview's Introduction

RefreshableScrollView

This project is only for SwiftUI

Pull-to-refresh functionality for List and ScrollView controls

Encapsulated UITableView, UIScrollView, UICollectionView can also be used

Supported Platforms

  • iOS 13.0
  • macOS 10.15
  • tvOS 13.0
  • watchOS 6.0

Usage

        class ViewModel: ObservableObject {
        @Published var isRefresh: Bool = false
    }
    
    let array = ["text1", "text2", "text3"]
    @StateObject private var vm = ViewModel()
    
    var body: some View {
        List {
            ForEach(0..<array.count) { index in
                let text = array[index]
                HStack {
                    Text(text)
                }
            }
        }
        .pullToRefresh($vm.isRefresh) {
            // refresh done
            DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
                vm.isRefresh = false
            }
        }
    }

Installation

You can add RefreshableScrollView to an Xcode project by adding it as a package dependency.

  1. From the File menu, select Swift PackagesAdd Package Dependency…
  2. Enter https://github.com/HumorousGhost/RefreshableScrollView into the package repository URL text field
  3. Link RefreshableScrollView to your application target

refreshablescrollview's People

Contributors

beryu avatar humorousghost avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

beryu

refreshablescrollview's Issues

Supports the UIRefreshControl behavior like preinstalled apps

Thanks for publishing the great library!
And I think this touch and feel can be improved with UIRefreshControl.

In Mobile Safari (one of the apps that are preinstalled on iOS), "pull to refresh" is fired with enough scroll.
But this library is not.

If RefreshScrollView supports the UIRefreshControl behavior like preinstalled apps, maybe it makes UX be greater!

RefreshableScrollView

Refreshing is fired with little scrolls.

demo.mov

Mobile Safari (iOS 16)

Refreshing is fired with scrolls that fill UIRefreshControll's circle.

safari.mov

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.