Skip to content

Commit 0811a95

Browse files
author
Martin Barreto
committed
update some class names
1 parent a088f9f commit 0811a95

26 files changed

+119
-110
lines changed

Example/Example/BarExampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class BarExampleViewController: BarPagerTabStripViewController {
4343

4444
// MARK: - PagerTabStripViewControllerDataSource
4545

46-
override func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
46+
override func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
4747

4848
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: "Table View")
4949
let child_2 = ChildExampleViewController(itemInfo: "View")

Example/Example/ButtonBarExampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ButtonBarExampleViewController: ButtonBarPagerTabStripViewController {
3838

3939
// MARK: - PagerTabStripVIewControllerDataSource
4040

41-
override func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
41+
override func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
4242
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: "Table View")
4343
let child_2 = ChildExampleViewController(itemInfo: "View")
4444
let child_3 = TableChildExampleViewController(style: .Grouped, itemInfo: "Table View 2")

Example/Example/ChildControllers/ChildExampleViewController.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
import Foundation
2626
import XLPagerTabStrip
2727

28-
class ChildExampleViewController: UIViewController, PagerTabStripChildItem {
28+
class ChildExampleViewController: UIViewController, IndicatorInfoProvider {
2929

30-
var itemInfo: ChildItemInfo = "View"
30+
var itemInfo: IndicatorInfo = "View"
3131

32-
init(itemInfo: ChildItemInfo) {
32+
init(itemInfo: IndicatorInfo) {
3333
self.itemInfo = itemInfo
3434
super.init(nibName: nil, bundle: nil)
3535
}
@@ -52,9 +52,9 @@ class ChildExampleViewController: UIViewController, PagerTabStripChildItem {
5252
view.addConstraint(NSLayoutConstraint(item: label, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: -50))
5353
}
5454

55-
// MARK: - PagerTabStripChildItem
55+
// MARK: - IndicatorInfoProvider
5656

57-
func childInfoForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildItemInfo {
57+
func infoForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
5858
return itemInfo
5959
}
6060
}

Example/Example/ChildControllers/TableChildExampleViewController.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
import Foundation
2626
import XLPagerTabStrip
2727

28-
class TableChildExampleViewController: UITableViewController, PagerTabStripChildItem {
28+
class TableChildExampleViewController: UITableViewController, IndicatorInfoProvider {
2929

3030
let cellIdentifier = "postCell"
3131
var blackTheme = false
32-
var itemInfo = ChildItemInfo(title: "View")
32+
var itemInfo = IndicatorInfo(title: "View")
3333

34-
init(style: UITableViewStyle, itemInfo: ChildItemInfo) {
34+
init(style: UITableViewStyle, itemInfo: IndicatorInfo) {
3535
self.itemInfo = itemInfo
3636
super.init(style: style)
3737
}
@@ -77,9 +77,9 @@ class TableChildExampleViewController: UITableViewController, PagerTabStripChild
7777
return cell
7878
}
7979

80-
// MARK: - PagerTabStripChildItem
81-
82-
func childInfoForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildItemInfo {
80+
// MARK: - IndicatorInfoProvider
81+
82+
func infoForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
8383
return itemInfo
8484
}
8585
}

Example/Example/Instagram/InstagramExampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class InstagramExampleViewController: ButtonBarPagerTabStripViewController {
5454

5555
// MARK: - PagerTabStripVIewControllerDataSource
5656

57-
override func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
57+
override func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
5858
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: "FOLLOWING")
5959
let child_2 = ChildExampleViewController(itemInfo: "YOU")
6060
return [child_1, child_2]

Example/Example/NavButtonBarExampleViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class NavButtonBarExampleViewController: ButtonBarPagerTabStripViewController {
5959

6060
// MARK: - PagerTabStripViewControllerDataSource
6161

62-
override func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
62+
override func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
6363
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: "Table View")
6464
let child_2 = ChildExampleViewController(itemInfo: "View")
6565
let child_3 = TableChildExampleViewController(style: .Grouped, itemInfo: "Table View 2")
@@ -97,8 +97,8 @@ class NavButtonBarExampleViewController: ButtonBarPagerTabStripViewController {
9797
super.reloadPagerTabStripView()
9898
}
9999

100-
override func configureCell(cell: ButtonBarViewCell, childInfo: ChildItemInfo) {
101-
super.configureCell(cell, childInfo: childInfo)
100+
override func configureCell(cell: ButtonBarViewCell, indicatorInfo: IndicatorInfo) {
101+
super.configureCell(cell, indicatorInfo: indicatorInfo)
102102
cell.backgroundColor = .clearColor()
103103
}
104104
}

Example/Example/SegmentedExampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class SegmentedExampleViewController: SegmentedPagerTabStripViewController {
3737

3838
// MARK: - PagerTabStripViewControllerDataSource
3939

40-
override func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
40+
override func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
4141
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: "Table View")
4242
let child_2 = ChildExampleViewController(itemInfo: "View")
4343
let child_3 = TableChildExampleViewController(style: .Grouped, itemInfo: "Table View 2")

Example/Example/Spotify/SpotifyExampleViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public class SpotifyExampleViewController: ButtonBarPagerTabStripViewController
5757

5858
// MARK: - PagerTabStripVIewControllerDataSource
5959

60-
public override func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
61-
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: ChildItemInfo(title: "FRIENDS"))
60+
public override func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
61+
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: IndicatorInfo(title: "FRIENDS"))
6262
child_1.blackTheme = true
63-
let child_2 = TableChildExampleViewController(style: .Plain, itemInfo: ChildItemInfo(title: "FEATURED"))
63+
let child_2 = TableChildExampleViewController(style: .Plain, itemInfo: IndicatorInfo(title: "FEATURED"))
6464
child_2.blackTheme = true
6565
return [child_1, child_2]
6666
}

Example/Example/TwitterExampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import XLPagerTabStrip
2828
class TwitterExampleViewController: TwitterPagerTabStripViewController {
2929
var isReload = false
3030

31-
override func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
31+
override func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
3232

3333
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: "TableView")
3434
let child_2 = ChildExampleViewController(itemInfo: "View")

Example/Example/Youtube/YoutubeExampleViewController.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class YoutubeExampleViewController: BaseButtonBarPagerTabStripViewController<You
3838
required init?(coder aDecoder: NSCoder) {
3939
super.init(coder: aDecoder)
4040

41-
buttonBarItemSpec = ButtonBarItemSpec.NibFile(nibName: "YoutubeIconCell", bundle: NSBundle(forClass: YoutubeIconCell.self), width: { (cell: ChildItemInfo) -> CGFloat in
41+
buttonBarItemSpec = ButtonBarItemSpec.NibFile(nibName: "YoutubeIconCell", bundle: NSBundle(forClass: YoutubeIconCell.self), width: { (cell: IndicatorInfo) -> CGFloat in
4242
return 55.0
4343
})
4444
}
@@ -72,26 +72,26 @@ class YoutubeExampleViewController: BaseButtonBarPagerTabStripViewController<You
7272

7373
// MARK: - PagerTabStripVIewControllerDataSource
7474

75-
override func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
76-
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: ChildItemInfo(title: " HOME", image: UIImage(named: "home")))
77-
let child_2 = TableChildExampleViewController(style: .Plain, itemInfo: ChildItemInfo(title: " TRENDING", image: UIImage(named: "trending")))
78-
let child_3 = ChildExampleViewController(itemInfo: ChildItemInfo(title: " ACCOUNT", image: UIImage(named: "profile")))
75+
override func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
76+
let child_1 = TableChildExampleViewController(style: .Plain, itemInfo: IndicatorInfo(title: " HOME", image: UIImage(named: "home")))
77+
let child_2 = TableChildExampleViewController(style: .Plain, itemInfo: IndicatorInfo(title: " TRENDING", image: UIImage(named: "trending")))
78+
let child_3 = ChildExampleViewController(itemInfo: IndicatorInfo(title: " ACCOUNT", image: UIImage(named: "profile")))
7979
return [child_1, child_2, child_3]
8080
}
8181

8282

83-
override func configureCell(cell: YoutubeIconCell, childInfo: ChildItemInfo) {
84-
cell.iconImage.image = childInfo.image?.imageWithRenderingMode(.AlwaysTemplate)
83+
override func configureCell(cell: YoutubeIconCell, indicatorInfo: IndicatorInfo) {
84+
cell.iconImage.image = indicatorInfo.image?.imageWithRenderingMode(.AlwaysTemplate)
8585
}
8686

8787

8888
override func pagerTabStripViewController(pagerTabStripViewController: PagerTabStripViewController, updateIndicatorFromIndex fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) throws {
8989
try super.pagerTabStripViewController(pagerTabStripViewController, updateIndicatorFromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: progressPercentage, indexWasChanged: indexWasChanged)
9090
if indexWasChanged && toIndex > -1 && toIndex < viewControllers.count {
91-
let child = viewControllers[toIndex] as! PagerTabStripChildItem
91+
let child = viewControllers[toIndex] as! IndicatorInfoProvider
9292
UIView.performWithoutAnimation({ [weak self] () -> Void in
9393
guard let me = self else { return }
94-
me.navigationItem.leftBarButtonItem?.title = child.childInfoForPagerTabStripViewController(me).title
94+
me.navigationItem.leftBarButtonItem?.title = child.infoForPagerTabStripViewController(me).title
9595
})
9696
}
9797
}

Example/PagerSlidingTabStrip.gif

-991 KB
Binary file not shown.

Example/bar.gif

82.9 KB
Loading

Example/barButton.gif

133 KB
Loading

Example/navBarButton.gif

110 KB
Loading

Example/segmented.gif

147 KB
Loading

Example/twitter.gif

81.7 KB
Loading

README.md

+38-14
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,44 @@ Android [PagerTabStrip](http://developer.android.com/reference/android/support/v
2424
</tr>
2525
</table>
2626

27-
The library provides many ways to show the PagerTabStrip menu.
27+
## Pager Types
28+
29+
The library provides 4 different ways to show the view controllers.
30+
31+
### Button Bar
32+
33+
This is likely to be the most common pager type. It's used by many well known apps such as instagram, youtube, skype and many others.
34+
35+
<img src="Example/barButton.gif" width="250"/>
36+
37+
### Bar
38+
39+
This mode doesn't show a title neither a image. It only shows a bar that indicates the current view controller.
40+
41+
<img src="Example/bar.gif" width="250"/>
42+
43+
### Twitter
44+
45+
Long time ago twitter app made use of this type of pager in the app main screen.
46+
47+
<img src="Example/twitter.gif" width="250"/>
48+
49+
### Segmented
50+
51+
This mode uses a `UIsegmentedControl` to indicates which is the view controller being displayed.
52+
53+
<img src="Example/segmented.gif" width="250"/>
2854

2955
## Usage
3056

3157

32-
Basically we just need to provide the list of child view controllers to show and these view controllers should provide the information (title or image) to show in the associated indicator.
58+
Basically we just need to provide the list of child view controllers to show and these view controllers should provide the information (title or image) that will be shown in the associated indicator.
3359

3460
Let's see the steps to do this:
3561

3662
##### Choose which type of pager we want to create
3763

38-
Fist step is choose how we want to show our pager step controller, it must extend from any of the following controllers: `TwitterPagerTabStripViewController`, `ButtonBarPagerTabStripViewController`, `SegmentedPagerTabStripViewController`, `BarPagerTabStripViewController`.
64+
Fist we should choose the type of pager we want to create, depending on our choice we will have to create a view controller that extend from one of the following controllers: `TwitterPagerTabStripViewController`, `ButtonBarPagerTabStripViewController`, `SegmentedPagerTabStripViewController`, `BarPagerTabStripViewController`.
3965

4066
> All these build-in pager controllers extend from the base class `PagerTabStripViewController`.
4167
> You can also make your custom pager controller by extending directly from `PagerTabStripViewController` in case no pager menu type fits your needs.
@@ -50,36 +76,34 @@ class MyPagerTabStripName: ButtonBarPagerTabStripViewController {
5076

5177
##### Connect outlets and add layout constraints
5278

53-
We strongly recommend to use IB to set up your page controller views.
79+
We strongly recommend to use IB to set up our page controller views.
5480

5581
Drag into the storyboard a `UIViewController` and set up its class with your pager controller (`MyPagerTabStripName`).
5682
Drag a `UIScrollView` into your view controller view and connect `PagerTabStripViewController` `contentView` outlet with the scroll view.
5783

5884
Depending on which type of paging view controller you are working with you may have to connect more outlets.
5985

60-
For `BarPagerTabStripViewController` you should connect `barView` outlet.
61-
For `ButtonBarPagerTabStripViewController` you should connect `buttonBarView` outlet.
62-
For `SegmentedPagerTabStripViewController` you should connect `segmentedControl` outlet.
63-
`TwitterPagerTabStripViewController` doesn't require to connect any additional outlet.
86+
For `BarPagerTabStripViewController` we should connect `barView` outlet. `ButtonBarPagerTabStripViewController` requires us to connect `buttonBarView` outlet. `SegmentedPagerTabStripViewController` has a `segmentedControl` outlet, if the outlet is not connected the library try to set up the navigationItem titleView using a `UIsegmentedControl`. `TwitterPagerTabStripViewController` doesn't require to connect any additional outlet.
6487

65-
> The example project contains a example for each pager controller type and you can look into it to see how views were added and how outlets were connected.
88+
> The example project contains a example for each pager controller type and we can look into it to see how views were added and how outlets were connected.
6689
67-
##### Provide view controllers that will appear embedded into the PagerTabStrip view controller
90+
##### Provide the view controllers that will appear embedded into the PagerTabStrip view controller
6891

69-
You can provide the view controllers by overriding `func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController]` method.
92+
You can provide the view controllers by overriding `func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController]` method.
7093

7194
```swift
72-
override public func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
95+
override public func viewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
7396
return [MyEmbeddedViewController(), MySecondEmbeddedViewController()]
7497
}
7598
```
7699

77-
> The method above is the only method contained in `PagerTabStripViewControllerDataSource`. We don't need to explicitly conform to it since base pager class already does it.
100+
> The method above is the only method declared in `PagerTabStripViewControllerDataSource` protocol. We don't need to explicitly conform to it since base pager class already does it.
78101
79102

80103
##### Provide information to show in each indicator
81104

82-
Every UIViewController that will appear in the PagerTabStrip controller should conforms to `PagerTabStripChildItem`. The only method this protocol requires to implement is `func childHeaderForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildItemInfo`
105+
Every UIViewController that will appear within the PagerTabStrip controller needs to provide either a title or an image.
106+
In order to do so they should conform to `PagerTabStripChildItem` by implementing `func childHeaderForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildItemInfo`
83107
which provides the information required to show the PagerTabStrip menu (indicator) associated with the view controller.
84108

85109
```swift

0 commit comments

Comments
 (0)