• Stars
    star
    176
  • Rank 210,772 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Assign this class to your UITableView and it will be equipped with pull to refresh as well as infinite scroll along with a callback where you don't have to worry about page number/size stuff. Thats why libraries exist :)

PaginatedTableView

Swift 5 Version License Platform Country

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Demo



Pagination or Infinite scroll is a very necessary feature in modern apps. This library makes it super easy to implement infinite scroll.
No need to keep the page number or show/hide loader logic within the ViewController, it will stay as clean as you have simple table view. πŸ‘
Guess what, it comes with pull to refresh by default ;)

Usage

Step 1: Assign custom class

  // Assign custom class to table view in storyboard
  @IBOutlet weak var tableView: PaginatedTableView!

Step 2: Remember to assign paginated delegate and data source ONLY, DO NOT assign tableViewDelegate or tableViewDataSource

  // Add paginated delegates only
  tableView.paginatedDelegate = self
  tableView.paginatedDataSource = self

Step 3: On ViewDidLoad call the load method with refresh true optional parameter

  tableView.loadData(refresh: true)

Step 4: Implement stub and call api

    func loadMore(_ pageNumber: Int, _ pageSize: Int, onSuccess: ((Bool) -> Void)?, onError: ((Error) -> Void)?) {
        // Call your api here
        // Send true in onSuccess in case new data exists, sending false will disable pagination
        
        // If page number is first, reset the list
        if pageNumber == 1 { self.list = [Model]() }
        
        // else append the data to list
        self.list.append(apiResponseList)
        
        // If Api responds with error
        onError?(apiError)        

        // Else end success with flag true if more data available
        let moreDataAvailable = !apiResponseList.isEmpty
        onSuccess?(moreDataAvailable)
    }

The latest release supports swiping cells and listening to scroll changes, please see example for more features.

Step 5: Enjoy
Yeah! Thats all. You now have paginated table view with infinite scroll along with pull to refresh ❀️
Simple, isnt it?

Installation

PaginatedTableView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PaginatedTableView'

Author

Salmaan Ahmed, [email protected]

License

PaginatedTableView is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

FlagChatAdapter

FlagChatAdapter is easy to implement enchanting recycler view adapter. Just extend your adapter with FlagChatAdapter, impliment some methods and voila! You have got the most beautiful looking chat on your phone. Zero boilerplate code, just put your variables in the right direction.
Kotlin
40
star
2

SlackRedesignFlutter

Exploring the power of UI in flutter, I decided to create something cool. I saw the concept of flutter while browsing up-laps. I used the default flutter icons and colors to keep it simple. Here I reveal the power of flutter.
Dart
37
star
3

HorizontalCalendar

Horizontal week view calendar for iOS just like apple calendar
Swift
18
star
4

SASlider

SASlider is lightweight cool looking custom slider control which enables the user to input integer or decimal values with high customizeability. User can select values by inputting in text field above slider, slide the control or tap anywhere on the slider to move it.
Kotlin
17
star
5

flutterCounter

Flutter Counter is a plugin written in dart for flutter which is really simple and customizeable. Create it like any other widget, add params according to your need and presto! You have got the highly customizeable counter with callbacks. Zero boilerplate!
Dart
15
star
6

SAExpandableButton

Expandable button is lightweight custom button which hides and shows child views on click automatically
Java
12
star
7

CustomizableSpinner

Easy spinner which populates without any creating adapter or providing layout
Kotlin
11
star
8

encryptedPrefs

Default shared prefrences in android comes with limitations. Developers cant save objects to it, neither are those encrypted. This is to make the storage much more easy, you can now save the models to local storage by calling a single function. And guess what, its also encrypted! Zero boilerplate!
Dart
10
star
9

PullToRefreshDSL

One line of code to add pull to refresh view to header or footer of any UIScrollView subclass i.e. Collection/TableView.
Ruby
9
star
10

HF-Barcode-Scanner

Simple Barcode Scanner
Java
5
star
11

DailySlackProgress

Swift
4
star
12

iOS-MVVM-Sample

Simple testable MVVM sample to start your app with
Swift
3
star
13

NSStructMapper

Library to Map NSObjects to SwiftObjects and Vice Versa
Swift
2
star
14

salmaanahmedold.github.io

HTML
1
star