Merge branch 'master' into feature/indicator-custom-info
This commit is contained in:
commit
a98448beb2
|
|
@ -0,0 +1,51 @@
|
|||
disabled_rules: # rule identifiers to exclude from running
|
||||
# - colon
|
||||
# - comma
|
||||
# - control_statement
|
||||
- line_length
|
||||
- function_body_length
|
||||
- identifier_name
|
||||
- type_name
|
||||
- large_tuple
|
||||
opt_in_rules: # some rules are only opt-in
|
||||
- empty_count
|
||||
# Find all the available rules by running:
|
||||
# swiftlint rules
|
||||
excluded: # paths to ignore during linting. Takes precedence over `included`.
|
||||
- Carthage
|
||||
- Pods
|
||||
- Source/ExcludedFolder
|
||||
- Source/ExcludedFile.swift
|
||||
|
||||
# configurable rules can be customized from this configuration file
|
||||
# binary rules can set their severity level
|
||||
force_cast: warning # implicitly
|
||||
force_try:
|
||||
severity: warning # explicitly
|
||||
# rules that have both warning and error levels, can set just the warning level
|
||||
# implicitly
|
||||
line_length: 200
|
||||
# they can set both implicitly with an array
|
||||
type_body_length:
|
||||
- 300 # warning
|
||||
- 400 # error
|
||||
# or they can set both explicitly
|
||||
file_length:
|
||||
warning: 500
|
||||
error: 1200
|
||||
# naming rules can set warnings/errors for min_length and max_length
|
||||
# additionally they can set excluded names
|
||||
type_name:
|
||||
min_length: 4 # only warning
|
||||
max_length: # warning and error
|
||||
warning: 40
|
||||
error: 50
|
||||
excluded: iPhone # excluded via string
|
||||
identifier_name:
|
||||
min_length: # only min_length
|
||||
error: 4 # only error
|
||||
excluded: # excluded via string array
|
||||
- id
|
||||
- URL
|
||||
- GlobalAPIKey
|
||||
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
language: objective-c
|
||||
osx_image: xcode8
|
||||
osx_image: xcode9
|
||||
env:
|
||||
- DESTINATION="OS=10.0,name=iPhone 6s" SCHEME="XLPagerTabStrip" SDK=iphonesimulator10.0
|
||||
- DESTINATION="OS=11.0,name=iPhone 7" SCHEME="XLPagerTabStrip" SDK=iphonesimulator
|
||||
before_install:
|
||||
- brew update
|
||||
#- brew outdated carthage || brew upgrade carthage
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
# Change Log
|
||||
All notable changes to XLPagerTabStrip will be documented in this file.
|
||||
|
||||
### [8.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/8.0.0)
|
||||
|
||||
* Xcode 9 support. (Swift 4)
|
||||
* Bug fixes and stability improvements.
|
||||
|
||||
### [7.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/7.0.0)
|
||||
|
||||
* Bug fixes and stability improvements.
|
||||
|
||||
### [6.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/5.0.0)
|
||||
### [6.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/6.0.0)
|
||||
|
||||
* Swift 3 support
|
||||
* **Breaking change**: Swiftified names of functions (you can see more details about it [here](https://github.com/xmartlabs/XLPagerTabStrip/Migration.md))
|
||||
|
|
|
|||
|
|
@ -295,15 +295,15 @@
|
|||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0720;
|
||||
LastUpgradeCheck = 0800;
|
||||
LastUpgradeCheck = 0900;
|
||||
TargetAttributes = {
|
||||
28F828CB1C4B714D00330CF4 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
LastSwiftMigration = 0800;
|
||||
LastSwiftMigration = 0900;
|
||||
};
|
||||
28F828DF1C4B714D00330CF4 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
LastSwiftMigration = 0800;
|
||||
LastSwiftMigration = 0900;
|
||||
TestTargetID = 28F828CB1C4B714D00330CF4;
|
||||
};
|
||||
};
|
||||
|
|
@ -438,14 +438,20 @@
|
|||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
|
|
@ -484,14 +490,20 @@
|
|||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
|
|
@ -528,7 +540,8 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
|
@ -543,7 +556,8 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
@ -556,7 +570,8 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.ExampleUITests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TEST_TARGET_NAME = Example;
|
||||
USES_XCTRUNNER = YES;
|
||||
};
|
||||
|
|
@ -570,7 +585,8 @@
|
|||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.ExampleUITests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TEST_TARGET_NAME = Example;
|
||||
USES_XCTRUNNER = YES;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,14 +12,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
|
||||
UITabBar.appearance().tintColor = UIColor.init(red: 0.027, green: 0.725, blue: 0.608, alpha: 1)
|
||||
UIApplication.shared.statusBarStyle = .lightContent
|
||||
|
||||
let _ = YoutubeExampleViewController(nibName: nil, bundle: nil)
|
||||
_ = YoutubeExampleViewController(nibName: nil, bundle: nil)
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
@ -46,6 +45,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ class BarExampleViewController: BarPagerTabStripViewController {
|
|||
}
|
||||
|
||||
var childViewControllers = [child_1, child_2, child_3, child_4]
|
||||
for (index, _) in childViewControllers.enumerated(){
|
||||
for index in childViewControllers.indices {
|
||||
let nElements = childViewControllers.count - index
|
||||
let n = (Int(arc4random()) % nElements) + index
|
||||
if n != index{
|
||||
swap(&childViewControllers[index], &childViewControllers[n])
|
||||
if n != index {
|
||||
childViewControllers.swapAt(index, n)
|
||||
}
|
||||
}
|
||||
let nItems = 1 + (arc4random() % 4)
|
||||
|
|
@ -70,8 +70,7 @@ class BarExampleViewController: BarPagerTabStripViewController {
|
|||
isReload = true
|
||||
if arc4random() % 2 == 0 {
|
||||
pagerBehaviour = .progressive(skipIntermediateViewControllers: arc4random() % 2 == 0, elasticIndicatorLimit: arc4random() % 2 == 0 )
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pagerBehaviour = .common(skipIntermediateViewControllers: arc4random() % 2 == 0)
|
||||
}
|
||||
super.reloadPagerTabStripView()
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ class ButtonBarExampleViewController: ButtonBarPagerTabStripViewController {
|
|||
return [child_1, child_2, child_3, child_4, child_5, child_6, child_7, child_8]
|
||||
}
|
||||
|
||||
var childViewControllers = [child_1, child_2, child_3, child_4, child_6, child_7, child_8]
|
||||
var childViewControllers = [child_1, child_2, child_3, child_4, child_5, child_6, child_7, child_8]
|
||||
|
||||
for (index, _) in childViewControllers.enumerated(){
|
||||
for index in childViewControllers.indices {
|
||||
let nElements = childViewControllers.count - index
|
||||
let n = (Int(arc4random()) % nElements) + index
|
||||
if n != index{
|
||||
swap(&childViewControllers[index], &childViewControllers[n])
|
||||
if n != index {
|
||||
childViewControllers.swapAt(index, n)
|
||||
}
|
||||
}
|
||||
let nItems = 1 + (arc4random() % 8)
|
||||
|
|
@ -69,8 +69,7 @@ class ButtonBarExampleViewController: ButtonBarPagerTabStripViewController {
|
|||
isReload = true
|
||||
if arc4random() % 2 == 0 {
|
||||
pagerBehaviour = .progressive(skipIntermediateViewControllers: arc4random() % 2 == 0, elasticIndicatorLimit: arc4random() % 2 == 0 )
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pagerBehaviour = .common(skipIntermediateViewControllers: arc4random() % 2 == 0)
|
||||
}
|
||||
super.reloadPagerTabStripView()
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class TableChildExampleViewController: UITableViewController, IndicatorInfoProvi
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
tableView.register(UINib(nibName: "PostCell", bundle: Bundle.main), forCellReuseIdentifier: cellIdentifier)
|
||||
tableView.estimatedRowHeight = 60.0;
|
||||
tableView.estimatedRowHeight = 60.0
|
||||
tableView.rowHeight = UITableViewAutomaticDimension
|
||||
tableView.allowsSelection = false
|
||||
if blackTheme {
|
||||
|
|
@ -67,9 +67,9 @@ class TableChildExampleViewController: UITableViewController, IndicatorInfoProvi
|
|||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! PostCell
|
||||
let data = DataProvider.sharedInstance.postsData.object(at: indexPath.row) as!
|
||||
NSDictionary
|
||||
guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? PostCell,
|
||||
let data = DataProvider.sharedInstance.postsData.object(at: indexPath.row) as? NSDictionary else { return PostCell() }
|
||||
|
||||
cell.configureWithData(data)
|
||||
if blackTheme {
|
||||
cell.changeStylToBlack()
|
||||
|
|
@ -82,4 +82,5 @@ class TableChildExampleViewController: UITableViewController, IndicatorInfoProvi
|
|||
func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
|
||||
return itemInfo
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -26,7 +26,6 @@ import UIKit
|
|||
|
||||
class PostCell: UITableViewCell {
|
||||
|
||||
|
||||
@IBOutlet weak var userImage: UIImageView!
|
||||
@IBOutlet weak var postName: UILabel!
|
||||
@IBOutlet weak var postText: UILabel!
|
||||
|
|
@ -36,8 +35,7 @@ class PostCell: UITableViewCell {
|
|||
userImage.layer.cornerRadius = 10.0
|
||||
}
|
||||
|
||||
|
||||
func configureWithData(_ data: NSDictionary){
|
||||
func configureWithData(_ data: NSDictionary) {
|
||||
if let post = data["post"] as? NSDictionary, let user = post["user"] as? NSDictionary {
|
||||
postName.text = user["name"] as? String
|
||||
postText.text = post["text"] as? String
|
||||
|
|
@ -45,8 +43,7 @@ class PostCell: UITableViewCell {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func changeStylToBlack(){
|
||||
func changeStylToBlack() {
|
||||
userImage?.layer.cornerRadius = 30.0
|
||||
postText.text = nil
|
||||
postName.font = UIFont(name: "HelveticaNeue-Light", size:18) ?? .systemFont(ofSize: 18)
|
||||
|
|
|
|||
|
|
@ -65,8 +65,3 @@ class InstagramExampleViewController: ButtonBarPagerTabStripViewController {
|
|||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ class NavButtonBarExampleViewController: ButtonBarPagerTabStripViewController {
|
|||
newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
|
||||
oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
|
||||
})
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
|
||||
oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
|
||||
}
|
||||
|
|
@ -73,13 +72,13 @@ class NavButtonBarExampleViewController: ButtonBarPagerTabStripViewController {
|
|||
return [child_1, child_2, child_3, child_4, child_5, child_6, child_7, child_8]
|
||||
}
|
||||
|
||||
var childViewControllers = [child_1, child_2, child_3, child_4, child_6, child_7, child_8]
|
||||
var childViewControllers = [child_1, child_2, child_3, child_4, child_5, child_6, child_7, child_8]
|
||||
|
||||
for (index, _) in childViewControllers.enumerated(){
|
||||
for index in childViewControllers.indices {
|
||||
let nElements = childViewControllers.count - index
|
||||
let n = (Int(arc4random()) % nElements) + index
|
||||
if n != index{
|
||||
swap(&childViewControllers[index], &childViewControllers[n])
|
||||
if n != index {
|
||||
childViewControllers.swapAt(index, n)
|
||||
}
|
||||
}
|
||||
let nItems = 1 + (arc4random() % 8)
|
||||
|
|
@ -90,8 +89,7 @@ class NavButtonBarExampleViewController: ButtonBarPagerTabStripViewController {
|
|||
isReload = true
|
||||
if arc4random() % 2 == 0 {
|
||||
pagerBehaviour = .progressive(skipIntermediateViewControllers: arc4random() % 2 == 0, elasticIndicatorLimit: arc4random() % 2 == 0 )
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pagerBehaviour = .common(skipIntermediateViewControllers: arc4random() % 2 == 0)
|
||||
}
|
||||
super.reloadPagerTabStripView()
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ class ReloadExampleViewController: UIViewController {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
if let _ = navigationController {
|
||||
if navigationController != nil {
|
||||
navigationItem.titleView = bigLabel
|
||||
bigLabel.sizeToFit()
|
||||
}
|
||||
|
||||
if let pagerViewController = childViewControllers.filter( { $0 is PagerTabStripViewController } ).first as? PagerTabStripViewController {
|
||||
if let pagerViewController = childViewControllers.first as? PagerTabStripViewController {
|
||||
updateTitle(of: pagerViewController)
|
||||
}
|
||||
}
|
||||
|
|
@ -61,11 +61,10 @@ class ReloadExampleViewController: UIViewController {
|
|||
}
|
||||
child.reloadPagerTabStripView()
|
||||
updateTitle(of: child)
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@IBAction func closeTapped(_ sender: UIButton) {
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
|
@ -81,7 +80,7 @@ class ReloadExampleViewController: UIViewController {
|
|||
navigationItem.titleView?.sizeToFit()
|
||||
}
|
||||
|
||||
override var preferredStatusBarStyle : UIStatusBarStyle {
|
||||
override var preferredStatusBarStyle: UIStatusBarStyle {
|
||||
return .lightContent
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ class SegmentedExampleViewController: SegmentedPagerTabStripViewController {
|
|||
var childViewControllers = [child_1, child_2, child_3, child_4]
|
||||
let count = childViewControllers.count
|
||||
|
||||
for (index, _) in childViewControllers.enumerated(){
|
||||
for index in childViewControllers.indices {
|
||||
let nElements = count - index
|
||||
let n = (Int(arc4random()) % nElements) + index
|
||||
if n != index{
|
||||
swap(&childViewControllers[index], &childViewControllers[n])
|
||||
if n != index {
|
||||
childViewControllers.swapAt(index, n)
|
||||
}
|
||||
}
|
||||
let nItems = 1 + (arc4random() % 4)
|
||||
|
|
|
|||
|
|
@ -70,8 +70,3 @@ class SpotifyExampleViewController: ButtonBarPagerTabStripViewController {
|
|||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ class TwitterExampleViewController: TwitterPagerTabStripViewController {
|
|||
return [child_1, child_2, child_3, child_4, child_5, child_6, child_7, child_8]
|
||||
}
|
||||
|
||||
var childViewControllers = [child_1, child_2, child_3, child_4, child_6, child_7, child_8]
|
||||
var childViewControllers = [child_1, child_2, child_3, child_4, child_5, child_6, child_7, child_8]
|
||||
|
||||
for (index, _) in childViewControllers.enumerated(){
|
||||
for index in childViewControllers.indices {
|
||||
let nElements = childViewControllers.count - index
|
||||
let n = (Int(arc4random()) % nElements) + index
|
||||
if n != index{
|
||||
swap(&childViewControllers[index], &childViewControllers[n])
|
||||
if n != index {
|
||||
childViewControllers.swapAt(index, n)
|
||||
}
|
||||
}
|
||||
let nItems = 1 + (arc4random() % 8)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class YoutubeExampleViewController: BaseButtonBarPagerTabStripViewController<You
|
|||
let redColor = UIColor(red: 221/255.0, green: 0/255.0, blue: 19/255.0, alpha: 1.0)
|
||||
let unselectedIconColor = UIColor(red: 73/255.0, green: 8/255.0, blue: 10/255.0, alpha: 1.0)
|
||||
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
}
|
||||
|
|
@ -38,7 +37,7 @@ class YoutubeExampleViewController: BaseButtonBarPagerTabStripViewController<You
|
|||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
|
||||
buttonBarItemSpec = ButtonBarItemSpec.nibFile(nibName: "YoutubeIconCell", bundle: Bundle(for: YoutubeIconCell.self), width: { (cell: IndicatorInfo) -> CGFloat in
|
||||
buttonBarItemSpec = ButtonBarItemSpec.nibFile(nibName: "YoutubeIconCell", bundle: Bundle(for: YoutubeIconCell.self), width: { _ in
|
||||
return 55.0
|
||||
})
|
||||
}
|
||||
|
|
@ -55,13 +54,10 @@ class YoutubeExampleViewController: BaseButtonBarPagerTabStripViewController<You
|
|||
settings.style.buttonBarLeftContentInset = 0
|
||||
settings.style.buttonBarRightContentInset = 0
|
||||
|
||||
|
||||
|
||||
changeCurrentIndexProgressive = { [weak self] (oldCell: YoutubeIconCell?, newCell: YoutubeIconCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
|
||||
guard changeCurrentIndex == true else { return }
|
||||
oldCell?.iconImage.tintColor = self?.unselectedIconColor
|
||||
newCell?.iconImage.tintColor = .white
|
||||
|
||||
}
|
||||
super.viewDidLoad()
|
||||
navigationController?.navigationBar.shadowImage = UIImage()
|
||||
|
|
@ -77,7 +73,6 @@ class YoutubeExampleViewController: BaseButtonBarPagerTabStripViewController<You
|
|||
return [child_1, child_2, child_3]
|
||||
}
|
||||
|
||||
|
||||
override func configure(cell: YoutubeIconCell, for indicatorInfo: IndicatorInfo) {
|
||||
cell.iconImage.image = indicatorInfo.image?.withRenderingMode(.alwaysTemplate)
|
||||
}
|
||||
|
|
@ -85,7 +80,7 @@ class YoutubeExampleViewController: BaseButtonBarPagerTabStripViewController<You
|
|||
override func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) {
|
||||
super.updateIndicator(for: viewController, fromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: progressPercentage, indexWasChanged: indexWasChanged)
|
||||
if indexWasChanged && toIndex > -1 && toIndex < viewControllers.count {
|
||||
let child = viewControllers[toIndex] as! IndicatorInfoProvider
|
||||
let child = viewControllers[toIndex] as! IndicatorInfoProvider // swiftlint:disable:this force_cast
|
||||
UIView.performWithoutAnimation({ [weak self] () -> Void in
|
||||
guard let me = self else { return }
|
||||
me.navigationItem.leftBarButtonItem?.title = child.indicatorInfo(for: me).title
|
||||
|
|
@ -99,8 +94,3 @@ class YoutubeExampleViewController: BaseButtonBarPagerTabStripViewController<You
|
|||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
|
||||
|
||||
class YoutubeIconCell : UICollectionViewCell {
|
||||
class YoutubeIconCell: UICollectionViewCell {
|
||||
|
||||
@IBOutlet weak var iconImage: UIImageView!
|
||||
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@
|
|||
import UIKit
|
||||
import XLPagerTabStrip
|
||||
|
||||
var str = "Hello, playground"
|
||||
var helloWorld = "Hello, playground"
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
<p align="left">
|
||||
<a href="https://travis-ci.org/xmartlabs/XLPagerTabStrip"><img src="https://travis-ci.org/xmartlabs/XLPagerTabStrip.svg?branch=master" alt="Build status" /></a>
|
||||
<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" />
|
||||
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/swift3-compatible-4BC51D.svg?style=flat" alt="Swift 3 compatible" /></a>
|
||||
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/swift4-compatible-4BC51D.svg?style=flat" alt="Swift 3 compatible" /></a>
|
||||
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible" /></a>
|
||||
<a href="https://cocoapods.org/pods/XLActionController"><img src="https://img.shields.io/badge/pod-7.0.0-blue.svg" alt="CocoaPods compatible" /></a>
|
||||
<a href="https://cocoapods.org/pods/XLPagerTabStrip"><img src="https://img.shields.io/cocoapods/v/XLPagerTabStrip.svg" alt="CocoaPods compatible" /></a>
|
||||
<a href="https://raw.githubusercontent.com/xmartlabs/XLPagerTabStrip/master/LICENSE"><img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License: MIT" />
|
||||
</a>
|
||||
<!-- <a href="https://codebeat.co/projects/github-com-xmartlabs-xlpagertabstrip"><img alt="codebeat badge" src="https://codebeat.co/badges/f32c9ad3-0aa1-4b40-a632-9421211bd39e" /></a> -->
|
||||
|
|
@ -305,7 +305,7 @@ Follow these 3 steps to run Example project: Clone XLPagerTabStrip repository, o
|
|||
To install XLPagerTabStrip, simply add the following line to your Podfile:
|
||||
|
||||
```ruby
|
||||
pod 'XLPagerTabStrip', '~> 7.0'
|
||||
pod 'XLPagerTabStrip', '~> 8.0'
|
||||
```
|
||||
|
||||
### Carthage
|
||||
|
|
@ -315,7 +315,7 @@ pod 'XLPagerTabStrip', '~> 7.0'
|
|||
To install XLPagerTabStrip, simply add the following line to your Cartfile:
|
||||
|
||||
```ogdl
|
||||
github "xmartlabs/XLPagerTabStrip" ~> 7.0
|
||||
github "xmartlabs/XLPagerTabStrip" ~> 8.0
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ open class BarPagerTabStripViewController: PagerTabStripViewController, PagerTab
|
|||
open override func reloadPagerTabStripView() {
|
||||
super.reloadPagerTabStripView()
|
||||
barView.optionsCount = viewControllers.count
|
||||
if isViewLoaded{
|
||||
if isViewLoaded {
|
||||
barView.moveTo(index: currentIndex, animated: false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ open class BarView: UIView {
|
|||
addSubview(selectedBar)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private func updateSelectedBarPosition(with animation: Bool) {
|
||||
|
|
@ -61,8 +60,7 @@ open class BarView: UIView {
|
|||
UIView.animate(withDuration: 0.3, animations: { [weak self] in
|
||||
self?.selectedBar.frame = frame
|
||||
})
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
selectedBar.frame = frame
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,14 +24,13 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollectionViewCell>: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate, UICollectionViewDelegate, UICollectionViewDataSource {
|
||||
open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType: UICollectionViewCell>: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate, UICollectionViewDelegate, UICollectionViewDataSource {
|
||||
|
||||
public var settings = ButtonBarPagerTabStripSettings()
|
||||
public var buttonBarItemSpec: ButtonBarItemSpec<ButtonBarCellType>!
|
||||
public var changeCurrentIndex: ((_ oldCell: ButtonBarCellType?, _ newCell: ButtonBarCellType?, _ animated: Bool) -> Void)?
|
||||
public var changeCurrentIndexProgressive: ((_ oldCell: ButtonBarCellType?, _ newCell: ButtonBarCellType?, _ progressPercentage: CGFloat, _ changeCurrentIndex: Bool, _ animated: Bool) -> Void)?
|
||||
|
||||
|
||||
@IBOutlet public weak var buttonBarView: ButtonBarView!
|
||||
|
||||
lazy private var cachedCellWidths: [CGFloat]? = { [unowned self] in
|
||||
|
|
@ -55,7 +54,7 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
let buttonBarViewAux = buttonBarView ?? {
|
||||
let flowLayout = UICollectionViewFlowLayout()
|
||||
flowLayout.scrollDirection = .horizontal
|
||||
flowLayout.sectionInset = UIEdgeInsetsMake(0, settings.style.buttonBarLeftContentInset ?? 35, 0, settings.style.buttonBarRightContentInset ?? 35)
|
||||
flowLayout.sectionInset = UIEdgeInsets(top: 0, left: settings.style.buttonBarLeftContentInset ?? 35, bottom: 0, right: settings.style.buttonBarRightContentInset ?? 35)
|
||||
let buttonBarHeight = settings.style.buttonBarHeight ?? 44
|
||||
let buttonBar = ButtonBarView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: buttonBarHeight), collectionViewLayout: flowLayout)
|
||||
buttonBar.backgroundColor = .orange
|
||||
|
|
@ -79,12 +78,12 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
buttonBarView.dataSource = self
|
||||
}
|
||||
buttonBarView.scrollsToTop = false
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout // swiftlint:disable:this force_cast
|
||||
flowLayout.scrollDirection = .horizontal
|
||||
flowLayout.minimumInteritemSpacing = settings.style.buttonBarMinimumInteritemSpacing ?? flowLayout.minimumInteritemSpacing
|
||||
flowLayout.minimumLineSpacing = settings.style.buttonBarMinimumLineSpacing ?? flowLayout.minimumLineSpacing
|
||||
let sectionInset = flowLayout.sectionInset
|
||||
flowLayout.sectionInset = UIEdgeInsetsMake(sectionInset.top, settings.style.buttonBarLeftContentInset ?? sectionInset.left, sectionInset.bottom, settings.style.buttonBarRightContentInset ?? sectionInset.right)
|
||||
flowLayout.sectionInset = UIEdgeInsets(top: sectionInset.top, left: settings.style.buttonBarLeftContentInset ?? sectionInset.left, bottom: sectionInset.bottom, right: settings.style.buttonBarRightContentInset ?? sectionInset.right)
|
||||
buttonBarView.showsHorizontalScrollIndicator = false
|
||||
buttonBarView.backgroundColor = settings.style.buttonBarBackgroundColor ?? buttonBarView.backgroundColor
|
||||
buttonBarView.selectedBar.backgroundColor = settings.style.selectedBarBackgroundColor
|
||||
|
|
@ -154,16 +153,14 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
var numberOfLargeCells = 0
|
||||
var totalWidthOfLargeCells: CGFloat = 0
|
||||
|
||||
for minimumCellWidthValue in minimumCellWidths {
|
||||
if minimumCellWidthValue > suggestedStretchedCellWidth {
|
||||
totalWidthOfLargeCells += minimumCellWidthValue
|
||||
numberOfLargeCells += 1
|
||||
}
|
||||
for minimumCellWidthValue in minimumCellWidths where minimumCellWidthValue > suggestedStretchedCellWidth {
|
||||
totalWidthOfLargeCells += minimumCellWidthValue
|
||||
numberOfLargeCells += 1
|
||||
}
|
||||
|
||||
guard numberOfLargeCells > previousNumberOfLargeCells else { return suggestedStretchedCellWidth }
|
||||
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout // swiftlint:disable:this force_cast
|
||||
let collectionViewAvailiableWidth = buttonBarView.frame.size.width - flowLayout.sectionInset.left - flowLayout.sectionInset.right
|
||||
let numberOfCells = minimumCellWidths.count
|
||||
let cellSpacingTotal = CGFloat(numberOfCells - 1) * flowLayout.minimumLineSpacing
|
||||
|
|
@ -197,7 +194,7 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
|
||||
// MARK: - UICollectionViewDelegateFlowLayut
|
||||
|
||||
open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
|
||||
@objc open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
|
||||
guard let cellWidthValue = cachedCellWidths?[indexPath.row] else {
|
||||
fatalError("cachedCellWidths for \(indexPath.row) must not be nil")
|
||||
}
|
||||
|
|
@ -216,8 +213,7 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
if let changeCurrentIndexProgressive = changeCurrentIndexProgressive {
|
||||
changeCurrentIndexProgressive(oldCell, newCell, 1, true, true)
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if let changeCurrentIndex = changeCurrentIndex {
|
||||
changeCurrentIndex(oldCell, newCell, true)
|
||||
}
|
||||
|
|
@ -235,7 +231,7 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as? ButtonBarCellType else {
|
||||
fatalError("UICollectionViewCell should be or extend from ButtonBarViewCell")
|
||||
}
|
||||
let childController = viewControllers[indexPath.item] as! IndicatorInfoProvider
|
||||
let childController = viewControllers[indexPath.item] as! IndicatorInfoProvider // swiftlint:disable:this force_cast
|
||||
let indicatorInfo = childController.indicatorInfo(for: self)
|
||||
|
||||
configure(cell: cell, for: indicatorInfo)
|
||||
|
|
@ -244,8 +240,7 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
if let changeCurrentIndexProgressive = changeCurrentIndexProgressive {
|
||||
changeCurrentIndexProgressive(currentIndex == indexPath.item ? nil : cell, currentIndex == indexPath.item ? cell : nil, 1, true, false)
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if let changeCurrentIndex = changeCurrentIndex {
|
||||
changeCurrentIndex(currentIndex == indexPath.item ? nil : cell, currentIndex == indexPath.item ? cell : nil, false)
|
||||
}
|
||||
|
|
@ -263,19 +258,19 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
shouldUpdateButtonBarView = true
|
||||
}
|
||||
|
||||
open func configure(cell: ButtonBarCellType, for indicatorInfo: IndicatorInfo){
|
||||
open func configure(cell: ButtonBarCellType, for indicatorInfo: IndicatorInfo) {
|
||||
fatalError("You must override this method to set up ButtonBarView cell accordingly")
|
||||
}
|
||||
|
||||
private func calculateWidths() -> [CGFloat] {
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout // swiftlint:disable:this force_cast
|
||||
let numberOfCells = viewControllers.count
|
||||
|
||||
var minimumCellWidths = [CGFloat]()
|
||||
var collectionViewContentWidth: CGFloat = 0
|
||||
|
||||
for viewController in viewControllers {
|
||||
let childController = viewController as! IndicatorInfoProvider
|
||||
let childController = viewController as! IndicatorInfoProvider // swiftlint:disable:this force_cast
|
||||
let indicatorInfo = childController.indicatorInfo(for: self)
|
||||
switch buttonBarItemSpec! {
|
||||
case .cellClass(let widthCallback):
|
||||
|
|
@ -296,8 +291,7 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
|
||||
if !settings.style.buttonBarItemsShouldFillAvailableWidth || collectionViewAvailableVisibleWidth < collectionViewContentWidth {
|
||||
return minimumCellWidths
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
let stretchedCellWidthIfAllEqual = (collectionViewAvailableVisibleWidth - cellSpacingTotal) / CGFloat(numberOfCells)
|
||||
let generalMinimumCellWidth = calculateStretchedCellWidths(minimumCellWidths, suggestedStretchedCellWidth: stretchedCellWidthIfAllEqual, previousNumberOfLargeCells: 0)
|
||||
var stretchedCellWidths = [CGFloat]()
|
||||
|
|
@ -314,7 +308,6 @@ open class BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollec
|
|||
private var shouldUpdateButtonBarView = true
|
||||
}
|
||||
|
||||
|
||||
open class ExampleBaseButtonBarPagerTabStripViewController: BaseButtonBarPagerTabStripViewController<ButtonBarViewCell> {
|
||||
|
||||
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
|
|
@ -327,8 +320,15 @@ open class ExampleBaseButtonBarPagerTabStripViewController: BaseButtonBarPagerTa
|
|||
initialize()
|
||||
}
|
||||
|
||||
open func initialize(){
|
||||
buttonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: Bundle(for: ButtonBarViewCell.self), width:{ [weak self] (childItemInfo) -> CGFloat in
|
||||
open func initialize() {
|
||||
var bundle = Bundle(for: ButtonBarViewCell.self)
|
||||
if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") {
|
||||
if let resourcesBundle = Bundle(path: resourcePath) {
|
||||
bundle = resourcesBundle
|
||||
}
|
||||
}
|
||||
|
||||
buttonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: bundle, width: { [weak self] (childItemInfo) -> CGFloat in
|
||||
let label = UILabel()
|
||||
label.translatesAutoresizingMaskIntoConstraints = false
|
||||
label.font = self?.settings.style.buttonBarItemFont ?? label.font
|
||||
|
|
@ -338,7 +338,7 @@ open class ExampleBaseButtonBarPagerTabStripViewController: BaseButtonBarPagerTa
|
|||
})
|
||||
}
|
||||
|
||||
open override func configure(cell: ButtonBarViewCell, for indicatorInfo: IndicatorInfo){
|
||||
open override func configure(cell: ButtonBarViewCell, for indicatorInfo: IndicatorInfo) {
|
||||
cell.label.text = indicatorInfo.title
|
||||
if let image = indicatorInfo.image {
|
||||
cell.imageView.image = image
|
||||
|
|
|
|||
|
|
@ -101,7 +101,15 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
|
||||
open override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
buttonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: Bundle(for: ButtonBarViewCell.self), width:{ [weak self] (childItemInfo) -> CGFloat in
|
||||
|
||||
var bundle = Bundle(for: ButtonBarViewCell.self)
|
||||
if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") {
|
||||
if let resourcesBundle = Bundle(path: resourcePath) {
|
||||
bundle = resourcesBundle
|
||||
}
|
||||
}
|
||||
|
||||
buttonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: bundle, width: { [weak self] (childItemInfo) -> CGFloat in
|
||||
let label = UILabel()
|
||||
label.translatesAutoresizingMaskIntoConstraints = false
|
||||
label.font = self?.settings.style.buttonBarItemFont
|
||||
|
|
@ -110,7 +118,6 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
return labelSize.width + (self?.settings.style.buttonBarItemLeftRightMargin ?? 8) * 2
|
||||
})
|
||||
|
||||
|
||||
let buttonBarViewAux = buttonBarView ?? {
|
||||
let flowLayout = UICollectionViewFlowLayout()
|
||||
flowLayout.scrollDirection = .horizontal
|
||||
|
|
@ -137,12 +144,12 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
buttonBarView.dataSource = self
|
||||
}
|
||||
buttonBarView.scrollsToTop = false
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout // swiftlint:disable:this force_cast
|
||||
flowLayout.scrollDirection = .horizontal
|
||||
flowLayout.minimumInteritemSpacing = settings.style.buttonBarMinimumInteritemSpacing ?? flowLayout.minimumInteritemSpacing
|
||||
flowLayout.minimumLineSpacing = settings.style.buttonBarMinimumLineSpacing ?? flowLayout.minimumLineSpacing
|
||||
let sectionInset = flowLayout.sectionInset
|
||||
flowLayout.sectionInset = UIEdgeInsetsMake(sectionInset.top, settings.style.buttonBarLeftContentInset ?? sectionInset.left, sectionInset.bottom, settings.style.buttonBarRightContentInset ?? sectionInset.right)
|
||||
flowLayout.sectionInset = UIEdgeInsets(top: sectionInset.top, left: settings.style.buttonBarLeftContentInset ?? sectionInset.left, bottom: sectionInset.bottom, right: settings.style.buttonBarRightContentInset ?? sectionInset.right)
|
||||
|
||||
buttonBarView.showsHorizontalScrollIndicator = false
|
||||
buttonBarView.backgroundColor = settings.style.buttonBarBackgroundColor ?? buttonBarView.backgroundColor
|
||||
|
|
@ -210,7 +217,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
|
||||
guard numberOfLargeCells > previousNumberOfLargeCells else { return suggestedStretchedCellWidth }
|
||||
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout // swiftlint:disable:this force_cast
|
||||
let collectionViewAvailiableWidth = buttonBarView.frame.size.width - flowLayout.sectionInset.left - flowLayout.sectionInset.right
|
||||
let numberOfCells = minimumCellWidths.count
|
||||
let cellSpacingTotal = CGFloat(numberOfCells - 1) * flowLayout.minimumLineSpacing
|
||||
|
|
@ -251,7 +258,8 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
|
||||
if reload {
|
||||
let indexPathsToReload = cells.enumerated()
|
||||
.flatMap { index, cell in
|
||||
.flatMap { (arg) -> IndexPath? in
|
||||
let (index, cell) = arg
|
||||
return cell == nil ? indexPaths[index] : nil
|
||||
}
|
||||
.flatMap { (indexPath: IndexPath) -> IndexPath? in
|
||||
|
|
@ -266,9 +274,9 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
return cells
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegateFlowLayout
|
||||
// MARK: - UICollectionViewDelegateFlowLayut
|
||||
|
||||
open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
|
||||
@objc open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
|
||||
guard let cellWidthValue = cachedCellWidths?[indexPath.row] else {
|
||||
fatalError("cachedCellWidths for \(indexPath.row) must not be nil")
|
||||
}
|
||||
|
|
@ -290,8 +298,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
if let changeCurrentIndexProgressive = changeCurrentIndexProgressive {
|
||||
changeCurrentIndexProgressive(cells.first!, cells.last!, 1, true, true)
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if let changeCurrentIndex = changeCurrentIndex {
|
||||
changeCurrentIndex(cells.first!, cells.last!, true)
|
||||
}
|
||||
|
|
@ -312,7 +319,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
|
||||
collectionViewDidLoad = true
|
||||
|
||||
let childController = viewControllers[indexPath.item] as! IndicatorInfoProvider
|
||||
let childController = viewControllers[indexPath.item] as! IndicatorInfoProvider // swiftlint:disable:this force_cast
|
||||
let indicatorInfo = childController.indicatorInfo(for: self)
|
||||
|
||||
cell.label.text = indicatorInfo.title
|
||||
|
|
@ -333,8 +340,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
if let changeCurrentIndexProgressive = changeCurrentIndexProgressive {
|
||||
changeCurrentIndexProgressive(currentIndex == indexPath.item ? nil : cell, currentIndex == indexPath.item ? cell : nil, 1, true, false)
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if let changeCurrentIndex = changeCurrentIndex {
|
||||
changeCurrentIndex(currentIndex == indexPath.item ? nil : cell, currentIndex == indexPath.item ? cell : nil, false)
|
||||
}
|
||||
|
|
@ -351,18 +357,18 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
shouldUpdateButtonBarView = true
|
||||
}
|
||||
|
||||
open func configureCell(_ cell: ButtonBarViewCell, indicatorInfo: IndicatorInfo){
|
||||
open func configureCell(_ cell: ButtonBarViewCell, indicatorInfo: IndicatorInfo) {
|
||||
}
|
||||
|
||||
private func calculateWidths() -> [CGFloat] {
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout
|
||||
let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout // swiftlint:disable:this force_cast
|
||||
let numberOfCells = viewControllers.count
|
||||
|
||||
var minimumCellWidths = [CGFloat]()
|
||||
var collectionViewContentWidth: CGFloat = 0
|
||||
|
||||
for viewController in viewControllers {
|
||||
let childController = viewController as! IndicatorInfoProvider
|
||||
let childController = viewController as! IndicatorInfoProvider // swiftlint:disable:this force_cast
|
||||
let indicatorInfo = childController.indicatorInfo(for: self)
|
||||
switch buttonBarItemSpec! {
|
||||
case .cellClass(let widthCallback):
|
||||
|
|
@ -383,8 +389,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
|
||||
if !settings.style.buttonBarItemsShouldFillAvailableWidth || collectionViewAvailableVisibleWidth < collectionViewContentWidth {
|
||||
return minimumCellWidths
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
let stretchedCellWidthIfAllEqual = (collectionViewAvailableVisibleWidth - cellSpacingTotal) / CGFloat(numberOfCells)
|
||||
let generalMinimumCellWidth = calculateStretchedCellWidths(minimumCellWidths, suggestedStretchedCellWidth: stretchedCellWidthIfAllEqual, previousNumberOfLargeCells: 0)
|
||||
var stretchedCellWidths = [CGFloat]()
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ open class ButtonBarView: UICollectionView {
|
|||
updateSelectedBarPosition(animated, swipeDirection: swipeDirection, pagerScroll: pagerScroll)
|
||||
}
|
||||
|
||||
open func move(fromIndex: Int, toIndex: Int, progressPercentage: CGFloat,pagerScroll: PagerScroll) {
|
||||
open func move(fromIndex: Int, toIndex: Int, progressPercentage: CGFloat, pagerScroll: PagerScroll) {
|
||||
selectedIndex = progressPercentage > 0.5 ? toIndex : fromIndex
|
||||
|
||||
let fromFrame = layoutAttributesForItem(at: IndexPath(item: fromIndex, section: 0))!.frame
|
||||
|
|
@ -87,13 +87,11 @@ open class ButtonBarView: UICollectionView {
|
|||
if toIndex < 0 {
|
||||
let cellAtts = layoutAttributesForItem(at: IndexPath(item: 0, section: 0))
|
||||
toFrame = cellAtts!.frame.offsetBy(dx: -cellAtts!.frame.size.width, dy: 0)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
let cellAtts = layoutAttributesForItem(at: IndexPath(item: (numberOfItems - 1), section: 0))
|
||||
toFrame = cellAtts!.frame.offsetBy(dx: cellAtts!.frame.size.width, dy: 0)
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
toFrame = layoutAttributesForItem(at: IndexPath(item: toIndex, section: 0))!.frame
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +113,7 @@ open class ButtonBarView: UICollectionView {
|
|||
setContentOffset(CGPoint(x: targetContentOffset, y: 0), animated: false)
|
||||
}
|
||||
|
||||
open func updateSelectedBarPosition(_ animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) -> Void {
|
||||
open func updateSelectedBarPosition(_ animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) {
|
||||
var selectedBarFrame = selectedBar.frame
|
||||
|
||||
let selectedCellIndexPath = IndexPath(item: selectedIndex, section: 0)
|
||||
|
|
@ -131,22 +129,21 @@ open class ButtonBarView: UICollectionView {
|
|||
UIView.animate(withDuration: 0.3, animations: { [weak self] in
|
||||
self?.selectedBar.frame = selectedBarFrame
|
||||
})
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
selectedBar.frame = selectedBarFrame
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private func updateContentOffset(animated: Bool, pagerScroll: PagerScroll, toFrame: CGRect, toIndex: Int) -> Void {
|
||||
private func updateContentOffset(animated: Bool, pagerScroll: PagerScroll, toFrame: CGRect, toIndex: Int) {
|
||||
guard pagerScroll != .no || (pagerScroll != .scrollOnlyIfOutOfScreen && (toFrame.origin.x < contentOffset.x || toFrame.origin.x >= (contentOffset.x + frame.size.width - contentInset.left))) else { return }
|
||||
let targetContentOffset = contentSize.width > frame.size.width ? contentOffsetForCell(withFrame: toFrame, andIndex: toIndex) : 0
|
||||
setContentOffset(CGPoint(x: targetContentOffset, y: 0), animated: animated)
|
||||
}
|
||||
|
||||
private func contentOffsetForCell(withFrame cellFrame: CGRect, andIndex index: Int) -> CGFloat {
|
||||
let sectionInset = (collectionViewLayout as! UICollectionViewFlowLayout).sectionInset
|
||||
let sectionInset = (collectionViewLayout as! UICollectionViewFlowLayout).sectionInset // swiftlint:disable:this force_cast
|
||||
var alignmentOffset: CGFloat = 0.0
|
||||
|
||||
switch selectedBarAlignment {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wgnu"
|
||||
#pragma GCC diagnostic ignored "-Wreceiver-is-weak"
|
||||
#pragma GCC diagnostic ignored "-Warc-repeated-use-of-weak"
|
||||
#pragma GCC diagnostic ignored "-Wdirect-ivar-access"
|
||||
|
||||
|
|
|
|||
|
|
@ -48,18 +48,17 @@ public struct IndicatorInfo {
|
|||
|
||||
}
|
||||
|
||||
|
||||
extension IndicatorInfo : ExpressibleByStringLiteral {
|
||||
|
||||
public init(stringLiteral value: String){
|
||||
public init(stringLiteral value: String) {
|
||||
title = value
|
||||
}
|
||||
|
||||
public init(extendedGraphemeClusterLiteral value: String){
|
||||
public init(extendedGraphemeClusterLiteral value: String) {
|
||||
title = value
|
||||
}
|
||||
|
||||
public init(unicodeScalarLiteral value: String){
|
||||
public init(unicodeScalarLiteral value: String) {
|
||||
title = value
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,26 +38,21 @@ public enum PagerTabStripBehaviour {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public var isProgressiveIndicator: Bool {
|
||||
switch self {
|
||||
case .common(_):
|
||||
case .common:
|
||||
return false
|
||||
case .progressive(_, _):
|
||||
case .progressive:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
public var isElasticIndicatorLimit: Bool {
|
||||
switch self {
|
||||
case .common(_):
|
||||
case .common:
|
||||
return false
|
||||
case .progressive(_, let elasticIndicatorLimit):
|
||||
return elasticIndicatorLimit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,5 +25,7 @@
|
|||
import Foundation
|
||||
|
||||
public enum PagerTabStripError: Error {
|
||||
case viewControllerNotContainedInPagerTabStrip
|
||||
|
||||
case viewControllerOutOfBounds
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,15 +22,14 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
// MARK: Protocols
|
||||
|
||||
public protocol IndicatorInfoProvider {
|
||||
|
||||
func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo
|
||||
|
||||
}
|
||||
|
||||
public protocol PagerTabStripDelegate: class {
|
||||
|
|
@ -38,7 +37,7 @@ public protocol PagerTabStripDelegate: class {
|
|||
func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int)
|
||||
}
|
||||
|
||||
public protocol PagerTabStripIsProgressiveDelegate : PagerTabStripDelegate {
|
||||
public protocol PagerTabStripIsProgressiveDelegate: PagerTabStripDelegate {
|
||||
|
||||
func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool)
|
||||
}
|
||||
|
|
@ -48,8 +47,7 @@ public protocol PagerTabStripDataSource: class {
|
|||
func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController]
|
||||
}
|
||||
|
||||
|
||||
//MARK: PagerTabStripViewController
|
||||
// MARK: PagerTabStripViewController
|
||||
|
||||
open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
||||
|
||||
|
|
@ -79,8 +77,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
open var swipeDirection: SwipeDirection {
|
||||
if containerView.contentOffset.x > lastContentOffset {
|
||||
return .left
|
||||
}
|
||||
else if containerView.contentOffset.x < lastContentOffset {
|
||||
} else if containerView.contentOffset.x < lastContentOffset {
|
||||
return .right
|
||||
}
|
||||
return .none
|
||||
|
|
@ -142,7 +139,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
childViewControllers.forEach { $0.endAppearanceTransition() }
|
||||
}
|
||||
|
||||
override open func viewDidLayoutSubviews(){
|
||||
override open func viewDidLayoutSubviews() {
|
||||
super.viewDidLayoutSubviews()
|
||||
updateIfNeeded()
|
||||
}
|
||||
|
|
@ -168,8 +165,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: fromIndex), y: 0), animated: false)
|
||||
(navigationController?.view ?? view).isUserInteractionEnabled = !animated
|
||||
containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: true)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
(navigationController?.view ?? view).isUserInteractionEnabled = !animated
|
||||
containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: animated)
|
||||
}
|
||||
|
|
@ -179,17 +175,17 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
moveToViewController(at: viewControllers.index(of: viewController)!, animated: animated)
|
||||
}
|
||||
|
||||
//MARK: - PagerTabStripDataSource
|
||||
// MARK: - PagerTabStripDataSource
|
||||
|
||||
open func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
|
||||
assertionFailure("Sub-class must implement the PagerTabStripDataSource viewControllers(for:) method")
|
||||
return []
|
||||
}
|
||||
|
||||
//MARK: - Helpers
|
||||
// MARK: - Helpers
|
||||
|
||||
open func updateIfNeeded() {
|
||||
if isViewLoaded && !lastSize.equalTo(containerView.bounds.size){
|
||||
if isViewLoaded && !lastSize.equalTo(containerView.bounds.size) {
|
||||
updateContent()
|
||||
}
|
||||
}
|
||||
|
|
@ -202,13 +198,13 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
return CGFloat(index) * containerView.bounds.width
|
||||
}
|
||||
|
||||
open func offsetForChild(at index: Int) -> CGFloat{
|
||||
open func offsetForChild(at index: Int) -> CGFloat {
|
||||
return (CGFloat(index) * containerView.bounds.width) + ((containerView.bounds.width - view.bounds.width) * 0.5)
|
||||
}
|
||||
|
||||
open func offsetForChild(viewController: UIViewController) throws -> CGFloat{
|
||||
open func offsetForChild(viewController: UIViewController) throws -> CGFloat {
|
||||
guard let index = viewControllers.index(of: viewController) else {
|
||||
throw PagerTabStripError.viewControllerNotContainedInPagerTabStrip
|
||||
throw PagerTabStripError.viewControllerOutOfBounds
|
||||
}
|
||||
return offsetForChild(at: index)
|
||||
}
|
||||
|
|
@ -222,7 +218,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
return Int((contentOffset + 1.5 * pageWidth) / pageWidth) - 1
|
||||
}
|
||||
|
||||
open func pageFor(virtualPage: Int) -> Int{
|
||||
open func pageFor(virtualPage: Int) -> Int {
|
||||
if virtualPage < 0 {
|
||||
return 0
|
||||
}
|
||||
|
|
@ -245,11 +241,10 @@ 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 let _ = childController.parent {
|
||||
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 {
|
||||
} else {
|
||||
childController.beginAppearanceTransition(true, animated: false)
|
||||
addChildViewController(childController)
|
||||
childController.view.frame = CGRect(x: offsetForChild(at: index), y: 0, width: view.bounds.width, height: containerView.bounds.height)
|
||||
|
|
@ -258,9 +253,8 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
childController.didMove(toParentViewController: self)
|
||||
childController.endAppearanceTransition()
|
||||
}
|
||||
}
|
||||
else {
|
||||
if let _ = childController.parent {
|
||||
} else {
|
||||
if childController.parent != nil {
|
||||
childController.beginAppearanceTransition(false, animated: false)
|
||||
childController.willMove(toParentViewController: nil)
|
||||
childController.view.removeFromSuperview()
|
||||
|
|
@ -277,26 +271,23 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
preCurrentIndex = currentIndex
|
||||
let changeCurrentIndex = newCurrentIndex != oldCurrentIndex
|
||||
|
||||
if let progressiveDeledate = self as? PagerTabStripIsProgressiveDelegate, pagerBehaviour.isProgressiveIndicator {
|
||||
if let progressiveDelegate = self as? PagerTabStripIsProgressiveDelegate, pagerBehaviour.isProgressiveIndicator {
|
||||
|
||||
let (fromIndex, toIndex, scrollPercentage) = progressiveIndicatorData(virtualPage)
|
||||
progressiveDeledate.updateIndicator(for: self, fromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: scrollPercentage, indexWasChanged: changeCurrentIndex)
|
||||
}
|
||||
else{
|
||||
progressiveDelegate.updateIndicator(for: self, fromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: scrollPercentage, indexWasChanged: changeCurrentIndex)
|
||||
} else {
|
||||
delegate?.updateIndicator(for: self, fromIndex: min(oldCurrentIndex, pagerViewControllers.count - 1), toIndex: newCurrentIndex)
|
||||
}
|
||||
}
|
||||
|
||||
open func reloadPagerTabStripView() {
|
||||
guard isViewLoaded else { return }
|
||||
for childController in viewControllers {
|
||||
if let _ = childController.parent {
|
||||
childController.beginAppearanceTransition(false, animated: false)
|
||||
childController.willMove(toParentViewController: nil)
|
||||
childController.view.removeFromSuperview()
|
||||
childController.removeFromParentViewController()
|
||||
childController.endAppearanceTransition()
|
||||
}
|
||||
for childController in viewControllers where childController.parent != nil {
|
||||
childController.beginAppearanceTransition(false, animated: false)
|
||||
childController.willMove(toParentViewController: nil)
|
||||
childController.view.removeFromSuperview()
|
||||
childController.removeFromParentViewController()
|
||||
childController.endAppearanceTransition()
|
||||
}
|
||||
reloadViewControllers()
|
||||
containerView.contentSize = CGSize(width: containerView.bounds.width * CGFloat(viewControllers.count), height: containerView.contentSize.height)
|
||||
|
|
@ -308,7 +299,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
updateContent()
|
||||
}
|
||||
|
||||
//MARK: - UIScrollDelegate
|
||||
// MARK: - UIScrollDelegate
|
||||
|
||||
open func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
if containerView == scrollView {
|
||||
|
|
@ -331,7 +322,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
//MARK: - Orientation
|
||||
// MARK: - Orientation
|
||||
|
||||
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||
super.viewWillTransition(to: size, with: coordinator)
|
||||
|
|
@ -346,8 +337,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//MARK: Private
|
||||
// MARK: Private
|
||||
|
||||
private func progressiveIndicatorData(_ virtualPage: Int) -> (Int, Int, CGFloat) {
|
||||
let count = viewControllers.count
|
||||
|
|
@ -359,26 +349,21 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
if virtualPage > count - 1 {
|
||||
fromIndex = count - 1
|
||||
toIndex = count
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if self.scrollPercentage >= 0.5 {
|
||||
fromIndex = max(toIndex - 1, 0)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
toIndex = fromIndex + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
else if direction == .right {
|
||||
} else if direction == .right {
|
||||
if virtualPage < 0 {
|
||||
fromIndex = 0
|
||||
toIndex = -1
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if self.scrollPercentage > 0.5 {
|
||||
fromIndex = min(toIndex + 1, count - 1)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
toIndex = fromIndex - 1
|
||||
}
|
||||
}
|
||||
|
|
@ -387,20 +372,20 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
|
|||
return (fromIndex, toIndex, scrollPercentage)
|
||||
}
|
||||
|
||||
private func reloadViewControllers(){
|
||||
private func reloadViewControllers() {
|
||||
guard let dataSource = datasource else {
|
||||
fatalError("dataSource must not be nil")
|
||||
}
|
||||
viewControllers = dataSource.viewControllers(for: self)
|
||||
// viewControllers
|
||||
guard viewControllers.count != 0 else {
|
||||
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 InfoProvider") }}
|
||||
|
||||
}
|
||||
|
||||
private var pagerTabStripChildViewControllersForScrolling : [UIViewController]?
|
||||
private var pagerTabStripChildViewControllersForScrolling: [UIViewController]?
|
||||
private var lastPageNumber = 0
|
||||
private var lastContentOffset: CGFloat = 0.0
|
||||
private var pageBeforeRotate = 0
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ public struct SegmentedPagerTabStripSettings {
|
|||
public var style = Style()
|
||||
}
|
||||
|
||||
|
||||
open class SegmentedPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripDelegate {
|
||||
|
||||
@IBOutlet weak public var segmentedControl: UISegmentedControl!
|
||||
|
|
@ -76,19 +75,18 @@ open class SegmentedPagerTabStripViewController: PagerTabStripViewController, Pa
|
|||
|
||||
func reloadSegmentedControl() {
|
||||
segmentedControl.removeAllSegments()
|
||||
for (index, item) in viewControllers.enumerated(){
|
||||
let child = item as! IndicatorInfoProvider
|
||||
for (index, item) in viewControllers.enumerated() {
|
||||
let child = item as! IndicatorInfoProvider // swiftlint:disable:this force_cast
|
||||
if let image = child.indicatorInfo(for: self).image {
|
||||
segmentedControl.insertSegment(with: image, at: index, animated: false)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
segmentedControl.insertSegment(withTitle: child.indicatorInfo(for: self).title, at: index, animated: false)
|
||||
}
|
||||
}
|
||||
segmentedControl.selectedSegmentIndex = currentIndex
|
||||
}
|
||||
|
||||
func segmentedControlChanged(_ sender: UISegmentedControl) {
|
||||
@objc func segmentedControlChanged(_ sender: UISegmentedControl) {
|
||||
let index = sender.selectedSegmentIndex
|
||||
updateIndicator(for: self, fromIndex: currentIndex, toIndex: index)
|
||||
shouldUpdateSegmentedControl = false
|
||||
|
|
|
|||
|
|
@ -91,11 +91,9 @@ open class TwitterPagerTabStripViewController: PagerTabStripViewController, Page
|
|||
var xOffset: CGFloat = 0
|
||||
if fromIndex < toIndex {
|
||||
xOffset = distance * CGFloat(fromIndex) + distance * progressPercentage
|
||||
}
|
||||
else if fromIndex > toIndex {
|
||||
} else if fromIndex > toIndex {
|
||||
xOffset = distance * CGFloat(fromIndex) - distance * progressPercentage
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
xOffset = distance * CGFloat(fromIndex)
|
||||
}
|
||||
|
||||
|
|
@ -175,9 +173,9 @@ open class TwitterPagerTabStripViewController: PagerTabStripViewController, Page
|
|||
childTitleLabels.forEach { $0.removeFromSuperview() }
|
||||
childTitleLabels.removeAll()
|
||||
for (index, item) in viewControllers.enumerated() {
|
||||
let child = item as! IndicatorInfoProvider
|
||||
let child = item as! IndicatorInfoProvider // swiftlint:disable:this force_cast
|
||||
let indicatorInfo = child.indicatorInfo(for: self)
|
||||
let navTitleLabel : UILabel = {
|
||||
let navTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = indicatorInfo.title
|
||||
label.font = UIApplication.shared.statusBarOrientation.isPortrait ? settings.style.portraitTitleFont : settings.style.landscapeTitleFont
|
||||
|
|
@ -223,8 +221,7 @@ open class TwitterPagerTabStripViewController: PagerTabStripViewController, Page
|
|||
label.alpha = {
|
||||
if offset < distance * CGFloat(index) {
|
||||
return (offset - distance * CGFloat(index - 1)) / distance
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return 1 - ((offset - distance * CGFloat(index)) / distance)
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = "XLPagerTabStrip"
|
||||
s.version = "7.0.0"
|
||||
s.version = "8.0.0"
|
||||
s.summary = "Android PagerTabStrip for iOS and much more."
|
||||
s.homepage = "https://github.com/xmartlabs/XLPagerTabStrip"
|
||||
s.license = { type: 'MIT', file: 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@
|
|||
28F828791C494B2C00330CF4 /* Frameworks */,
|
||||
28F8287A1C494B2C00330CF4 /* Headers */,
|
||||
28F8287B1C494B2C00330CF4 /* Resources */,
|
||||
CB25B8F81EBCF0CE00FEB0A2 /* SwiftLint */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
|
@ -227,11 +228,11 @@
|
|||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0720;
|
||||
LastUpgradeCheck = 0810;
|
||||
LastUpgradeCheck = 0900;
|
||||
TargetAttributes = {
|
||||
28F8287C1C494B2C00330CF4 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
LastSwiftMigration = 0800;
|
||||
LastSwiftMigration = 0900;
|
||||
};
|
||||
28F828861C494B2C00330CF4 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
|
|
@ -275,6 +276,23 @@
|
|||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
CB25B8F81EBCF0CE00FEB0A2 /* SwiftLint */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = SwiftLint;
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
28F828781C494B2C00330CF4 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
|
|
@ -324,14 +342,20 @@
|
|||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
|
|
@ -355,12 +379,12 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 2.3;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
|
|
@ -375,14 +399,20 @@
|
|||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
|
|
@ -400,7 +430,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
|
|
@ -427,7 +457,8 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStrip;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
|
@ -447,7 +478,8 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStrip;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
@ -460,7 +492,7 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStripTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
|
@ -472,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 = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0810"
|
||||
LastUpgradeVersion = "0900"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
|
|
@ -55,6 +56,7 @@
|
|||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
|
|
|||
Loading…
Reference in New Issue