Pull to refresh in SwiftUI for List, NavigationView

Overview

SwiftUI-PullToRefresh

Pull to refresh implementation in SwiftUI for List and NavigationView

This article helped me a lot: https://swiftui-lab.com/scrollview-pull-to-refresh/ Thanks!

pulltorefresh

Installation:

It requires iOS 13 and Xcode 11!

In Xcode got to File -> Swift Packages -> Add Package Dependency and paste inthe repo's url: https://github.com/AppPear/SwiftUI-PullToRefresh

Usage:

You need to add RefreshableNavigationView(title: String, action: () -> Void, content: () -> View) to your View. Title is the navigationView title, and the action takes the refresh function. RefreshableNavigationView already encapsulates a List() so in the content you only need to define your cells. If you want TableViewCellSeparators don't forget to add a Divider() at the bottom of your cell.

Example:

import SwiftUIPullToRefresh

struct ContentView: View {
    @State var numbers:[Int] = [23,45,76,54,76,3465,24,423]
    
    var body: some View {
        RefreshableNavigationView(title: "Numbers", action:{
            self.numbers = self.generateRandomNumbers()
        }){
            ForEach(self.numbers, id: \.self){ number in
                VStack(alignment: .leading){
                    Text("\(number)")
                    Divider()
                }
            }
        }
    }
    
    func generateRandomNumbers() -> [Int] {
        var sequence = [Int]()
        for _ in 0...30 {
            sequence.append(Int.random(in: 0 ..< 100))
        }
        return sequence
    }
}
Comments
  • Update README.md

    Update README.md

    Improve example

    added "import SwiftUIPullToRefresh" or Xcode will complain about "Use of unresolved identifier 'RefreshableNavigationView'"

    opened by B1G 0
  • Added Navigationbar Items

    Added Navigationbar Items

    Hey,

    I added a option for navigationBar Items. And fixed the list divider. I'm just hiding the background color of the section header background color but this is less used than the list divider. And you can add it always you self with .backgroundColor again. And after the refresh the user will now see done.

    Also I updated you data structure to combine.

    I hope everything is fine, this time.

    opened by Veeit 0
  • Add documentation

    Add documentation

    This looks like a really cool library, but you're shooting yourself in the foot by not adding proper documentation. Doing so would likely increase the number of people who use your library.

    opened by Peter-Schorn 2
  • Changed the displayMode of navigationbarTitle to be able to decide

    Changed the displayMode of navigationbarTitle to be able to decide

    I'm interested in PullToRefresh in SwiftUI !!!

    I tried to select the displaymode of navigationTitle. Maybe it's related to #7.

    Xcode version Version 11.5 (11E608c)

    opened by giiiita 0
  • Small adjustment to the Spinner. It looks better if having 12 rectangles instead of 10.

    Small adjustment to the Spinner. It looks better if having 12 rectangles instead of 10.

    I made a small adjustment to the Spinner as below

    • Add two more rectangle to look similar to the iOS native Spinner
    • Put it inside a ZStack view to centralize the Spinner
    • Increase/Decrease the size of the Spinner based on its parent frame.

    spinner_adjustment

    opened by phuhuynh2411 2
  • Add possibility of async fetch

    Add possibility of async fetch

    Hi. Awesome project !

    It could be interesting to add the possibility to hide the ActivityIndicator after a server response and not directly after the action call

    opened by cederache 1
Releases(1.0.0)
Owner
Andras Samu
CS undergrad. Recently involved in AR, Vision with ML, React Native. Usually I do mobile app development.
Andras Samu
Todo-list - Simple todo list app written in Swift

About TodoApp TodoApp is sinmple todo list app that I created in my free time, i

null 2 Aug 30, 2022
An example to-do list app using SwiftUI which is introduced in WWDC19

SwiftUITodo SwiftUITodo is an example to-do list application using SwiftUI which is first introduced in WWDC19 keynote. Requirements Xcode 11 Beta Swi

Suyeol Jeon 701 Dec 23, 2022
Basic Todo list application built using the new SwiftUI framework and Core Data

Dub Dub Do - A sample TODO List Application in SwiftUI Updated for Xcode 11.5 This is a basic app that lets you create a list of todos, mark them as i

Stephen McMillan 67 Sep 28, 2022
A to-do list app using SwiftUI and combine with restful api.

Todo Combine SwiftUI It's an experiment project for the brand new SwiftUI + Combine + restful API with dark mode Build follow restfult to-do-api to ru

jamfly 14 Feb 21, 2022
In this mini app covered the concepts like basics of SwiftUI and Navigations and Animations and List with CRUD functions and MVVM and App Launch and App icons adding and also applied persistence using UserDefaults Concept.

TodoList In this application used the concepts from the beginner level project of SwiftUI_Evolve_1 The following concepts covered in this mini app Swi

Sivaram Yadav 2 Dec 4, 2021
Shows a Pokémon list with its image and name with SwiftUI

TelepassDigitalTestIB Description General This project aims to develop an app, for Telepass interview process, that shows a Pokémon list with its imag

null 1 Jul 5, 2022
Todo list with SwiftUI

TodoList.Capstone Todo list with SwiftUI i did is a Todo-List you can create a new todo by providing its name and description and the deadline of the

areej Mashabi 0 Nov 14, 2021
SwiftUI movies list using The Movie Database (TMDB) API

MyMoviesList About MyMovieList is an application that uses The Movie Database (TMDB) API and is built with SwiftUI. It demo of some SwiftUI (& Combine

Arnaud 1 Dec 5, 2021
SwiftUIIndexedList - Add an index bar to a SwiftUI List or ScrollView

SwiftUIIndexedList Add an index bar to a SwiftUI List or ScrollView. Getting Sta

Ciaran O'Brien 25 Oct 27, 2022
Workaround to hide/modify List separators in SwiftUI iOS13 and iOS14

Help support my open source work! iOS15 List finally supports setting list row separator color and style as of iOS15! They still don't support list in

Michael Schmidt 135 Dec 7, 2022
Aplikasi iOS Advanced Level To Do List dengan Firebase Auth, SwiftUI, MVVM Design Pattern, dan Firebase Firestore

Aplikasi Tasker adalah aplikasi iOS To Do List yang dibuat menggunakan Autentikasi Firebase / Firestore dan MVVM Design Pattern.

DK 10 Oct 17, 2022
This is a repository with an app that shows a list of posts and where you can access the detail of each of them

PostsApp This is a repository with an app that shows a list of posts and where you can access the detail of each of them Dependencies You need to inst

Patricia Zambrano 1 Jun 21, 2022
iOS App to display game lists and details with the ability to add games to your favorites list and see metacritic ratings.

Game Data System - GDS Author: Heitor Silveira ([email protected]) iOS App to view games from various platforms, their description, release

Heitor Ugarte Calvet da Silveira 0 Oct 6, 2021
iOS app that allows you to search for any comic character and save your favorites in a list.

iOS App: My Comics Swift exercise ¡Hola mundo! In my Swift learning journey my mentor and I decided to do an app using the Comic Vine API. This API gi

Silvia España Gil 5 Dec 13, 2022
Shopping List App Built Using Swift

ShoppingList 2021-11-03.11.03.06.mov 2021-11-03.11.03.49.mov 사용한 것 Realm Alert ActionSheet UITableView -> Edit, Swipe 주요 기능 MongoDB, Realm을 활용한 쇼핑 리스트

Seungchan 0 Nov 4, 2021
iOS App by which the user can display a list of characters from the Harry Potter Movies.

iOS App by which the user can display a list of characters from the Harry Potter Movies. They can display a list of all characters, students, staff or view characters by house.

Matthew Hollyhead 0 Nov 7, 2021
The iOS application has the Pokémon list. In the app

The iOS application has the Pokémon list. In the app, you can search for Pokémon by name, edit the Pokémon list (mark favorites or delete unwanted ones ?? ), and re-update the Pokémon list from the network.

Volodya 0 Nov 16, 2021
A grocery list app for families written in Swift using Firebase Realtime Database

FamiList | Grocery list app in Swift FamiList is a grocery list app for families written in Swift using Firebase Realtime Database. You can add differ

Wasan Ibrahim 2 Jul 31, 2022
A todo list iOS app developed with swift5 and coredata to persist data, this app help people organise their tasks on categories.

A todo list iOS app developed with swift5 and coredata to persist data, this app help people organise their tasks on categories. The app is simple, intuitive, and easy to use and update tasks informations.

null 1 Oct 10, 2022