Swiftpack.co -  postolaki/POSInfiniteScroll as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
postolaki/POSInfiniteScroll
swift InfiniteScroll & PullToRefresh
.package(url: "https://github.com/postolaki/POSInfiniteScroll.git", from: "v1.0.6")

POSInfiniteScroll

Example

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

Requirements

  • ☑ Swift 5
  • ☑ iOS 10 or higher

Installation

CocoaPods

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

pod 'POSInfiniteScroll'

Carthage

Add POSInfiniteScroll to your Cartfile:

github "postolaki/posinfinitescroll"

And then run:

carthage update or carthage update --use-xcframeworks

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding POSInfiniteScroll as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/postolaki/POSInfiniteScroll.git")
]
import POSInfiniteScroll

InfiniteScroll

// setup infinite scroll
tableView.addInfiniteScroll { tableView in
    // finish infinite scroll animation
    tableView.finishInfiniteScroll()
}

collectionView.addInfiniteScroll { collectionView in
    // finish infinite scroll animation
	collectionView.reloadDataAndFinishInfIniteScroll()
}

tableView.shouldRemoveInfiniteScrollHandler = { _ in
    return condition to remove infinite scroll
}

Public methods and properties

func addInfiniteScroll(_ completion: @escaping (UITableView) -> Void)
func addInfiniteScroll(_ completion: @escaping (UICollectionView) -> Void)
func finishInfiniteScroll(_ completion: (() -> Void)? = nil)
func removeInfiniteScroll()

var infiniteScrollTriggerOffset: CGFloat
var shouldRemoveInfiniteScrollHandler: () -> Bool

Custom indicator

Custom indicator must conform to protocol SpinnerViewProtocol

protocol SpinnerViewProtocol: UIView {
    func startAnimating()
    func stopAnimating()
}

var infiniteScrollSpinnerView: SpinnerViewProtocol?

PullToRefresh

// setup pull to refresh
tableView.addPullToRefresh { tableView in
    // finish pull to refresh animation
	tableView.finishPullToRefresh()
}

collectionView.addPullToRefresh { collectionView in
    // finish pull to refresh animation
    collectionView.reloadDataAndFinishPullToRefresh()
}

Public methods and properties

func beginPullToRefresh(_ completion: (() -> Void)? = nil)
func addPullToRefresh(_ completion: @escaping (UITableView) -> Void)
func addPullToRefresh(_ completion: @escaping (UICollectionView) -> Void)
func finishPullToRefresh(_ completion: (() -> Void)? = nil)
func removePullToRefresh()

var pullToRefreshTriggerOffset: CGFloat

Custom indicator

Custom indicator must conform to protocol PullToRefreshSpinnerViewProtocol

protocol PullToRefreshSpinnerViewProtocol: SpinnerViewProtocol {
    var progress: CGFloat { get set }
    var isAnimating: Bool { get }
}

var pullToRefreshSpinnerView: PullToRefreshSpinnerViewProtocol?

Author

ivan.postolaki@gmail.com

License

POSInfiniteScroll is available under the MIT license.

GitHub

link
Stars: 2
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API