Giter Site home page Giter Site logo

paginationuimanager's Introduction

License Swift

PaginationUIManager

PaginationUIManager is a quite handy library for pagination in iOS. It also offers custom PullToRefresh View.

Features

  • Ease to implement Pagination.
  • Choise of using custom refreshing animation for pull-to-refresh or basic (default provided by iOS).
  • Bottom loader (if there is more data to load) is automatically managed.

Installation

CocoaPods

CocoaPods is the dependency manager for Cocoa Libraries. You can install Cocoapods using following command:

$ sudo gem install cocoapods

If you wish to integrate PaginationUIManager in your project, the make following changes in your Podfile:

source 'https://github.com/Nickelfox/PaginationUIManager.git'
platform :ios, '9.0'
use_frameworks!
pod 'PaginationUIManager', '~> 0.2.1'

After saving Podfile. Run following command:

pod install

Manually

If you don't want to use any dependency manager in your project, you can install this library manually too. Just add the following lines to your Podfile:

pod "PaginationUIManager", :git => 'https://github.com/Nickelfox/PaginationUIManager.git'

After saving Podfile, run following:

 pod install

Usage

It's very simple to use PaginationUIManager. What all you need is just to create a variable of type PaginationUIManager.

fileprivate var paginationUIManager: PaginationUIManager?

While initialising, PaginationUIManager requires the UIScrollView(or its subclasses i.e. UITableView or UICollectionView) and pullToRefreshView type e.g. none, basic or custom. The custom type accepts the instance of UIView.

    self.paginationUIManager = PaginationUIManager(scrollView: self.tableView, pullToRefreshType: .basic)

Also, we need to set the delegate of paginationUIManager.

    self.paginationUIManager?.delegate = self

The ViewController in which we're initialising PaginationUIManager, it must conform PaginationUIManagerDelegate.

    extension ViewController: PaginationUIManagerDelegate {
    		func refreshAll(completion: @escaping (Bool) -> Void) {
    				// your implementation.
    		}
    	
    	func loadMore(completion: @escaping (Bool) -> Void) {
    		// your implementation.
    	}
    }

refreshAll method is fired when you pull-to-refresh for new data. loadMore method is fired if there is more data to load.

For custom animations in pull-to-refresh, the UIView class must be subclass of PullToRefreshContentView.

method setState lets you mange animation of following states.

states are the cases of enum PullToRefreshViewState.

    public enum SSPullToRefreshViewState : UInt {
        // state before you start dragging to refresh
        case normal
        // state when you've dragged enough to refresh
        case ready
        // state when data is getting refreshed
        case loading
        // state when data has finished loading
        case closing
    }

If you're using this on UICollectionView, then make sure you've enabled paging and set alwaysBounceVertical property of UICollectionView to true.

Example

Detailed example is there in Demo Directory.

Want to Contribute ?

  • Fork it
  • Create your feature branch git checkout -b my-new-feature
  • Commit your changes git commit -am 'Add some feature'
  • Push to the branch git push origin my-new-feature
  • Create a new Pull Request

paginationuimanager's People

Contributors

vaibhav-nickelfox avatar ravindrasoni avatar abhishek9634 avatar abhishek-nickelfox avatar

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.