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

updated to Swift 4.2 and added swift version to podspec #617

Merged
merged 2 commits into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions Sources/ButtonBarPagerTabStripViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
}
cell.isAccessibilityElement = true
cell.accessibilityLabel = cell.label.text
cell.accessibilityTraits |= UIAccessibilityTraitButton
cell.accessibilityTraits |= UIAccessibilityTraitHeader
cell.accessibilityTraits = [.button, .header]
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mats-claassen thanks, it done

return cell
}

Expand Down
7 changes: 3 additions & 4 deletions Sources/ButtonBarViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ open class ButtonBarViewCell: UICollectionViewCell {
super.init(coder: aDecoder)

isAccessibilityElement = true
accessibilityTraits |= UIAccessibilityTraitButton
accessibilityTraits |= UIAccessibilityTraitHeader
accessibilityTraits = [.button, .header]
Copy link
Member

Choose a reason for hiding this comment

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

I think you should use the insert or formUnion function here. The previous logic was adding the two traits to whatever was already in accessibilityTraits.

}

open override var isSelected: Bool {
Expand All @@ -44,9 +43,9 @@ open class ButtonBarViewCell: UICollectionViewCell {
set {
super.isSelected = newValue
if (newValue) {
accessibilityTraits |= UIAccessibilityTraitSelected
accessibilityTraits = [.selected]
Copy link
Member

Choose a reason for hiding this comment

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

Again. use accessibilityTraits.insert(.selected)

} else {
accessibilityTraits &= ~UIAccessibilityTraitSelected
accessibilityTraits.formUnion(.selected)
Copy link
Member

Choose a reason for hiding this comment

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

And here you should remove selected and not add it: accessibilityTraits.remove(.selected)

}
}
}
Expand Down
26 changes: 13 additions & 13 deletions Sources/PagerTabStripViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
reloadViewControllers()

let childController = viewControllers[currentIndex]
addChildViewController(childController)
addChild(childController)
childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
containerView.addSubview(childController.view)
childController.didMove(toParentViewController: self)
childController.didMove(toParent: self)
}

open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
isViewAppearing = true
childViewControllers.forEach { $0.beginAppearanceTransition(true, animated: animated) }
children.forEach { $0.beginAppearanceTransition(true, animated: animated) }
}

override open func viewDidAppear(_ animated: Bool) {
Expand All @@ -126,17 +126,17 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
moveToViewController(at: preCurrentIndex)
}
isViewAppearing = false
childViewControllers.forEach { $0.endAppearanceTransition() }
children.forEach { $0.endAppearanceTransition() }
}

open override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
childViewControllers.forEach { $0.beginAppearanceTransition(false, animated: animated) }
children.forEach { $0.beginAppearanceTransition(false, animated: animated) }
}

open override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
childViewControllers.forEach { $0.endAppearanceTransition() }
children.forEach { $0.endAppearanceTransition() }
}

override open func viewDidLayoutSubviews() {
Expand Down Expand Up @@ -240,25 +240,25 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {

for (index, childController) in pagerViewControllers.enumerated() {
let pageOffsetForChild = self.pageOffsetForChild(at: index)
if fabs(containerView.contentOffset.x - pageOffsetForChild) < containerView.bounds.width {
if abs(containerView.contentOffset.x - pageOffsetForChild) < containerView.bounds.width {
if childController.parent != nil {
childController.view.frame = CGRect(x: offsetForChild(at: index), y: 0, width: view.bounds.width, height: containerView.bounds.height)
childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
} else {
childController.beginAppearanceTransition(true, animated: false)
addChildViewController(childController)
addChild(childController)
childController.view.frame = CGRect(x: offsetForChild(at: index), y: 0, width: view.bounds.width, height: containerView.bounds.height)
childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
containerView.addSubview(childController.view)
childController.didMove(toParentViewController: self)
childController.didMove(toParent: self)
childController.endAppearanceTransition()
}
} else {
if childController.parent != nil {
childController.beginAppearanceTransition(false, animated: false)
childController.willMove(toParentViewController: nil)
childController.willMove(toParent: nil)
childController.view.removeFromSuperview()
childController.removeFromParentViewController()
childController.removeFromParent()
childController.endAppearanceTransition()
}
}
Expand All @@ -284,9 +284,9 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
guard isViewLoaded else { return }
for childController in viewControllers where childController.parent != nil {
childController.beginAppearanceTransition(false, animated: false)
childController.willMove(toParentViewController: nil)
childController.willMove(toParent: nil)
childController.view.removeFromSuperview()
childController.removeFromParentViewController()
childController.removeFromParent()
childController.endAppearanceTransition()
}
reloadViewControllers()
Expand Down
1 change: 1 addition & 0 deletions XLPagerTabStrip.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ Pod::Spec.new do |s|
s.ios.source_files = 'Sources/**/*.{h,m,swift}'
s.ios.frameworks = 'UIKit', 'Foundation'
s.resource_bundles = { 'XLPagerTabStrip' => ['Sources/ButtonCell.xib'] }
s.swift_version = "4.2"
end
8 changes: 4 additions & 4 deletions XLPagerTabStrip.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -479,7 +479,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -492,7 +492,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStripTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -504,7 +504,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStripTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down