All Projects → rootstrap → PagedLists

rootstrap / PagedLists

Licence: MIT license
Paginated UITableView and UICollectionViews for iOS.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to PagedLists

TVToday
iOS TV Shows app with TMDb Api. RxSwift, MVVM, Clean Architecture. Tuist + Swift Package Manager
Stars: ✭ 27 (-60.87%)
Mutual labels:  swift-package-manager, spm, swift5
SwiftGradients
Useful extensions for UIViews and CALayer classes to add beautiful color gradients.
Stars: ✭ 15 (-78.26%)
Mutual labels:  swift-package-manager, spm, swift5
iOSEasyList
A data-driven UICollectionView and UITableView framework for building fast and flexible lists
Stars: ✭ 29 (-57.97%)
Mutual labels:  pagination, uitableview, uicollectionview
ios ui recipe showcase
iOSアプリ開発 - UI実装であると嬉しいレシピブック掲載サンプル
Stars: ✭ 54 (-21.74%)
Mutual labels:  uitableview, uicollectionview, swift5
Match3Kit
Library for simple Match3 games.
Stars: ✭ 38 (-44.93%)
Mutual labels:  swift-package-manager, spm, swift5
Hippolyte
HTTP Stubbing in Swift
Stars: ✭ 109 (+57.97%)
Mutual labels:  swift-package-manager, spm, swift5
MMActionSheet
An actionSheet view implement with pure swift
Stars: ✭ 25 (-63.77%)
Mutual labels:  swift-package-manager, spm, swift5
Table
CLI tables in Swift
Stars: ✭ 53 (-23.19%)
Mutual labels:  swift-package-manager, spm, swift5
Expandable Collection View Kit
🗂 Expandable, hierarchical, flexible, declarative UICollectionView with diffable data sources & SwiftUI-like tree items builder [Swift 5.1, iOS & iPadOS 13].
Stars: ✭ 69 (+0%)
Mutual labels:  uicollectionview, swift-package-manager, spm
Skeletonview
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting
Stars: ✭ 10,804 (+15557.97%)
Mutual labels:  uitableview, uicollectionview, swift-package-manager
scrivener list
A Scrivener compatible extension that allows pagination of a list of elements.
Stars: ✭ 23 (-66.67%)
Mutual labels:  pagination, paginate
iOSUtilitiesSource
IOS Utilities Library for Swift
Stars: ✭ 46 (-33.33%)
Mutual labels:  pod, swift5
React Paginate
A ReactJS component that creates a pagination
Stars: ✭ 2,169 (+3043.48%)
Mutual labels:  pagination, paginate
swift-watch
Watches over your Swift project's source
Stars: ✭ 43 (-37.68%)
Mutual labels:  swift-package-manager, spm
extensions-kit
📦 Collection of Swift+Apple Frameworks extensions for speeding up software development [iOS & iPadOS].
Stars: ✭ 71 (+2.9%)
Mutual labels:  swift-package-manager, spm
vue-tiny-pagination
A Vue component for create a tiny pagination with Flexbox
Stars: ✭ 20 (-71.01%)
Mutual labels:  pagination, paginate
Swift-FFDB
a Object/Relational Mapping (ORM) support to iOS and MacOS .Since SwiftFFDB is build on top of FMDB.
Stars: ✭ 22 (-68.12%)
Mutual labels:  swift-package-manager, swift5
Cyanic
Declarative, state-driven UI framework
Stars: ✭ 32 (-53.62%)
Mutual labels:  uitableview, uicollectionview
paginathing
a jQuery plugin to paginate your DOM easily.
Stars: ✭ 23 (-66.67%)
Mutual labels:  pagination, paginate
IQListKit
Model driven UITableView/UICollectionView
Stars: ✭ 51 (-26.09%)
Mutual labels:  uitableview, uicollectionview


PagedLists

CI Status Version License Platform Carthage SPM Swift Version

What is it?

PagedLists gives you custom UITableView and UICollectionView classes that supports pagination. All the logic and tracking of loading states, current page and when to actually request next pages is handled by these components.

Features:

  • Customizable number of elements per page.
  • Multiple scrolling directions are supported(i.e: You can load new pages of messages at the top of a chat.)
  • Supports paged scrolling in UICollectionView.
  • Uses delegation to load content from your desired source.

Installation

1. Cocoapods

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

pod 'PagedLists', '~> 1.0.0'

2. Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. Add the following line to your Cartfile and follow the installation instructions.

github "rootstrap/PagedLists" ~> 1.0.0

3. Swift Package Manager

  • In XCode 11, go to File -> Swift Packages -> Add Package Dependency.
  • Enter the repo URL(https://github.com/rootstrap/PagedLists) and click Next.
  • Select the version rule desired(you can specify a version number, branch or commit) and click Next. This library supports SPM starting from the version 1.0.0.
  • Finally, select the target where you want to use the framework.

That should be it. PagedLists should appear in the navigation panel as a dependency and the framework will be linked automatically to your target.

Note: It is always recommended to lock your external libraries to a specific version.

Usage

You can add a PagedTableView or PagedCollectionView programmatically or via Storyboards by specifying the class in the attributes inspector.

let tableView = PagedTableView(frame: <some CGRect>)

Configuration

Set the number of elements per page you are expecting from your data source.

tableView.elementsPerPage = 20

The pagination delegate

tableView.updateDelegate = self

By conforming to the pagination protocol, PagedTableView and PagedCollectionView gives you an opportunity to load the data from your desired source. You must then send the element count back or the error in case of failure.

extension ViewController: PagedTableViewDelegate {

  func tableView(
    _ tableView: PagedTableView,
    needsDataForPage page: Int,
    completion: (Int, NSError?) -> Void
  ) {
    // Load data from a network request and communicate results
    // back to the PagedTableView
    viewModel.getItems(
      page: page,
      success: { [weak self] newItemsCount in
        tableView.reloadData()
        completion(newItemsCount, nil)
      },
      failure: { [weak self] error in
        self?.showErrorToTheUser()
        completion(0, error)
      }
    )
  }
}
Custom pagination data

In the example above, we are letting PagedTableView to automatically detect if a new page request is necessary based on the number of elements loaded.

If your datasource provides data on pagination you can use that information to control when the table view loads new pages.

tableView.hasMore = requestData.isNextPageAvailable

Restart pagination

You can reset all pagination data on a table or collection view, for example, if you have a pull to refresh control.

dataSource.items = []
tableView.reloadData()
// Resets pagination
tableView.reset()

Example

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

Credits

PagedLists is maintained by Rootstrap and German López with the help of our contributors.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].