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

Convert XLPagerTabStrip to Swift 3 #226

Merged
merged 3 commits into from
Sep 16, 2016
Merged

Convert XLPagerTabStrip to Swift 3 #226

merged 3 commits into from
Sep 16, 2016

Conversation

mats-claassen
Copy link
Member

No description provided.

buttonBarView.backgroundColor = UIColor(red: 7/255, green: 185/255, blue: 155/255, alpha: 1)
}

// MARK: - PagerTabStripDataSource

override func viewControllersForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
Copy link
Member

@mtnbarreto mtnbarreto Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about changing this signature to viewControllers(forPagerTabStrip: PagerTabStripViewController) ?

}

// MARK: - IndicatorInfoProvider

func indicatorInfoForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indicatorInfo(forPagerTabStrip: PagerTabStripViewController) -> IndicatorInfo is more close to swift 3 syntax.

@@ -79,7 +79,7 @@ class TableChildExampleViewController: UITableViewController, IndicatorInfoProvi

// MARK: - IndicatorInfoProvider

func indicatorInfoForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use for: instead..

indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInf

override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
override var preferredStatusBarStyle : UIStatusBarStyle {
return UIStatusBarStyle.lightContent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please delete UIStatusBarStyle

override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
override var preferredStatusBarStyle : UIStatusBarStyle {
return UIStatusBarStyle.lightContent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too.


buttonBarView.selectedBarHeight = settings.style.selectedBarHeight ?? buttonBarView.selectedBarHeight
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

buttonBarView.reloadData()
cachedCellWidths = calculateWidths()
buttonBarView.moveToIndex(currentIndex, animated: false, swipeDirection: .None, pagerScroll: .Yes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.moveTo(index: currentIndex, withAnimation: false, swipeDirection: .None, pagerScroll: .Yes)

fatalError("UICollectionViewCell should be or extend from ButtonBarViewCell")
}
let childController = viewControllers[indexPath.item] as! IndicatorInfoProvider
let childController = viewControllers[(indexPath as NSIndexPath).item] as! IndicatorInfoProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not need the casting... indexPath as NSIndexPath

let indicatorInfo = childController.indicatorInfoForPagerTabStrip(self)

configureCell(cell, indicatorInfo: indicatorInfo)

if pagerBehaviour.isProgressiveIndicator {
if let changeCurrentIndexProgressive = changeCurrentIndexProgressive {
changeCurrentIndexProgressive(oldCell: currentIndex == indexPath.item ? nil : cell, newCell: currentIndex == indexPath.item ? cell : nil, progressPercentage: 1, changeCurrentIndex: true, animated: false)
changeCurrentIndexProgressive(currentIndex == (indexPath as NSIndexPath).item ? nil : cell, currentIndex == (indexPath as NSIndexPath).item ? cell : nil, 1, true, false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer to keep the named parameters in closure variables. Let's check if this is possible

var newContainerViewFrame = self.containerView.frame
newContainerViewFrame.origin.y = buttonBarHeight
newContainerViewFrame.size.height = self.containerView.frame.size.height - (buttonBarHeight - self.containerView.frame.origin.y)
self.containerView.frame = newContainerViewFrame
return buttonBar
}()

lazy private var cachedCellWidths: [CGFloat]? = { [unowned self] in
lazy fileprivate var cachedCellWidths: [CGFloat]? = { [unowned self] in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may have to use private sometimes. private means it can be used from the current context.

@@ -63,39 +63,39 @@ public class ButtonBarView: UICollectionView {
addSubview(selectedBar)
}

public func moveToIndex(toIndex: Int, animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) {
open func moveToIndex(_ toIndex: Int, animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor signacture

selectedIndex = toIndex
updateSelectedBarPosition(animated, swipeDirection: swipeDirection, pagerScroll: pagerScroll)
}

public func moveFromIndex(fromIndex: Int, toIndex: Int, progressPercentage: CGFloat,pagerScroll: PagerScroll) {
open func moveFromIndex(_ fromIndex: Int, toIndex: Int, progressPercentage: CGFloat,pagerScroll: PagerScroll) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

@@ -133,24 +133,24 @@ public class ButtonBarView: UICollectionView {

// MARK: - Helpers

private func updateContentOffset(animated: Bool, pagerScroll: PagerScroll, toFrame: CGRect, toIndex: Int) -> Void {
guard pagerScroll != .No || (pagerScroll != .ScrollOnlyIfOutOfScreen && (toFrame.origin.x < contentOffset.x || toFrame.origin.x >= (contentOffset.x + frame.size.width - contentInset.left))) else { return }
fileprivate func updateContentOffset(_ animated: Bool, pagerScroll: PagerScroll, toFrame: CGRect, toIndex: Int) -> Void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withAnimation:

label.font = UIFont.boldSystemFontOfSize(14.0)
label.autoresizingMask = [.flexibleWidth, .flexibleHeight]
label.textAlignment = .center
label.font = UIFont.boldSystemFont(ofSize: 14.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove UIFont please

@@ -30,66 +30,66 @@ import Foundation

public protocol IndicatorInfoProvider {

func indicatorInfoForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo
func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indicatorInfo(for pagerTabStripController: ......

@@ -30,66 +30,66 @@ import Foundation

public protocol IndicatorInfoProvider {

func indicatorInfoForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo
func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo
}

public protocol PagerTabStripDelegate: class {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this protocol method signatures should be updated!

super.viewDidLayoutSubviews()
updateIfNeeded()
}

public func moveToViewControllerAtIndex(index: Int, animated: Bool = true) {
guard isViewLoaded() && view.window != nil else {
open func moveToViewControllerAtIndex(_ index: Int, animated: Bool = true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor

@mats-claassen mats-claassen merged commit 794f085 into master Sep 16, 2016
@mtnbarreto mtnbarreto deleted the Swift3 branch September 27, 2016 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants