Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/TabPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ open class TabPageViewController: UIPageViewController {
open var isInfinity: Bool = false
open var option: TabPageOption = TabPageOption()
open var tabItems: [(viewController: UIViewController, title: String)] = []

open var indexSelected: ((Int) -> Void)?

var currentIndex: Int? {
guard let viewController = viewControllers?.first else {
return nil
Expand Down Expand Up @@ -179,6 +180,7 @@ extension TabPageViewController {
tabView.updateCurrentIndex(beforeIndex, shouldScroll: true)

tabView.pageItemPressedBlock = { [weak self] (index: Int, direction: UIPageViewControllerNavigationDirection) in
self?.indexSelected?(index)
self?.displayControllerWithIndex(index, direction: direction, animated: true)
}

Expand Down Expand Up @@ -296,7 +298,7 @@ extension TabPageViewController: UIPageViewControllerDataSource {
guard var index = tabItems.map({$0.viewController}).index(of: viewController) else {
return nil
}

self.indexSelected?(index)
if isAfter {
index += 1
} else {
Expand Down