Skip to content

Pager library is the easiest way of setting up a Pager.

Notifications You must be signed in to change notification settings

WildStudio/Pager

Repository files navigation

___

Pager library is the easiest way of setting up a Pager. It comes with some convenience methods like, disabling swipe, and navigating backwards and forwards. Pager handles the menu navigation to navigate to a specific page.

Requirements

  • iOS 10.0+
  • Xcode 9

Installation

Just add the Source folder to your project.

or use CocoaPods with Podfile:

pod 'Pager'

Usage

  1. Create a your Model object inheriting from: Ìtem like this:
class Model: Item {
    let image: String

    init(title: String, description: String, imageName: String) {
        self.image = imageName
        super.init(title: title, description: description)
    }
}

  1. Create your detail view controller and conform to ItemPresentable like this:
extension PageDetailViewController: ItemPresentable {
    func configuredWith(item: Item) -> UIViewController {
        guard let model = item as? Model else {
            descriptionText = item.description
            return self
        }
        
        titleText = model.title
        descriptionText = model.description
        imageName = model.image
        
        return self
    }
}
  1. Create PagerContainerViewController and configure:

let controller = Pager.PageContainerViewController.instantiate()
present(controller, animated: true)

let controllers = dataSource.map { _ in PageDetailViewController.instantiate() ?? PageDetailViewController() }
controller.configure(with: dataSource, controllers: controllers)

License

Pager is released under the MIT license.

If you use the open-source library in your project, please make sure to credit.

About

Pager library is the easiest way of setting up a Pager.

Resources

Stars

Watchers

Forks

Packages

No packages published