Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve API contract #774

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/PagerTabStripViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ public protocol PagerTabStripIsProgressiveDelegate: PagerTabStripDelegate {
func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool)
}

public typealias ViewControllerIndicatorInfoProvider = UIViewController & IndicatorInfoProvider

public protocol PagerTabStripDataSource: class {

func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController]
func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [ViewControllerIndicatorInfoProvider]
}

// MARK: PagerTabStripViewController
Expand Down Expand Up @@ -177,7 +179,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {

// MARK: - PagerTabStripDataSource

open func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
open func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [ViewControllerIndicatorInfoProvider] {
assertionFailure("Sub-class must implement the PagerTabStripDataSource viewControllers(for:) method")
return []
}
Expand Down Expand Up @@ -381,8 +383,6 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
guard !viewControllers.isEmpty else {
fatalError("viewControllers(for:) should provide at least one child view controller")
}
viewControllers.forEach { if !($0 is IndicatorInfoProvider) { fatalError("Every view controller provided by PagerTabStripDataSource's viewControllers(for:) method must conform to IndicatorInfoProvider") }}

}

private var pagerTabStripChildViewControllersForScrolling: [UIViewController]?
Expand Down