Repository: xmartlabs/XLPagerTabStrip Branch: master Commit: 211ed62aa376 Files: 95 Total size: 382.6 KB Directory structure: gitextract__7a04txt/ ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE.md │ └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .swiftlint.yml ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Cartfile.private ├── Example/ │ ├── Example/ │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets/ │ │ │ ├── AppIcon.appiconset/ │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ ├── Simpsons/ │ │ │ │ ├── Apu_Nahasapeemapetilon.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── Bart_Simpsons.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── Contents.json │ │ │ │ ├── Homer_Simpsons.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── Lisa_Simpsons.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── Maggie_Simpsons.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── Marge_Simpsons.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── Montgomery_Burns.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── Ned_Flanders.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── Otto_Mann.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ └── default-avatar.imageset/ │ │ │ │ └── Contents.json │ │ │ ├── TabBar/ │ │ │ │ ├── Contents.json │ │ │ │ ├── icon_bar.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── icon_button.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ ├── icon_segmented.imageset/ │ │ │ │ │ └── Contents.json │ │ │ │ └── icon_twitter.imageset/ │ │ │ │ └── Contents.json │ │ │ └── Youtube/ │ │ │ ├── Contents.json │ │ │ ├── home.imageset/ │ │ │ │ └── Contents.json │ │ │ ├── more_options.imageset/ │ │ │ │ └── Contents.json │ │ │ ├── profile.imageset/ │ │ │ │ └── Contents.json │ │ │ ├── search.imageset/ │ │ │ │ └── Contents.json │ │ │ └── trending.imageset/ │ │ │ └── Contents.json │ │ ├── BarExampleViewController.swift │ │ ├── Base.lproj/ │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Storyboard.storyboard │ │ ├── ButtonBarExampleViewController.swift │ │ ├── ChildControllers/ │ │ │ ├── ChildExampleViewController.swift │ │ │ └── TableChildExampleViewController.swift │ │ ├── Helpers/ │ │ │ ├── DataProvider.swift │ │ │ ├── PostCell.swift │ │ │ └── PostCell.xib │ │ ├── Info.plist │ │ ├── Instagram/ │ │ │ └── InstagramExampleViewController.swift │ │ ├── NavButtonBarExampleViewController.swift │ │ ├── ReloadExampleViewController.swift │ │ ├── SegmentedExampleViewController.swift │ │ ├── Spotify/ │ │ │ └── SpotifyExampleViewController.swift │ │ ├── TwitterExampleViewController.swift │ │ ├── Youtube/ │ │ │ ├── YoutubeExampleViewController.swift │ │ │ ├── YoutubeIconCell.swift │ │ │ └── YoutubeIconCell.xib │ │ └── YoutubeWithLabel/ │ │ ├── YoutubeIconWithLabelCell.swift │ │ ├── YoutubeIconWithLabelCell.xib │ │ └── YoutubeWithLabelExampleViewController.swift │ └── ExampleUITests/ │ ├── ExampleUITests.swift │ └── Info.plist ├── Example.xcodeproj/ │ ├── project.pbxproj │ └── project.xcworkspace/ │ └── contents.xcworkspacedata ├── LICENSE ├── Migration.md ├── ObjC/ │ ├── FXPageControl.h │ └── FXPageControl.m ├── Package.resolved ├── Package.swift ├── Playground.playground/ │ ├── Contents.swift │ └── contents.xcplayground ├── README.md ├── Sources/ │ └── XLPagerTabStrip/ │ ├── BarPagerTabStripViewController.swift │ ├── BarView.swift │ ├── BaseButtonBarPagerTabStripViewController.swift │ ├── ButtonBarPagerTabStripViewController.swift │ ├── ButtonBarView.swift │ ├── ButtonBarViewCell.swift │ ├── IndicatorInfo.swift │ ├── PagerTabStripBehaviour.swift │ ├── PagerTabStripError.swift │ ├── PagerTabStripViewController.swift │ ├── Resources/ │ │ └── ButtonCell.xib │ ├── SegmentedPagerTabStripViewController.swift │ ├── SwipeDirection.swift │ ├── TwitterPagerTabStripViewController.swift │ └── UIWindow+Pager.swift ├── Tests/ │ ├── Info.plist │ └── XLPagerTabStripTests.swift ├── XLPagerTabStrip/ │ ├── Info.plist │ └── XLPagerTabStrip.h ├── XLPagerTabStrip.podspec ├── XLPagerTabStrip.xcodeproj/ │ ├── project.pbxproj │ ├── project.xcworkspace/ │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata/ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata/ │ └── xcschemes/ │ └── XLPagerTabStrip.xcscheme └── XLPagerTabStrip.xcworkspace/ ├── contents.xcworkspacedata └── xcshareddata/ └── IDEWorkspaceChecks.plist ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: xmartlabs # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: .github/ISSUE_TEMPLATE.md ================================================ Before submitting issues ... - Make sure you are using XLPagerTabStrip [latest release](https://github.com/xmartlabs/XLPagerTabStrip/releases) or master branch version. - Make sure your Xcode version is the latest stable one. - Check if the issue was [already reported or fixed](https://github.com/xmartlabs/XLPagerTabStrip/issues?utf8=%E2%9C%93&q=is%3Aissue). We add labels to each issue in order to easily find related issues. If you found a match add a brief comment "I have the same problem" or "+1". - Please do not use the issue tracker for personal support requests. Stack Overflow is a better place for that where a wider community can help you! When submitting issues, please provide the following information to help maintainers to fix the problem faster: - Environment: XLPagerTabStrip, Xcode and iOS version you are using. - In case of reporting errors, provide Xcode console output of stack trace or code compilation error. - Any other additional detail such as example code that you think it would be useful to understand, reproduce and solve the problem. ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ================================================ FILE: .gitignore ================================================ ## OS X Finder .DS_Store ## Build generated build/ DerivedData ## Various settings *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata ## Other *.xccheckout *.moved-aside *.xcuserstate *.xcscmblueprint ## Obj-C/Swift specific *.hmap *.ipa ## Playgrounds timeline.xctimeline playground.xcworkspace # Swift Package Manager # # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. # Packages/ .build/ # CocoaPods # # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control # # Pods/ # Carthage # # Add this line if you want to avoid checking in source code from Carthage dependencies. # Carthage/Checkouts Carthage/Build .swift-version .swiftpm/xcode ================================================ FILE: .swiftlint.yml ================================================ 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) ================================================ FILE: .travis.yml ================================================ language: objective-c osx_image: xcode10.2 branches: only: - master env: - DESTINATION="OS=12.1,name=iPhone XS" SCHEME="XLPagerTabStrip" SDK=iphonesimulator before_install: - brew update - brew outdated carthage || brew upgrade carthage script: - set -o pipefail - xcodebuild -version - xcodebuild clean build -project XLPagerTabStrip.xcodeproj -scheme "$SCHEME" -sdk "$SDK" #- xcodebuild test -project XLPagerTabStrip.xcodeproj -scheme "$SCHEME" -sdk "$SDK" - xcodebuild -project XLPagerTabStrip.xcodeproj -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO test | xcpretty ================================================ FILE: CHANGELOG.md ================================================ # Change Log All notable changes to XLPagerTabStrip will be documented in this file. ### [9.1.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/9.1.0) * SPM support. ### [9.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/9.0.0) * Xcode 10.2 and Swift 5.0 support. * Minor updates and fixes. ### [8.1.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/8.1.0) * Xcode 10 and Swift 4.2 support. * Minor updates and fixes. ### [8.0.1](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/8.0.1) * Bug fixes and stability improvements. * Support for iPhone X. ### [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/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)) ### [5.1.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/5.0.0) * Xcode 8 support. (Swift 2.3) ### [5.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/5.0.0) * Xcode 7.3 support. * Bug fixes and stability improvements. ### [4.0.2](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/4.0.2) * Bug fixes ### [4.0.1](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/4.0.1) * Bug fixes and stability improvements ### [4.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/4.0.0) * Base code migration from obj-c to swift. * Removed XL prefix from all types. ### [3.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/3.0.0) * `selectedBarAlignment` added to `XLButtonBarView`. * `shouldCellsFillAvailableWidth` added to `XLButtonBarView`. * Bug fixes and Stability improvements. ### [2.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/v2.0.0) * Added ability to change look and feel of selected tab. * `changeCurrentIndexProgressiveBlock` added to `XLButtonBarPagerTabStripViewController`. * `changeCurrentIndexBlock` added to `XLButtonBarPagerTabStripViewController`. * indxWasChanged parameter was added to `-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage indexWasChanged:(BOOL)indexWasChanged;` * Bug Fix Issue #45: When the current tab is tapped by the user, and later swiping to another tab, the indicator now changes as expected. * Bug Fix: When scrolling between tabs with progressive indicator, the indicator now scrolls swiftly. It used to jump for an instant. * Bug Fix Issue #54: Twitter PagerTabStrip wasn't loading the navigation title correctly. * Bug Fix Issue #32: Demo for Nav Button Bar Example fix. * Bug Fix Issue #32: Twitter Pager white dots that mark which tab is currently selected is non selectable now. * Bug Fix Issue #22: moveToViewControllerAtIndex: in viewDidLoad or viewWillAppear is not reflected in buttonBarView. ### [1.1.1](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/v1.1.1) * Nav Button example added * Support for iOS 7.0 and above ### [1.1.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/v1.1.0) * Twitter pager added * Bug fixes and stability improvements ### [1.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/v1.0.0) * Initial release ================================================ FILE: CONTRIBUTING.md ================================================ Contributing Guidelines -------------------------------------------------- This document provides general guidelines about how to contribute to the project. Keep in mind these important things before you start contributing. ### Asking Questions We do not use github issues for general library support. We think this questions should be posted on stack overflow using [XlPagerTabStrip](http://http://stackoverflow.com/questions/tagged/xlpagertabstrip) tag. ### Reporting issues * Use [github issues](https://github.com/xmartlabs/XLPagerTabStrip/issues) to report a bug. * Before creating a new issue: * Make sure you are using the [latest release](https://github.com/xmartlabs/XLPagerTabStrip/releases). * Check if the issue was [already reported or fixed](https://github.com/xmartlabs/XLPagerTabStrip/issues?utf8=%E2%9C%93&q=is%3Aissue). Notice that it may not be released yet. * If you found a match add a brief comment "I have the same problem" or "+1". This helps prioritize the issues addressing the most common and critical first. If possible add additional information to help us reproduce and fix the issue. Please use your best judgement. * Reporting issues: * Please include the following information to help maintainers to fix the problem faster: * Xcode version you are using. * iOS version you are targeting. * Full Xcode console output of stack trace or code compilation error. * Any other additional detail you think it would be useful to understand and solve the problem. ### Pull requests The easiest way to start contributing is searching open issues by `help wanted` tag. We also add a `difficulty` tag (difficulty: easy, difficulty: moderate, difficulty: hard) in order to give an idea of how complex it can be to implement the feature according maintainers project experience. * Add test coverage to the feature or fix. We only accept new feature pull requests that have related test coverage. This allows us to keep the library stable as we move forward. * Remember to document the new feature. We do not accept new feature pull requests without its associated documentation. * In case of a new feature please update the example project showing the feature. * Please only one fix or feature per pull request. This will increase the chances your feature will be merged. ###### Suggested git workflow to contribute 1. Fork the XLPagerTabStrip repository. 2. Clone your forked project into your developer machine: `git clone git@github.com:/XLPagerTabStrip.git` 3. Add the original project repo as upstream repository in your forked project: `git remote add upstream git@github.com:xmartlabs/XLPagerTabStrip.git` 4. Before starting a new feature make sure your forked master branch is synchronized upstream master branch. Considering you do not mere your pull request into master you can run: `git checkout master` and then `git pull upstream master`. Optionally `git push origin master`. 5. Create a new branch. Note that the starting point is the upstream master branch HEAD. `git checkout -b my-feature-name` 6. Stage all your changes `git add .` and commit them `git commit -m "Your commit message"` 7. Make sure your branch is up to date with upstream master, `git pull --rebase upstream master`, resolve conflicts if necessary. This will move your commit to the top of git stack. 8. Squash your commits into one commit. `git rebase -i HEAD~6` considering you did 6 commits. 9. Push your branch into your forked remote repository. 10. Create a new pull request adding any useful comment. ###### Code style and conventions We try to follow our [swift style guide](https://github.com/xmartlabs/Swift-Style-Guide). Following it is not strictly necessary to contribute and to have a pull request accepted but project maintainers try to follow it. We would love to hear your ideas to improve our code style and conventions. Feel free to contribute. ### Feature proposal We would love to hear your ideas and make a discussions about it. * Use github issues to make feature proposals. * We use `type: feature request` label to mark all [feature request issues](https://github.com/xmartlabs/XLPagerTabStrip/labels/type%3A%20feature%20request). * Before submitting your proposal make sure there is no similar feature request. If you found a match feel free to join the discussion or just add a brief "+1" if you think the feature is worth implementing. * Be as specific as possible providing a precise explanation of feature request so anyone can understand the problem and the benefits of solving it. ================================================ FILE: Cartfile.private ================================================ github "Quick/Quick" github "Quick/Nimble" ================================================ FILE: Example/Example/AppDelegate.swift ================================================ // // AppDelegate.swift // Example // // Copyright © 2016 Xmartlabs SRL. All rights reserved. // import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: 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) _ = YoutubeExampleViewController(nibName: nil, bundle: nil) return true } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } } ================================================ FILE: Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "size" : "20x20", "scale" : "2x" }, { "idiom" : "iphone", "size" : "20x20", "scale" : "3x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "3x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "3x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "2x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Contents.json ================================================ { "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Apu_Nahasapeemapetilon.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "Apu_Nahasapeemapetilon.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Bart_Simpsons.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "Bart_Simpsons.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Contents.json ================================================ { "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Homer_Simpsons.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "Homer_Simpsons.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Lisa_Simpsons.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "Lisa_Simpsons.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Maggie_Simpsons.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "Maggie_Simpsons.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Marge_Simpsons.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "Marge_Simpsons.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Montgomery_Burns.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "Montgomery_Burns.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Ned_Flanders.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "Ned_Flanders.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/Otto_Mann.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "Otto_Mann.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Simpsons/default-avatar.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "filename" : "default-avatar@2x.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/TabBar/Contents.json ================================================ { "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/TabBar/icon_bar.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "a_bar.png", "scale" : "1x" }, { "idiom" : "universal", "filename" : "a_bar@2x.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/TabBar/icon_button.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "a_button.png", "scale" : "1x" }, { "idiom" : "universal", "filename" : "a_button@2x.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/TabBar/icon_segmented.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "a_segmented.png", "scale" : "1x" }, { "idiom" : "universal", "filename" : "a_segmented@2x.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/TabBar/icon_twitter.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "a_twitter.png", "scale" : "1x" }, { "idiom" : "universal", "filename" : "a_twitter@2x.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Youtube/Contents.json ================================================ { "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Youtube/home.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "filename" : "home@2x.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Youtube/more_options.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "filename" : "more_options@2x.png", "scale" : "2x" }, { "idiom" : "universal", "filename" : "more_options@3x.png", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Youtube/profile.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "filename" : "profile@2x.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Youtube/search.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "filename" : "search@2x.png", "scale" : "2x" }, { "idiom" : "universal", "filename" : "search@2x-1.png", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Youtube/trending.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "filename" : "trending@2x.png", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/BarExampleViewController.swift ================================================ // BarExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class BarExampleViewController: BarPagerTabStripViewController { var isReload = false required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override func viewDidLoad() { // set up style before super view did load is executed settings.style.selectedBarBackgroundColor = .orange // - super.viewDidLoad() } // MARK: - PagerTabStripDataSource override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: "Table View") let child_2 = ChildExampleViewController(itemInfo: "View") let child_3 = TableChildExampleViewController(style: .grouped, itemInfo: "Table View 2") let child_4 = ChildExampleViewController(itemInfo: "View 2") guard isReload else { return [child_1, child_2, child_3, child_4] } var childViewControllers = [child_1, child_2, child_3, child_4] for index in childViewControllers.indices { let nElements = childViewControllers.count - index let n = (Int(arc4random()) % nElements) + index if n != index { childViewControllers.swapAt(index, n) } } let nItems = 1 + (arc4random() % 4) return Array(childViewControllers.prefix(Int(nItems))) } override func reloadPagerTabStripView() { isReload = true if arc4random() % 2 == 0 { pagerBehaviour = .progressive(skipIntermediateViewControllers: arc4random() % 2 == 0, elasticIndicatorLimit: arc4random() % 2 == 0 ) } else { pagerBehaviour = .common(skipIntermediateViewControllers: arc4random() % 2 == 0) } super.reloadPagerTabStripView() } } ================================================ FILE: Example/Example/Base.lproj/LaunchScreen.storyboard ================================================ ================================================ FILE: Example/Example/Base.lproj/Storyboard.storyboard ================================================ ================================================ FILE: Example/Example/ButtonBarExampleViewController.swift ================================================ // ButtonBarExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class ButtonBarExampleViewController: ButtonBarPagerTabStripViewController { var isReload = false override func viewDidLoad() { super.viewDidLoad() buttonBarView.selectedBar.backgroundColor = .orange buttonBarView.backgroundColor = UIColor(red: 7/255, green: 185/255, blue: 155/255, alpha: 1) } // MARK: - PagerTabStripDataSource override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: "Table View") let child_2 = ChildExampleViewController(itemInfo: "View") let child_3 = TableChildExampleViewController(style: .grouped, itemInfo: "Table View 2") let child_4 = ChildExampleViewController(itemInfo: "View 2") let child_5 = TableChildExampleViewController(style: .plain, itemInfo: "Table View 3") let child_6 = ChildExampleViewController(itemInfo: "View 3") let child_7 = TableChildExampleViewController(style: .grouped, itemInfo: "Table View 4") let child_8 = ChildExampleViewController(itemInfo: "View 4") guard isReload else { 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_5, child_6, child_7, child_8] for index in childViewControllers.indices { let nElements = childViewControllers.count - index let n = (Int(arc4random()) % nElements) + index if n != index { childViewControllers.swapAt(index, n) } } let nItems = 1 + (arc4random() % 8) return Array(childViewControllers.prefix(Int(nItems))) } override func reloadPagerTabStripView() { isReload = true if arc4random() % 2 == 0 { pagerBehaviour = .progressive(skipIntermediateViewControllers: arc4random() % 2 == 0, elasticIndicatorLimit: arc4random() % 2 == 0 ) } else { pagerBehaviour = .common(skipIntermediateViewControllers: arc4random() % 2 == 0) } super.reloadPagerTabStripView() } } ================================================ FILE: Example/Example/ChildControllers/ChildExampleViewController.swift ================================================ // ChildExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class ChildExampleViewController: UIViewController, IndicatorInfoProvider { var itemInfo: IndicatorInfo = "View" init(itemInfo: IndicatorInfo) { self.itemInfo = itemInfo super.init(nibName: nil, bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.text = "XLPagerTabStrip" view.addSubview(label) view.backgroundColor = .white view.addConstraint(NSLayoutConstraint(item: label, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0)) view.addConstraint(NSLayoutConstraint(item: label, attribute: .centerY, relatedBy: .equal, toItem: view, attribute: .centerY, multiplier: 1, constant: -50)) } // MARK: - IndicatorInfoProvider func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo { return itemInfo } } ================================================ FILE: Example/Example/ChildControllers/TableChildExampleViewController.swift ================================================ // TableChildExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class TableChildExampleViewController: UITableViewController, IndicatorInfoProvider { let cellIdentifier = "postCell" var blackTheme = false var itemInfo = IndicatorInfo(title: "View") init(style: UITableView.Style, itemInfo: IndicatorInfo) { self.itemInfo = itemInfo super.init(style: style) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() tableView.register(UINib(nibName: "PostCell", bundle: Bundle.main), forCellReuseIdentifier: cellIdentifier) tableView.estimatedRowHeight = 600.0 tableView.rowHeight = UITableView.automaticDimension tableView.allowsSelection = false if blackTheme { tableView.backgroundColor = UIColor(red: 15/255.0, green: 16/255.0, blue: 16/255.0, alpha: 1.0) } } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) tableView.reloadData() } // MARK: - UITableViewDataSource override func numberOfSections(in tableView: UITableView) -> Int { return 1 } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return DataProvider.sharedInstance.postsData.count } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 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() } return cell } // MARK: - IndicatorInfoProvider func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo { return itemInfo } } ================================================ FILE: Example/Example/Helpers/DataProvider.swift ================================================ // PostCell.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit class DataProvider { static let sharedInstance = DataProvider() lazy var postsData: NSArray = { let jsonStr = "[{\"post\":{\"id\":113,\"text\":\"We're getting fifty percent of the t-shirt sales\",\"created_at\":\"2014-04-17T00:45:40.556Z\",\"user\":{\"id\":9,\"name\":\"Lisa Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Lisa_Simpsons.png\"}}},{\"post\":{\"id\":66,\"text\":\"Eep!\",\"created_at\":\"2014-04-09T21:29:59.982Z\",\"user\":{\"id\":7,\"name\":\"Bart Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Bart_Simpsons.png\"}}},{\"post\":{\"id\":42,\"text\":\"I'm not thinking straight, why did I have that wine cooler last month?\",\"created_at\":\"2014-04-09T17:58:41.704Z\",\"user\":{\"id\":5,\"name\":\"Ned Flanders\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Ned_Flanders.png\"}}},{\"post\":{\"id\":84,\"text\":\"Son, when you participate in sporting events, it's not whether you win or lose: it's how drunk you get.\",\"created_at\":\"2014-04-03T20:21:32.119Z\",\"user\":{\"id\":8,\"name\":\"Homer Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Homer_Simpsons.png\"}}},{\"post\":{\"id\":75,\"text\":\"I'm normally not a praying man, but if you're up there, please save me Superman.\",\"created_at\":\"2014-04-03T02:04:43.053Z\",\"user\":{\"id\":8,\"name\":\"Homer Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Homer_Simpsons.png\"}}},{\"post\":{\"id\":26,\"text\":\"Homer, please get rid of that pig.\",\"created_at\":\"2014-04-02T03:48:56.381Z\",\"user\":{\"id\":3,\"name\":\"Marge Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Marge_Simpsons.png\"}}},{\"post\":{\"id\":40,\"text\":\"You sold weapon-grade plutoneum to the Iraqies without a mark up.\",\"created_at\":\"2014-03-28T05:23:24.657Z\",\"user\":{\"id\":4,\"name\":\"Montgomery Burns\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Montgomery_Burns.png\"}}},{\"post\":{\"id\":28,\"text\":\"Homer, don't say that. The way I see it, if you raised three children who can knock out and hog tie a perfect stranger you must be doing something right.\",\"created_at\":\"2014-03-22T14:24:22.408Z\",\"user\":{\"id\":3,\"name\":\"Marge Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Marge_Simpsons.png\"}}},{\"post\":{\"id\":48,\"text\":\"Hi-dilly-ho, neighborinos!\",\"created_at\":\"2014-03-21T08:39:20.764Z\",\"user\":{\"id\":5,\"name\":\"Ned Flanders\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Ned_Flanders.png\"}}},{\"post\":{\"id\":78,\"text\":\"Maybe, just once, someone will call me 'Sir' without adding, 'You're making a scene.'\",\"created_at\":\"2014-03-20T02:44:28.075Z\",\"user\":{\"id\":8,\"name\":\"Homer Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Homer_Simpsons.png\"}}},{\"post\":{\"id\":33,\"text\":\"This is the type of trickery I pay you for.\",\"created_at\":\"2014-03-18T08:25:14.507Z\",\"user\":{\"id\":4,\"name\":\"Montgomery Burns\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Montgomery_Burns.png\"}}},{\"post\":{\"id\":72,\"text\":\"Oh, so they have internet on computers now!\",\"created_at\":\"2014-03-03T19:02:56.032Z\",\"user\":{\"id\":8,\"name\":\"Homer Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Homer_Simpsons.png\"}}},{\"post\":{\"id\":1,\"text\":\"You know, I do! I mean, there comes a time in a man's life when he asks himself, 'who will float my corpse down the Ganges?'\",\"created_at\":\"2014-02-24T14:09:00.912Z\",\"user\":{\"id\":1,\"name\":\"Apu Nahasapeemapetilon\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Apu_Nahasapeemapetilon.png\"}}},{\"post\":{\"id\":62,\"text\":\"Ay Caramba!\",\"created_at\":\"2014-02-18T16:38:37.958Z\",\"user\":{\"id\":7,\"name\":\"Bart Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Bart_Simpsons.png\"}}},{\"post\":{\"id\":19,\"text\":\"Throughout the ages, the finger painter, the Play-Doh sculptor, the Lincoln Logger, stood alone against the daycare teacher of her time. She did not live to earn aproval stickers, she lived for herself, that she might achieve things that are the glory of all humanity. These are my terms. I do not care to play by any others. And now, if the jury will allow me, it's naptime.\",\"created_at\":\"2014-02-16T22:11:33.236Z\",\"user\":{\"id\":2,\"name\":\"Maggie Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Maggie_Simpsons.png\"}}},{\"post\":{\"id\":76,\"text\":\"Son, if you really want something in this life, you have to work for it. Now quiet! They're about to announce the lottery numbers.\",\"created_at\":\"2014-02-16T19:09:55.062Z\",\"user\":{\"id\":8,\"name\":\"Homer Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Homer_Simpsons.png\"}}},{\"post\":{\"id\":22,\"text\":\"Somebody throw the goddamn bomb!\",\"created_at\":\"2014-02-16T13:50:25.313Z\",\"user\":{\"id\":3,\"name\":\"Marge Simpsons\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Marge_Simpsons.png\"}}},{\"post\":{\"id\":36,\"text\":\"Oh, so mother nature needs a favor? Well, maybe she should have thought of that when she was besetting us with droughts and floods and poison monkeys.\",\"created_at\":\"2014-02-13T06:51:57.549Z\",\"user\":{\"id\":4,\"name\":\"Montgomery Burns\",\"imageURL\":\"http://obscure-refuge-3149.herokuapp.com/images/Montgomery_Burns.png\"}}}]" let jsonData = jsonStr.data(using: String.Encoding.utf8) let res = try! JSONSerialization.jsonObject(with: jsonData!, options: []) // swiftlint:disable:this force_try return res as! NSArray // swiftlint:disable:this force_cast }() } class NavController: UINavigationController { override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } } class TabBarController: UITabBarController { override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } } ================================================ FILE: Example/Example/Helpers/PostCell.swift ================================================ // PostCell.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import UIKit class PostCell: UITableViewCell { @IBOutlet weak var userImage: UIImageView! @IBOutlet weak var postName: UILabel! @IBOutlet weak var postText: UILabel! override func awakeFromNib() { super.awakeFromNib() userImage.layer.cornerRadius = 10.0 } 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 userImage.image = UIImage(named: postName.text!.replacingOccurrences(of: " ", with: "_")) } } func changeStylToBlack() { userImage?.layer.cornerRadius = 30.0 postText.text = nil postName.font = UIFont(name: "HelveticaNeue-Light", size:18) ?? .systemFont(ofSize: 18) postName.textColor = .white backgroundColor = UIColor(red: 15/255.0, green: 16/255.0, blue: 16/255.0, alpha: 1.0) } } ================================================ FILE: Example/Example/Helpers/PostCell.xib ================================================ ================================================ FILE: Example/Example/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 9.0.0 CFBundleSignature ???? CFBundleVersion 1 LSRequiresIPhoneOS UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Storyboard UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance ================================================ FILE: Example/Example/Instagram/InstagramExampleViewController.swift ================================================ // SegmentedExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class InstagramExampleViewController: ButtonBarPagerTabStripViewController { @IBOutlet weak var shadowView: UIView! let blueInstagramColor = UIColor(red: 37/255.0, green: 111/255.0, blue: 206/255.0, alpha: 1.0) override func viewDidLoad() { // change selected bar color settings.style.buttonBarBackgroundColor = .white settings.style.buttonBarItemBackgroundColor = .white settings.style.selectedBarBackgroundColor = blueInstagramColor settings.style.buttonBarItemFont = .boldSystemFont(ofSize: 14) settings.style.selectedBarHeight = 2.0 settings.style.buttonBarMinimumLineSpacing = 0 settings.style.buttonBarItemTitleColor = .black settings.style.buttonBarItemsShouldFillAvailableWidth = true settings.style.buttonBarLeftContentInset = 0 settings.style.buttonBarRightContentInset = 0 changeCurrentIndexProgressive = { [weak self] (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in guard changeCurrentIndex == true else { return } oldCell?.label.textColor = .black newCell?.label.textColor = self?.blueInstagramColor } super.viewDidLoad() } // MARK: - PagerTabStripDataSource override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: "FOLLOWING") let child_2 = ChildExampleViewController(itemInfo: "YOU") return [child_1, child_2] } // MARK: - Custom Action @IBAction func closeAction(_ sender: UIButton) { dismiss(animated: true, completion: nil) } } ================================================ FILE: Example/Example/NavButtonBarExampleViewController.swift ================================================ // NavButtonBarExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class NavButtonBarExampleViewController: ButtonBarPagerTabStripViewController { var isReload = false override func viewDidLoad() { // set up style before super view did load is executed settings.style.buttonBarBackgroundColor = .clear settings.style.selectedBarBackgroundColor = .orange //- super.viewDidLoad() buttonBarView.removeFromSuperview() navigationController?.navigationBar.addSubview(buttonBarView) changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in guard changeCurrentIndex == true else { return } oldCell?.label.textColor = UIColor(white: 1, alpha: 0.6) newCell?.label.textColor = .white if animated { UIView.animate(withDuration: 0.1, animations: { () -> Void in newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) }) } else { newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) } } } // MARK: - PagerTabStripDataSource override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: "Table View") let child_2 = ChildExampleViewController(itemInfo: "View") let child_3 = TableChildExampleViewController(style: .grouped, itemInfo: "Table View 2") let child_4 = ChildExampleViewController(itemInfo: "View 1") let child_5 = TableChildExampleViewController(style: .plain, itemInfo: "Table View 3") let child_6 = ChildExampleViewController(itemInfo: "View 2") let child_7 = TableChildExampleViewController(style: .grouped, itemInfo: "Table View 4") let child_8 = ChildExampleViewController(itemInfo: "View 3") guard isReload else { 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_5, child_6, child_7, child_8] for index in childViewControllers.indices { let nElements = childViewControllers.count - index let n = (Int(arc4random()) % nElements) + index if n != index { childViewControllers.swapAt(index, n) } } let nItems = 1 + (arc4random() % 8) return Array(childViewControllers.prefix(Int(nItems))) } override func reloadPagerTabStripView() { isReload = true if arc4random() % 2 == 0 { pagerBehaviour = .progressive(skipIntermediateViewControllers: arc4random() % 2 == 0, elasticIndicatorLimit: arc4random() % 2 == 0 ) } else { pagerBehaviour = .common(skipIntermediateViewControllers: arc4random() % 2 == 0) } super.reloadPagerTabStripView() } override func configureCell(_ cell: ButtonBarViewCell, indicatorInfo: IndicatorInfo) { super.configureCell(cell, indicatorInfo: indicatorInfo) cell.backgroundColor = .clear } } ================================================ FILE: Example/Example/ReloadExampleViewController.swift ================================================ // ReloadExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import UIKit import XLPagerTabStrip class ReloadExampleViewController: UIViewController { @IBOutlet lazy var titleLabel: UILabel! = { let label = UILabel() return label }() lazy var bigLabel: UILabel = { let bigLabel = UILabel() bigLabel.backgroundColor = .clear bigLabel.textColor = .white bigLabel.font = UIFont.boldSystemFont(ofSize: 20) bigLabel.adjustsFontSizeToFitWidth = true return bigLabel }() override func viewDidLoad() { super.viewDidLoad() if navigationController != nil { navigationItem.titleView = bigLabel bigLabel.sizeToFit() } if let pagerViewController = children.first as? PagerTabStripViewController { updateTitle(of: pagerViewController) } } @IBAction func reloadTapped(_ sender: UIBarButtonItem) { for childViewController in children { guard let child = childViewController as? PagerTabStripViewController else { continue } child.reloadPagerTabStripView() updateTitle(of: child) break } } @IBAction func closeTapped(_ sender: UIButton) { dismiss(animated: true, completion: nil) } func updateTitle(of pagerTabStripViewController: PagerTabStripViewController) { func stringFromBool(_ bool: Bool) -> String { return bool ? "YES" : "NO" } titleLabel.text = "Progressive = \(stringFromBool(pagerTabStripViewController.pagerBehaviour.isProgressiveIndicator)) ElasticLimit = \(stringFromBool(pagerTabStripViewController.pagerBehaviour.isElasticIndicatorLimit))" (navigationItem.titleView as? UILabel)?.text = titleLabel.text navigationItem.titleView?.sizeToFit() } override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } } ================================================ FILE: Example/Example/SegmentedExampleViewController.swift ================================================ // SegmentedExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class SegmentedExampleViewController: SegmentedPagerTabStripViewController { var isReload = false required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) // change segmented style settings.style.segmentedControlColor = .white } // MARK: - PagerTabStripDataSource override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: "Table View") let child_2 = ChildExampleViewController(itemInfo: "View") let child_3 = TableChildExampleViewController(style: .grouped, itemInfo: "Table View 2") let child_4 = ChildExampleViewController(itemInfo: "View 2") guard isReload else { return [child_1, child_2, child_3, child_4] } var childViewControllers = [child_1, child_2, child_3, child_4] let count = childViewControllers.count for index in childViewControllers.indices { let nElements = count - index let n = (Int(arc4random()) % nElements) + index if n != index { childViewControllers.swapAt(index, n) } } let nItems = 1 + (arc4random() % 4) return Array(childViewControllers.prefix(Int(nItems))) } @IBAction func reloadTapped(_ sender: UIBarButtonItem) { isReload = true pagerBehaviour = .common(skipIntermediateViewControllers: arc4random() % 2 == 0) reloadPagerTabStripView() } } ================================================ FILE: Example/Example/Spotify/SpotifyExampleViewController.swift ================================================ // SpotifyExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class SpotifyExampleViewController: ButtonBarPagerTabStripViewController { @IBOutlet weak var shadowView: UIView! let graySpotifyColor = UIColor(red: 21/255.0, green: 21/255.0, blue: 24/255.0, alpha: 1.0) let darkGraySpotifyColor = UIColor(red: 19/255.0, green: 20/255.0, blue: 20/255.0, alpha: 1.0) override func viewDidLoad() { // change selected bar color settings.style.buttonBarBackgroundColor = graySpotifyColor settings.style.buttonBarItemBackgroundColor = graySpotifyColor settings.style.selectedBarBackgroundColor = UIColor(red: 33/255.0, green: 174/255.0, blue: 67/255.0, alpha: 1.0) settings.style.buttonBarItemFont = UIFont(name: "HelveticaNeue-Light", size:14) ?? UIFont.systemFont(ofSize: 14) settings.style.selectedBarHeight = 3.0 settings.style.buttonBarMinimumLineSpacing = 0 settings.style.buttonBarItemTitleColor = .black settings.style.buttonBarItemsShouldFillAvailableWidth = true settings.style.buttonBarLeftContentInset = 20 settings.style.buttonBarRightContentInset = 20 changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in guard changeCurrentIndex == true else { return } oldCell?.label.textColor = UIColor(red: 138/255.0, green: 138/255.0, blue: 144/255.0, alpha: 1.0) newCell?.label.textColor = .white } super.viewDidLoad() } // MARK: - PagerTabStripDataSource override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: "FRIENDS")) child_1.blackTheme = true let child_2 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: "FEATURED")) child_2.blackTheme = true return [child_1, child_2] } // MARK: - Actions @IBAction func closeAction(_ sender: UIButton) { dismiss(animated: true, completion: nil) } } ================================================ FILE: Example/Example/TwitterExampleViewController.swift ================================================ // TwitterExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class TwitterExampleViewController: TwitterPagerTabStripViewController { var isReload = false override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: "TableView") let child_2 = ChildExampleViewController(itemInfo: "View") let child_3 = TableChildExampleViewController(style: .grouped, itemInfo: "TableView 2") let child_4 = ChildExampleViewController(itemInfo: "View 2") let child_5 = TableChildExampleViewController(style: .plain, itemInfo: "TableView 3") let child_6 = ChildExampleViewController(itemInfo: "View 3") let child_7 = TableChildExampleViewController(style: .grouped, itemInfo: "TableView 4") let child_8 = ChildExampleViewController(itemInfo: "View 4") guard isReload else { 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_5, child_6, child_7, child_8] for index in childViewControllers.indices { let nElements = childViewControllers.count - index let n = (Int(arc4random()) % nElements) + index if n != index { childViewControllers.swapAt(index, n) } } let nItems = 1 + (arc4random() % 8) return Array(childViewControllers.prefix(Int(nItems))) } @IBAction func reloadTapped(_ sender: AnyObject) { isReload = true reloadPagerTabStripView() } } ================================================ FILE: Example/Example/Youtube/YoutubeExampleViewController.swift ================================================ // YoutubeExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class YoutubeExampleViewController: BaseButtonBarPagerTabStripViewController { 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) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) buttonBarItemSpec = ButtonBarItemSpec.nibFile(nibName: "YoutubeIconCell", bundle: Bundle(for: YoutubeIconCell.self), width: { _ in return 55.0 }) } override func viewDidLoad() { // change selected bar color settings.style.buttonBarBackgroundColor = redColor settings.style.buttonBarItemBackgroundColor = .clear settings.style.selectedBarBackgroundColor = UIColor(red: 234/255.0, green: 234/255.0, blue: 234/255.0, alpha: 1.0) settings.style.selectedBarHeight = 4.0 settings.style.buttonBarMinimumLineSpacing = 0 settings.style.buttonBarItemTitleColor = .black settings.style.buttonBarItemsShouldFillAvailableWidth = true 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() navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) } // MARK: - PagerTabStripDataSource override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: " HOME", image: UIImage(named: "home"))) let child_2 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: " TRENDING", image: UIImage(named: "trending"))) let child_3 = ChildExampleViewController(itemInfo: IndicatorInfo(title: " ACCOUNT", image: UIImage(named: "profile"))) return [child_1, child_2, child_3] } override func configure(cell: YoutubeIconCell, for indicatorInfo: IndicatorInfo) { cell.iconImage.image = indicatorInfo.image?.withRenderingMode(.alwaysTemplate) } 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 // 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 }) } } // MARK: - Actions @IBAction func closeAction(_ sender: UIButton) { dismiss(animated: true, completion: nil) } } ================================================ FILE: Example/Example/Youtube/YoutubeIconCell.swift ================================================ // YoutubeIconCell.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit class YoutubeIconCell: UICollectionViewCell { @IBOutlet weak var iconImage: UIImageView! } ================================================ FILE: Example/Example/Youtube/YoutubeIconCell.xib ================================================ ================================================ FILE: Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.swift ================================================ // YoutubeIconWithLabelCell.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit class YoutubeIconWithLabelCell: UICollectionViewCell { @IBOutlet weak var iconImage: UIImageView! @IBOutlet weak var iconLabel: UILabel! } ================================================ FILE: Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.xib ================================================ ================================================ FILE: Example/Example/YoutubeWithLabel/YoutubeWithLabelExampleViewController.swift ================================================ // YoutubeWithLabelExampleViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import XLPagerTabStrip class YoutubeWithLabelExampleViewController: BaseButtonBarPagerTabStripViewController { 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) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) buttonBarItemSpec = ButtonBarItemSpec.nibFile(nibName: "YoutubeIconWithLabelCell", bundle: Bundle(for: YoutubeIconWithLabelCell.self), width: { _ in return 70.0 }) } override func viewDidLoad() { // change selected bar color settings.style.buttonBarBackgroundColor = redColor settings.style.buttonBarItemBackgroundColor = .clear settings.style.selectedBarBackgroundColor = UIColor(red: 234/255.0, green: 234/255.0, blue: 234/255.0, alpha: 1.0) settings.style.selectedBarHeight = 4.0 settings.style.buttonBarMinimumLineSpacing = 0 settings.style.buttonBarItemTitleColor = .black settings.style.buttonBarItemsShouldFillAvailableWidth = true settings.style.buttonBarLeftContentInset = 0 settings.style.buttonBarRightContentInset = 0 changeCurrentIndexProgressive = { [weak self] (oldCell: YoutubeIconWithLabelCell?, newCell: YoutubeIconWithLabelCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in guard changeCurrentIndex == true else { return } oldCell?.iconImage.tintColor = self?.unselectedIconColor oldCell?.iconLabel.textColor = self?.unselectedIconColor newCell?.iconImage.tintColor = .white newCell?.iconLabel.textColor = .white } super.viewDidLoad() navigationController?.navigationBar.shadowImage = UIImage() navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) } // MARK: - PagerTabStripDataSource override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: " HOME", image: UIImage(named: "home"))) let child_2 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: " TRENDING", image: UIImage(named: "trending"))) let child_3 = ChildExampleViewController(itemInfo: IndicatorInfo(title: " ACCOUNT", image: UIImage(named: "profile"))) return [child_1, child_2, child_3] } override func configure(cell: YoutubeIconWithLabelCell, for indicatorInfo: IndicatorInfo) { cell.iconImage.image = indicatorInfo.image?.withRenderingMode(.alwaysTemplate) cell.iconLabel.text = indicatorInfo.title?.trimmingCharacters(in: .whitespacesAndNewlines) } 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 // 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 }) } } // MARK: - Actions @IBAction func closeAction(_ sender: UIButton) { dismiss(animated: true, completion: nil) } } ================================================ FILE: Example/ExampleUITests/ExampleUITests.swift ================================================ // // ExampleUITests.swift // ExampleUITests // // Copyright © 2016 Xmartlabs SRL. All rights reserved. // import XCTest class ExampleUITests: XCTestCase { override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. // In UI tests it is usually best to stop immediately when a failure occurs. continueAfterFailure = false // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. XCUIApplication().launch() // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. } override func tearDown() { // Put teardown code here. This method is called after the invocation of each test method in the class. super.tearDown() } func testExample() { // Use recording to get started writing UI tests. // Use XCTAssert and related functions to verify your tests produce the correct results. } } ================================================ FILE: Example/ExampleUITests/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType BNDL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1 ================================================ FILE: Example.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 1F081A9E1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F081A9B1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift */; }; 1F081A9F1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1F081A9C1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib */; }; 1F081AA01FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F081A9D1FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift */; }; 285718181C568336004D7E7B /* DataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285718171C568336004D7E7B /* DataProvider.swift */; }; 285DA2881C569AA2000908CA /* ChildExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285DA2861C569AA2000908CA /* ChildExampleViewController.swift */; }; 285DA2891C569AA2000908CA /* TableChildExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285DA2871C569AA2000908CA /* TableChildExampleViewController.swift */; }; 285DA28C1C592154000908CA /* InstagramExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285DA28B1C592154000908CA /* InstagramExampleViewController.swift */; }; 285DA2901C59C587000908CA /* SpotifyExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285DA28F1C59C587000908CA /* SpotifyExampleViewController.swift */; }; 285DA2931C5A596B000908CA /* YoutubeExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285DA2921C5A596B000908CA /* YoutubeExampleViewController.swift */; }; 285DA2951C5A6A00000908CA /* YoutubeIconCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285DA2941C5A6A00000908CA /* YoutubeIconCell.swift */; }; 285DA2971C5A6A36000908CA /* YoutubeIconCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 285DA2961C5A6A36000908CA /* YoutubeIconCell.xib */; }; 287D0A721C4B7877004566D6 /* ExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 287D0A711C4B7877004566D6 /* ExampleUITests.swift */; }; 287D0A7D1C4B7B55004566D6 /* XLPagerTabStrip.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 287D0A7A1C4B7B26004566D6 /* XLPagerTabStrip.framework */; }; 287D0A7E1C4B7B55004566D6 /* XLPagerTabStrip.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 287D0A7A1C4B7B26004566D6 /* XLPagerTabStrip.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 28F828D01C4B714D00330CF4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28F828CF1C4B714D00330CF4 /* AppDelegate.swift */; }; CB2125DE1C52A80E002DAF42 /* TwitterExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB2125DD1C52A80E002DAF42 /* TwitterExampleViewController.swift */; }; CB3697BF1C5177B4001FC5F8 /* ButtonBarExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB3697BE1C5177B4001FC5F8 /* ButtonBarExampleViewController.swift */; }; CB71C6EB1C4EB964008EC806 /* SegmentedExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB71C6EA1C4EB964008EC806 /* SegmentedExampleViewController.swift */; }; CB71C6F31C4FDDCE008EC806 /* PostCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB71C6F21C4FDDCE008EC806 /* PostCell.swift */; }; CB86ED801C4D6F0D00DA463B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CB86ED6F1C4D6F0D00DA463B /* Assets.xcassets */; }; CB86ED811C4D6F0D00DA463B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CB86ED711C4D6F0D00DA463B /* LaunchScreen.storyboard */; }; CB86ED941C4E89DD00DA463B /* PostCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CB86ED931C4E89DD00DA463B /* PostCell.xib */; }; CBA0A1FF1C50304500C5748C /* BarExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBA0A1FE1C50304500C5748C /* BarExampleViewController.swift */; }; CBA0A2021C5032E100C5748C /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CBA0A2011C5032E100C5748C /* Storyboard.storyboard */; }; CBA0A2041C5033B400C5748C /* ReloadExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBA0A2031C5033B400C5748C /* ReloadExampleViewController.swift */; }; CBBD435F1C5274AE001A748E /* NavButtonBarExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBBD435E1C5274AE001A748E /* NavButtonBarExampleViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 287D0A791C4B7B26004566D6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 287D0A741C4B7B26004566D6 /* XLPagerTabStrip.xcodeproj */; proxyType = 2; remoteGlobalIDString = 28F8287D1C494B2C00330CF4; remoteInfo = XLPagerTabStrip; }; 287D0A7B1C4B7B26004566D6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 287D0A741C4B7B26004566D6 /* XLPagerTabStrip.xcodeproj */; proxyType = 2; remoteGlobalIDString = 28F828871C494B2C00330CF4; remoteInfo = XLPagerTabStripTests; }; 287D0A7F1C4B7B55004566D6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 287D0A741C4B7B26004566D6 /* XLPagerTabStrip.xcodeproj */; proxyType = 1; remoteGlobalIDString = 28F8287C1C494B2C00330CF4; remoteInfo = XLPagerTabStrip; }; 28F828E11C4B714D00330CF4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 28F828C41C4B714D00330CF4 /* Project object */; proxyType = 1; remoteGlobalIDString = 28F828CB1C4B714D00330CF4; remoteInfo = Example; }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ 287D0A811C4B7B55004566D6 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 10; files = ( 287D0A7E1C4B7B55004566D6 /* XLPagerTabStrip.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ 1F081A9B1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YoutubeIconWithLabelCell.swift; sourceTree = ""; }; 1F081A9C1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = YoutubeIconWithLabelCell.xib; sourceTree = ""; }; 1F081A9D1FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YoutubeWithLabelExampleViewController.swift; sourceTree = ""; }; 285718171C568336004D7E7B /* DataProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DataProvider.swift; path = Example/Helpers/DataProvider.swift; sourceTree = ""; }; 285DA2861C569AA2000908CA /* ChildExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChildExampleViewController.swift; path = Example/ChildControllers/ChildExampleViewController.swift; sourceTree = ""; }; 285DA2871C569AA2000908CA /* TableChildExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TableChildExampleViewController.swift; path = Example/ChildControllers/TableChildExampleViewController.swift; sourceTree = ""; }; 285DA28B1C592154000908CA /* InstagramExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InstagramExampleViewController.swift; path = Example/Instagram/InstagramExampleViewController.swift; sourceTree = ""; }; 285DA28F1C59C587000908CA /* SpotifyExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotifyExampleViewController.swift; sourceTree = ""; }; 285DA2921C5A596B000908CA /* YoutubeExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YoutubeExampleViewController.swift; path = Example/Youtube/YoutubeExampleViewController.swift; sourceTree = ""; }; 285DA2941C5A6A00000908CA /* YoutubeIconCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YoutubeIconCell.swift; path = Example/Youtube/YoutubeIconCell.swift; sourceTree = ""; }; 285DA2961C5A6A36000908CA /* YoutubeIconCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = YoutubeIconCell.xib; path = Example/Youtube/YoutubeIconCell.xib; sourceTree = ""; }; 287D0A711C4B7877004566D6 /* ExampleUITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExampleUITests.swift; path = Example/ExampleUITests/ExampleUITests.swift; sourceTree = SOURCE_ROOT; }; 287D0A741C4B7B26004566D6 /* XLPagerTabStrip.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = XLPagerTabStrip.xcodeproj; sourceTree = ""; }; 28F828CC1C4B714D00330CF4 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 28F828CF1C4B714D00330CF4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = Example/AppDelegate.swift; sourceTree = ""; }; 28F828DB1C4B714D00330CF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Example/Info.plist; sourceTree = ""; }; 28F828E01C4B714D00330CF4 /* ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 28F828E61C4B714D00330CF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; CB2125DD1C52A80E002DAF42 /* TwitterExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TwitterExampleViewController.swift; path = Example/TwitterExampleViewController.swift; sourceTree = ""; }; CB3697BE1C5177B4001FC5F8 /* ButtonBarExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ButtonBarExampleViewController.swift; path = Example/Example/ButtonBarExampleViewController.swift; sourceTree = SOURCE_ROOT; }; CB71C6EA1C4EB964008EC806 /* SegmentedExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SegmentedExampleViewController.swift; path = Example/SegmentedExampleViewController.swift; sourceTree = ""; }; CB71C6F21C4FDDCE008EC806 /* PostCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PostCell.swift; path = Example/Helpers/PostCell.swift; sourceTree = ""; }; CB86ED6F1C4D6F0D00DA463B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Example/Assets.xcassets; sourceTree = ""; }; CB86ED721C4D6F0D00DA463B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = LaunchScreen.storyboard; sourceTree = ""; }; CB86ED931C4E89DD00DA463B /* PostCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = PostCell.xib; path = Example/Helpers/PostCell.xib; sourceTree = ""; }; CBA0A1FE1C50304500C5748C /* BarExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BarExampleViewController.swift; path = Example/BarExampleViewController.swift; sourceTree = ""; }; CBA0A2011C5032E100C5748C /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard.storyboard; sourceTree = ""; }; CBA0A2031C5033B400C5748C /* ReloadExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ReloadExampleViewController.swift; path = Example/ReloadExampleViewController.swift; sourceTree = ""; }; CBBD435E1C5274AE001A748E /* NavButtonBarExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NavButtonBarExampleViewController.swift; path = Example/NavButtonBarExampleViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 28F828C91C4B714D00330CF4 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 287D0A7D1C4B7B55004566D6 /* XLPagerTabStrip.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 28F828DD1C4B714D00330CF4 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 1F081A9A1FDABD1400B881EB /* YoutubeWithLabel */ = { isa = PBXGroup; children = ( 1F081A9B1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift */, 1F081A9C1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib */, 1F081A9D1FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift */, ); name = YoutubeWithLabel; path = Example/YoutubeWithLabel; sourceTree = ""; }; 285718151C568285004D7E7B /* Helpers */ = { isa = PBXGroup; children = ( CB86ED931C4E89DD00DA463B /* PostCell.xib */, CB71C6F21C4FDDCE008EC806 /* PostCell.swift */, 285718171C568336004D7E7B /* DataProvider.swift */, ); name = Helpers; sourceTree = ""; }; 285DA2841C569A3E000908CA /* ChildControllers */ = { isa = PBXGroup; children = ( 285DA2861C569AA2000908CA /* ChildExampleViewController.swift */, 285DA2871C569AA2000908CA /* TableChildExampleViewController.swift */, ); name = ChildControllers; sourceTree = ""; }; 285DA28A1C59210F000908CA /* Instagram */ = { isa = PBXGroup; children = ( 285DA28B1C592154000908CA /* InstagramExampleViewController.swift */, ); name = "Instagram "; sourceTree = ""; }; 285DA28E1C59C587000908CA /* Spotify */ = { isa = PBXGroup; children = ( 285DA28F1C59C587000908CA /* SpotifyExampleViewController.swift */, ); name = Spotify; path = Example/Spotify; sourceTree = ""; }; 285DA2911C5A5945000908CA /* Youtube */ = { isa = PBXGroup; children = ( 285DA2921C5A596B000908CA /* YoutubeExampleViewController.swift */, 285DA2941C5A6A00000908CA /* YoutubeIconCell.swift */, 285DA2961C5A6A36000908CA /* YoutubeIconCell.xib */, ); name = Youtube; sourceTree = ""; }; 287D0A751C4B7B26004566D6 /* Products */ = { isa = PBXGroup; children = ( 287D0A7A1C4B7B26004566D6 /* XLPagerTabStrip.framework */, 287D0A7C1C4B7B26004566D6 /* XLPagerTabStripTests.xctest */, ); name = Products; sourceTree = ""; }; 28F828C31C4B714D00330CF4 = { isa = PBXGroup; children = ( 28F828CE1C4B714D00330CF4 /* Example */, 28F828E31C4B714D00330CF4 /* ExampleUITests */, 28F828CD1C4B714D00330CF4 /* Products */, 287D0A741C4B7B26004566D6 /* XLPagerTabStrip.xcodeproj */, ); sourceTree = ""; }; 28F828CD1C4B714D00330CF4 /* Products */ = { isa = PBXGroup; children = ( 28F828CC1C4B714D00330CF4 /* Example.app */, 28F828E01C4B714D00330CF4 /* ExampleUITests.xctest */, ); name = Products; sourceTree = ""; }; 28F828CE1C4B714D00330CF4 /* Example */ = { isa = PBXGroup; children = ( CB86ED6C1C4D6ED400DA463B /* Demo */, 28F828CF1C4B714D00330CF4 /* AppDelegate.swift */, 28F828DB1C4B714D00330CF4 /* Info.plist */, ); path = Example; sourceTree = ""; }; 28F828E31C4B714D00330CF4 /* ExampleUITests */ = { isa = PBXGroup; children = ( 28F828E61C4B714D00330CF4 /* Info.plist */, 287D0A711C4B7877004566D6 /* ExampleUITests.swift */, ); name = ExampleUITests; path = Example/ExampleUITests; sourceTree = ""; }; CB86ED6C1C4D6ED400DA463B /* Demo */ = { isa = PBXGroup; children = ( 1F081A9A1FDABD1400B881EB /* YoutubeWithLabel */, 285DA2911C5A5945000908CA /* Youtube */, 285DA28E1C59C587000908CA /* Spotify */, 285DA28A1C59210F000908CA /* Instagram */, 285DA2841C569A3E000908CA /* ChildControllers */, 285718151C568285004D7E7B /* Helpers */, CB86ED701C4D6F0D00DA463B /* Base.lproj */, CB86ED6F1C4D6F0D00DA463B /* Assets.xcassets */, CB71C6EA1C4EB964008EC806 /* SegmentedExampleViewController.swift */, CB3697BE1C5177B4001FC5F8 /* ButtonBarExampleViewController.swift */, CBA0A1FE1C50304500C5748C /* BarExampleViewController.swift */, CBA0A2031C5033B400C5748C /* ReloadExampleViewController.swift */, CBBD435E1C5274AE001A748E /* NavButtonBarExampleViewController.swift */, CB2125DD1C52A80E002DAF42 /* TwitterExampleViewController.swift */, ); name = Demo; sourceTree = ""; }; CB86ED701C4D6F0D00DA463B /* Base.lproj */ = { isa = PBXGroup; children = ( CBA0A2011C5032E100C5748C /* Storyboard.storyboard */, CB86ED711C4D6F0D00DA463B /* LaunchScreen.storyboard */, ); name = Base.lproj; path = Example/Base.lproj; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ 28F828CB1C4B714D00330CF4 /* Example */ = { isa = PBXNativeTarget; buildConfigurationList = 28F828E91C4B714D00330CF4 /* Build configuration list for PBXNativeTarget "Example" */; buildPhases = ( 28F828C81C4B714D00330CF4 /* Sources */, 28F828C91C4B714D00330CF4 /* Frameworks */, 28F828CA1C4B714D00330CF4 /* Resources */, 287D0A811C4B7B55004566D6 /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( 287D0A801C4B7B55004566D6 /* PBXTargetDependency */, ); name = Example; productName = Example; productReference = 28F828CC1C4B714D00330CF4 /* Example.app */; productType = "com.apple.product-type.application"; }; 28F828DF1C4B714D00330CF4 /* ExampleUITests */ = { isa = PBXNativeTarget; buildConfigurationList = 28F828EC1C4B714D00330CF4 /* Build configuration list for PBXNativeTarget "ExampleUITests" */; buildPhases = ( 28F828DC1C4B714D00330CF4 /* Sources */, 28F828DD1C4B714D00330CF4 /* Frameworks */, 28F828DE1C4B714D00330CF4 /* Resources */, ); buildRules = ( ); dependencies = ( 28F828E21C4B714D00330CF4 /* PBXTargetDependency */, ); name = ExampleUITests; productName = ExampleUITests; productReference = 28F828E01C4B714D00330CF4 /* ExampleUITests.xctest */; productType = "com.apple.product-type.bundle.ui-testing"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 28F828C41C4B714D00330CF4 /* Project object */ = { isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; LastUpgradeCheck = 1020; TargetAttributes = { 28F828CB1C4B714D00330CF4 = { CreatedOnToolsVersion = 7.2; LastSwiftMigration = 1020; }; 28F828DF1C4B714D00330CF4 = { CreatedOnToolsVersion = 7.2; LastSwiftMigration = 1020; TestTargetID = 28F828CB1C4B714D00330CF4; }; }; }; buildConfigurationList = 28F828C71C4B714D00330CF4 /* Build configuration list for PBXProject "Example" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); mainGroup = 28F828C31C4B714D00330CF4; productRefGroup = 28F828CD1C4B714D00330CF4 /* Products */; projectDirPath = ""; projectReferences = ( { ProductGroup = 287D0A751C4B7B26004566D6 /* Products */; ProjectRef = 287D0A741C4B7B26004566D6 /* XLPagerTabStrip.xcodeproj */; }, ); projectRoot = ""; targets = ( 28F828CB1C4B714D00330CF4 /* Example */, 28F828DF1C4B714D00330CF4 /* ExampleUITests */, ); }; /* End PBXProject section */ /* Begin PBXReferenceProxy section */ 287D0A7A1C4B7B26004566D6 /* XLPagerTabStrip.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; path = XLPagerTabStrip.framework; remoteRef = 287D0A791C4B7B26004566D6 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 287D0A7C1C4B7B26004566D6 /* XLPagerTabStripTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = XLPagerTabStripTests.xctest; remoteRef = 287D0A7B1C4B7B26004566D6 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ 28F828CA1C4B714D00330CF4 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( CB86ED801C4D6F0D00DA463B /* Assets.xcassets in Resources */, CB86ED941C4E89DD00DA463B /* PostCell.xib in Resources */, CBA0A2021C5032E100C5748C /* Storyboard.storyboard in Resources */, 1F081A9F1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib in Resources */, CB86ED811C4D6F0D00DA463B /* LaunchScreen.storyboard in Resources */, 285DA2971C5A6A36000908CA /* YoutubeIconCell.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 28F828DE1C4B714D00330CF4 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 28F828C81C4B714D00330CF4 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 285DA28C1C592154000908CA /* InstagramExampleViewController.swift in Sources */, CB71C6EB1C4EB964008EC806 /* SegmentedExampleViewController.swift in Sources */, 28F828D01C4B714D00330CF4 /* AppDelegate.swift in Sources */, CBA0A2041C5033B400C5748C /* ReloadExampleViewController.swift in Sources */, 285DA2901C59C587000908CA /* SpotifyExampleViewController.swift in Sources */, CB3697BF1C5177B4001FC5F8 /* ButtonBarExampleViewController.swift in Sources */, 285DA2881C569AA2000908CA /* ChildExampleViewController.swift in Sources */, CBA0A1FF1C50304500C5748C /* BarExampleViewController.swift in Sources */, 285718181C568336004D7E7B /* DataProvider.swift in Sources */, CB2125DE1C52A80E002DAF42 /* TwitterExampleViewController.swift in Sources */, 285DA2891C569AA2000908CA /* TableChildExampleViewController.swift in Sources */, 1F081A9E1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift in Sources */, CBBD435F1C5274AE001A748E /* NavButtonBarExampleViewController.swift in Sources */, CB71C6F31C4FDDCE008EC806 /* PostCell.swift in Sources */, 285DA2931C5A596B000908CA /* YoutubeExampleViewController.swift in Sources */, 285DA2951C5A6A00000908CA /* YoutubeIconCell.swift in Sources */, 1F081AA01FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 28F828DC1C4B714D00330CF4 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 287D0A721C4B7877004566D6 /* ExampleUITests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 287D0A801C4B7B55004566D6 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = XLPagerTabStrip; targetProxy = 287D0A7F1C4B7B55004566D6 /* PBXContainerItemProxy */; }; 28F828E21C4B714D00330CF4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 28F828CB1C4B714D00330CF4 /* Example */; targetProxy = 28F828E11C4B714D00330CF4 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ CB86ED711C4D6F0D00DA463B /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( CB86ED721C4D6F0D00DA463B /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 28F828E71C4B714D00330CF4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 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_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = 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; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.3; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; 28F828E81C4B714D00330CF4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 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_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = 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; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; }; 28F828EA1C4B714D00330CF4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = "$(SRCROOT)/Example/Example/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; }; name = Debug; }; 28F828EB1C4B714D00330CF4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = "$(SRCROOT)/Example/Example/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_VERSION = 5.0; }; name = Release; }; 28F828ED1C4B714D00330CF4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = Example/ExampleUITests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.ExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TEST_TARGET_NAME = Example; USES_XCTRUNNER = YES; }; name = Debug; }; 28F828EE1C4B714D00330CF4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = Example/ExampleUITests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.ExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_TARGET_NAME = Example; USES_XCTRUNNER = YES; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 28F828C71C4B714D00330CF4 /* Build configuration list for PBXProject "Example" */ = { isa = XCConfigurationList; buildConfigurations = ( 28F828E71C4B714D00330CF4 /* Debug */, 28F828E81C4B714D00330CF4 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 28F828E91C4B714D00330CF4 /* Build configuration list for PBXNativeTarget "Example" */ = { isa = XCConfigurationList; buildConfigurations = ( 28F828EA1C4B714D00330CF4 /* Debug */, 28F828EB1C4B714D00330CF4 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 28F828EC1C4B714D00330CF4 /* Build configuration list for PBXNativeTarget "ExampleUITests" */ = { isa = XCConfigurationList; buildConfigurations = ( 28F828ED1C4B714D00330CF4 /* Debug */, 28F828EE1C4B714D00330CF4 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 28F828C41C4B714D00330CF4 /* Project object */; } ================================================ FILE: Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2019 Xmartlabs SRL Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: Migration.md ================================================ ## How to migrate from Swift 2 to Swift 3 To migrate from Swift 2 to Swift 3 you have to change the naming of some of the functions you call or override. These are the name changes for version 6.0+ in `PagerTabStripViewController`: | Swift 2 function name | Swift 3 function name | | --------------------- | --------------------- | | `func viewControllersForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> [UIViewController]` | `func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController]` | | `func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo` | `func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo` | | `func pagerTabStripViewController(_ pagerTabStripViewController: PagerTabStripViewController, updateIndicatorFromIndex fromIndex: Int, toIndex: Int)` | `func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int)` | | `func pagerTabStripViewController(_ pagerTabStripViewController: PagerTabStripViewController, updateIndicatorFromIndex fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool)` | `func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool)` | | `func moveToViewControllerAtIndex(_ index: Int, animated: Bool = true)` | `func moveToViewController(at index: Int, animated: Bool = true)` | | `func moveToViewController(_ viewController: UIViewController, animated: Bool = true)` | `func moveTo(viewController: UIViewController, animated: Bool = true)` | | `func canMoveToIndex(index: Int) -> Bool` | `func canMoveTo(index: Int) -> Bool` | | ` func pageOffsetForChildIndex(index: Int) -> CGFloat` | `func pageOffsetForChild(at index: Int) -> CGFloat` | | `func offsetForChildIndex(_ index: Int) -> CGFloat` | `func offsetForChild(at index: Int) -> CGFloat` | | `func offsetForChildViewController(_ viewController: UIViewController) throws -> CGFloat` | `func offsetForChild(viewController: UIViewController) throws -> CGFloat` | | `func pageForContentOffset(_ contentOffset: CGFloat) -> Int` | `func pageFor(contentOffset: CGFloat) -> Int` | | `func virtualPageForContentOffset(_ contentOffset: CGFloat) -> Int` | `func virtualPageFor(contentOffset: CGFloat) -> Int` | | `func pageForVirtualPage(_ virtualPage: Int) -> Int` | `func pageFor(virtualPage: Int) -> Int` | You can check all the changes in [this pull request](https://github.com/xmartlabs/XLPagerTabStrip/pull/226) ================================================ FILE: ObjC/FXPageControl.h ================================================ // // FXPageControl.h // // Version 1.6 // // Created by Nick Lockwood on 07/01/2010. // Copyright 2010 Charcoal Design // // Distributed under the permissive zlib License // Get the latest version of FXPageControl from here: // // https://github.com/nicklockwood/FXPageControl // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution. // #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wobjc-missing-property-synthesis" #import NS_ASSUME_NONNULL_BEGIN extern const CGPathRef FXPageControlDotShapeCircle; extern const CGPathRef FXPageControlDotShapeSquare; extern const CGPathRef FXPageControlDotShapeTriangle; @protocol FXPageControlDelegate; IB_DESIGNABLE @interface FXPageControl : UIControl - (void)setUp; - (CGSize)sizeForNumberOfPages:(NSInteger)pageCount; - (void)updateCurrentPageDisplay; @property (nonatomic, weak) IBOutlet id delegate; @property (nonatomic, assign) IBInspectable NSInteger currentPage; @property (nonatomic, assign) IBInspectable NSInteger numberOfPages; @property (nonatomic, assign) IBInspectable BOOL defersCurrentPageDisplay; @property (nonatomic, assign) IBInspectable BOOL hidesForSinglePage; @property (nonatomic, assign, getter = isWrapEnabled) IBInspectable BOOL wrapEnabled; @property (nonatomic, assign, getter = isVertical) IBInspectable BOOL vertical; @property (nonatomic, assign) IBInspectable CGPathRef dotShape; @property (nonatomic, assign) IBInspectable CGFloat dotSize; @property (nonatomic, assign) IBInspectable CGFloat dotShadowBlur; @property (nonatomic, assign) IBInspectable CGSize dotShadowOffset; @property (nonatomic, assign) IBInspectable CGFloat dotBorderWidth; @property (nonatomic, strong, nullable) IBInspectable UIImage *dotImage; @property (nonatomic, strong, nullable) IBInspectable UIColor *dotColor; @property (nonatomic, strong, nullable) IBInspectable UIColor *dotShadowColor; @property (nonatomic, strong, nullable) IBInspectable UIColor *dotBorderColor; @property (nonatomic, assign) IBInspectable CGPathRef selectedDotShape; @property (nonatomic, assign) IBInspectable CGFloat selectedDotSize; @property (nonatomic, assign) IBInspectable CGFloat selectedDotShadowBlur; @property (nonatomic, assign) IBInspectable CGSize selectedDotShadowOffset; @property (nonatomic, assign) IBInspectable CGFloat selectedDotBorderWidth; @property (nonatomic, strong, nullable) IBInspectable UIImage *selectedDotImage; @property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotColor; @property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotShadowColor; @property (nonatomic, strong, nullable) IBInspectable UIColor *selectedDotBorderColor; @property (nonatomic, assign) IBInspectable CGFloat dotSpacing; @end @protocol FXPageControlDelegate @optional - (nullable UIImage *)pageControl:(FXPageControl *)pageControl imageForDotAtIndex:(NSInteger)index; - (CGPathRef)pageControl:(FXPageControl *)pageControl shapeForDotAtIndex:(NSInteger)index; - (UIColor *)pageControl:(FXPageControl *)pageControl colorForDotAtIndex:(NSInteger)index; - (nullable UIImage *)pageControl:(FXPageControl *)pageControl selectedImageForDotAtIndex:(NSInteger)index; - (CGPathRef)pageControl:(FXPageControl *)pageControl selectedShapeForDotAtIndex:(NSInteger)index; - (UIColor *)pageControl:(FXPageControl *)pageControl selectedColorForDotAtIndex:(NSInteger)index; @end NS_ASSUME_NONNULL_END #pragma clang diagnostic pop ================================================ FILE: ObjC/FXPageControl.m ================================================ // // FXPageControl.m // // Version 1.6 // // Created by Nick Lockwood on 07/01/2010. // Copyright 2010 Charcoal Design // // Distributed under the permissive zlib License // Get the latest version of FXPageControl from here: // // https://github.com/nicklockwood/FXPageControl // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution. // #import "FXPageControl.h" #pragma clang diagnostic ignored "-Wgnu" #pragma clang diagnostic ignored "-Wfloat-equal" #pragma clang diagnostic ignored "-Wfloat-conversion" #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" #pragma clang diagnostic ignored "-Wdirect-ivar-access" #import #if !__has_feature(objc_arc) #error This class requires automatic reference counting #endif const CGPathRef FXPageControlDotShapeCircle = (const CGPathRef)1; const CGPathRef FXPageControlDotShapeSquare = (const CGPathRef)2; const CGPathRef FXPageControlDotShapeTriangle = (const CGPathRef)3; #define LAST_SHAPE FXPageControlDotShapeTriangle @implementation FXPageControl - (void)setUp { //needs redrawing if bounds change self.contentMode = UIViewContentModeRedraw; //set defaults _dotSpacing = 10.0; _dotSize = 6.0; _dotShadowOffset = CGSizeMake(0, 1); _selectedDotShadowOffset = CGSizeMake(0, 1); } - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { [self setUp]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) { [self setUp]; } return self; } - (void)dealloc { if (_dotShape > LAST_SHAPE) CGPathRelease(_dotShape); if (_selectedDotShape > LAST_SHAPE) CGPathRelease(_selectedDotShape); } - (CGSize)sizeForNumberOfPages:(__unused NSInteger)pageCount { CGFloat width = _dotSize + (_dotSize + _dotSpacing) * (_numberOfPages - 1); return _vertical? CGSizeMake(_dotSize, width): CGSizeMake(width, _dotSize); } - (void)updateCurrentPageDisplay { [self setNeedsDisplay]; } - (void)drawRect:(CGRect)rect { if (_numberOfPages > 1 || !_hidesForSinglePage) { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextClearRect(context, rect); CGSize size = [self sizeForNumberOfPages:_numberOfPages]; if (_vertical) { CGContextTranslateCTM(context, self.frame.size.width / 2, (self.frame.size.height - size.height) / 2); } else { CGContextTranslateCTM(context, (self.frame.size.width - size.width) / 2, self.frame.size.height / 2); } for (int i = 0; i < _numberOfPages; i++) { UIImage *dotImage = nil; UIColor *dotColor = nil; CGPathRef dotShape = NULL; CGFloat dotSize = 0; UIColor *dotShadowColor = nil; CGSize dotShadowOffset = CGSizeZero; CGFloat dotShadowBlur = 0; CGFloat dotBorderWidth = 0; UIColor *dotBorderColor = nil; if (i == _currentPage) { if ([_delegate respondsToSelector:@selector(pageControl:selectedImageForDotAtIndex:)]) { dotImage = [_delegate pageControl:self selectedImageForDotAtIndex:i]; } else { dotImage = _selectedDotImage; } if ([_delegate respondsToSelector:@selector(pageControl:selectedShapeForDotAtIndex:)]) { dotShape = [_delegate pageControl:self selectedShapeForDotAtIndex:i]; } else { dotShape = _selectedDotShape ?: _dotShape; } if ([_delegate respondsToSelector:@selector(pageControl:selectedColorForDotAtIndex:)]) { dotColor = [_delegate pageControl:self selectedColorForDotAtIndex:i]; } else { dotColor = _selectedDotColor ?: [UIColor blackColor]; } dotShadowBlur = _selectedDotShadowBlur; dotShadowColor = _selectedDotShadowColor; dotShadowOffset = _selectedDotShadowOffset; dotBorderWidth = _selectedDotBorderWidth; dotBorderColor = _selectedDotBorderColor; dotSize = _selectedDotSize ?: _dotSize; } else { if ([_delegate respondsToSelector:@selector(pageControl:imageForDotAtIndex:)]) { dotImage = [_delegate pageControl:self imageForDotAtIndex:i]; } else { dotImage = _dotImage; } if ([_delegate respondsToSelector:@selector(pageControl:shapeForDotAtIndex:)]) { dotShape = [_delegate pageControl:self shapeForDotAtIndex:i]; } else { dotShape = _dotShape; } if ([_delegate respondsToSelector:@selector(pageControl:colorForDotAtIndex:)]) { dotColor = [_delegate pageControl:self colorForDotAtIndex:i]; } else { dotColor = _dotColor; } if (!dotColor) { //fall back to selected dot color with reduced alpha if ([_delegate respondsToSelector:@selector(pageControl:selectedColorForDotAtIndex:)]) { dotColor = [_delegate pageControl:self selectedColorForDotAtIndex:i]; } else { dotColor = _selectedDotColor ?: [UIColor blackColor]; } dotColor = [dotColor colorWithAlphaComponent:0.25]; } dotShadowBlur = _dotShadowBlur; dotShadowColor = _dotShadowColor; dotShadowOffset = _dotShadowOffset; dotBorderWidth = _dotBorderWidth; dotBorderColor = _dotBorderColor; dotSize = _dotSize; } [dotColor setFill]; CGContextSaveGState(context); CGFloat offset = (_dotSize + _dotSpacing) * i + _dotSize / 2; CGContextTranslateCTM(context, _vertical? 0: offset, _vertical? offset: 0); if (dotShadowColor && ![dotShadowColor isEqual:[UIColor clearColor]]) { CGContextSetShadowWithColor(context, dotShadowOffset, dotShadowBlur, dotShadowColor.CGColor); } if (dotImage) { [dotImage drawInRect:CGRectMake(-dotImage.size.width / 2, -dotImage.size.height / 2, dotImage.size.width, dotImage.size.height)]; } else { [dotBorderColor setStroke]; CGContextSetLineWidth(context, dotBorderWidth); if (!dotShape || dotShape == FXPageControlDotShapeCircle) { CGContextAddEllipseInRect(context, CGRectMake(-dotSize / 2, -dotSize / 2, dotSize, dotSize)); } else if (dotShape == FXPageControlDotShapeSquare) { CGContextAddRect(context, CGRectMake(-dotSize / 2, -dotSize / 2, dotSize, dotSize)); } else if (dotShape == FXPageControlDotShapeTriangle) { CGContextMoveToPoint(context, 0, -dotSize / 2); CGContextAddLineToPoint(context, dotSize / 2, dotSize / 2); CGContextAddLineToPoint(context, -dotSize / 2, dotSize / 2); CGContextAddLineToPoint(context, 0, -dotSize / 2); } else { CGContextAddPath(context, dotShape); } if (dotBorderWidth == 0) CGContextDrawPath(context, kCGPathFill); else CGContextDrawPath(context, kCGPathFillStroke); } CGContextRestoreGState(context); } } } - (NSInteger)clampedPageValue:(NSInteger)page { if (_wrapEnabled) { return _numberOfPages? (page + _numberOfPages) % _numberOfPages: 0; } else { return MIN(MAX(0, page), _numberOfPages - 1); } } - (void)setDotImage:(UIImage *)dotImage { if (_dotImage != dotImage) { _dotImage = dotImage; [self setNeedsDisplay]; } } - (void)setDotShape:(CGPathRef)dotShape { if (_dotShape != dotShape) { if (_dotShape > LAST_SHAPE) CGPathRelease(_dotShape); _dotShape = dotShape; if (_dotShape > LAST_SHAPE) CGPathRetain(_dotShape); [self setNeedsDisplay]; } } - (void)setDotSize:(CGFloat)dotSize { if (ABS(_dotSize - dotSize) > 0.001) { _dotSize = dotSize; [self setNeedsDisplay]; [self invalidateIntrinsicContentSize]; } } - (void)setDotColor:(UIColor *)dotColor { if (_dotColor != dotColor) { _dotColor = dotColor; [self setNeedsDisplay]; } } - (void)setDotShadowColor:(UIColor *)dotColor { if (_dotShadowColor != dotColor) { _dotShadowColor = dotColor; [self setNeedsDisplay]; } } - (void)setDotShadowBlur:(CGFloat)dotShadowBlur { if (ABS(_dotShadowBlur - dotShadowBlur) > 0.001) { _dotShadowBlur = dotShadowBlur; [self setNeedsDisplay]; [self invalidateIntrinsicContentSize]; } } - (void)setDotShadowOffset:(CGSize)dotShadowOffset { if (!CGSizeEqualToSize(_dotShadowOffset, dotShadowOffset)) { _dotShadowOffset = dotShadowOffset; [self setNeedsDisplay]; [self invalidateIntrinsicContentSize]; } } - (void)setDotBorderWidth:(CGFloat)dotBorderWidth { if (ABS(_dotBorderWidth - dotBorderWidth) > 0.001) { _dotBorderWidth = dotBorderWidth; [self setNeedsDisplay]; } } - (void)setDotBorderColor:(UIColor *)dotBorderColor { if (_dotBorderColor != dotBorderColor) { _dotBorderColor = dotBorderColor; [self setNeedsDisplay]; } } - (void)setSelectedDotImage:(UIImage *)dotImage { if (_selectedDotImage != dotImage) { _selectedDotImage = dotImage; [self setNeedsDisplay]; } } - (void)setSelectedDotColor:(UIColor *)dotColor { if (_selectedDotColor != dotColor) { _selectedDotColor = dotColor; [self setNeedsDisplay]; } } - (void)setSelectedDotShape:(CGPathRef)dotShape { if (_selectedDotShape != dotShape) { if (_selectedDotShape > LAST_SHAPE) CGPathRelease(_selectedDotShape); _selectedDotShape = dotShape; if (_selectedDotShape > LAST_SHAPE) CGPathRetain(_selectedDotShape); [self setNeedsDisplay]; } } - (void)setSelectedDotSize:(CGFloat)dotSize { if (ABS(_selectedDotSize - dotSize) > 0.001) { _selectedDotSize = dotSize; [self setNeedsDisplay]; [self invalidateIntrinsicContentSize]; } } - (void)setSelectedDotShadowColor:(UIColor *)dotColor { if (_selectedDotShadowColor != dotColor) { _selectedDotShadowColor = dotColor; [self setNeedsDisplay]; } } - (void)setSelectedDotShadowBlur:(CGFloat)dotShadowBlur { if (ABS(_selectedDotShadowBlur - dotShadowBlur) > 0.001) { _selectedDotShadowBlur = dotShadowBlur; [self setNeedsDisplay]; [self invalidateIntrinsicContentSize]; } } - (void)setSelectedDotShadowOffset:(CGSize)dotShadowOffset { if (!CGSizeEqualToSize(_selectedDotShadowOffset, dotShadowOffset)) { _selectedDotShadowOffset = dotShadowOffset; [self setNeedsDisplay]; [self invalidateIntrinsicContentSize]; } } - (void)setSelectedDotBorderWidth:(CGFloat)selectedDotBorderWidth { if (ABS(_selectedDotBorderWidth - selectedDotBorderWidth) > 0.001) { _selectedDotBorderWidth = selectedDotBorderWidth; [self setNeedsDisplay]; } } - (void)setSelectedDotBorderColor:(UIColor *)dotColor { if (_selectedDotBorderColor != dotColor) { _selectedDotBorderColor = dotColor; [self setNeedsDisplay]; } } - (void)setDotSpacing:(CGFloat)dotSpacing { if (ABS(_dotSpacing - dotSpacing) > 0.001) { _dotSpacing = dotSpacing; [self setNeedsDisplay]; [self invalidateIntrinsicContentSize]; } } - (void)setDelegate:(id)delegate { if (_delegate != delegate) { _delegate = delegate; [self setNeedsDisplay]; } } - (void)setCurrentPage:(NSInteger)page { _currentPage = [self clampedPageValue:page]; [self setNeedsDisplay]; } - (void)setNumberOfPages:(NSInteger)pages { if (_numberOfPages != pages) { _numberOfPages = pages; if (_currentPage >= pages) { _currentPage = pages - 1; } [self setNeedsDisplay]; [self invalidateIntrinsicContentSize]; } } - (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { CGPoint point = [touch locationInView:self]; BOOL forward = _vertical? (point.y > self.frame.size.height / 2): (point.x > self.frame.size.width / 2); _currentPage = [self clampedPageValue:_currentPage + (forward? 1: -1)]; if (!_defersCurrentPageDisplay) { [self setNeedsDisplay]; } [self sendActionsForControlEvents:UIControlEventValueChanged]; [super endTrackingWithTouch:touch withEvent:event]; } - (CGSize)sizeThatFits:(__unused CGSize)size { CGSize dotSize = [self sizeForNumberOfPages:_numberOfPages]; if (_selectedDotSize) { CGFloat width = (_selectedDotSize - _dotSize); CGFloat height = MAX(36, MAX(_dotSize, _selectedDotSize)); dotSize.width = _vertical? height: dotSize.width + width; dotSize.height = _vertical? dotSize.height + width: height; } if ((_dotShadowColor && ![_dotShadowColor isEqual:[UIColor clearColor]]) || (_selectedDotShadowColor && ![_selectedDotShadowColor isEqual:[UIColor clearColor]])) { dotSize.width += MAX(_dotShadowOffset.width, _selectedDotShadowOffset.width) * 2; dotSize.height += MAX(_dotShadowOffset.height, _selectedDotShadowOffset.height) * 2; dotSize.width += MAX(_dotShadowBlur, _selectedDotShadowBlur) * 2; dotSize.height += MAX(_dotShadowBlur, _selectedDotShadowBlur) * 2; } return dotSize; } - (CGSize)intrinsicContentSize { return [self sizeThatFits:self.bounds.size]; } #pragma mark - Accessibility - (UIAccessibilityTraits)accessibilityTraits { return UIAccessibilityTraitAdjustable; } - (void)accessibilityIncrement { self.currentPage = self.currentPage + 1; [self sendActionsForControlEvents:UIControlEventValueChanged]; } - (void)accessibilityDecrement { self.currentPage = self.currentPage - 1; [self sendActionsForControlEvents:UIControlEventValueChanged]; } @end ================================================ FILE: Package.resolved ================================================ { "object": { "pins": [ { "package": "FXPageControl", "repositoryURL": "https://github.com/nicklockwood/FXPageControl.git", "state": { "branch": null, "revision": "a94633402ba98c52f86c2a70e61ff086dec9de78", "version": "1.6.0" } } ] }, "version": 1 } ================================================ FILE: Package.swift ================================================ // swift-tools-version: 5.4 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "XLPagerTabStrip", platforms: [ .iOS(.v11) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "XLPagerTabStrip", targets: ["XLPagerTabStrip"]), ], dependencies: [ .package( url: "https://github.com/nicklockwood/FXPageControl.git", .upToNextMajor(from: "1.6.0") ) ], targets: [ .target( name: "XLPagerTabStrip", dependencies: ["FXPageControl"]), ], swiftLanguageVersions: [ .v5 ] ) ================================================ FILE: Playground.playground/Contents.swift ================================================ // // Playground.playground // XLPagerTabStrip // // Copyright © 2016 Xmartlabs SRL. All rights reserved. // //: Playground - noun: a place where people can play import UIKit import XLPagerTabStrip var helloWorld = "Hello, playground" ================================================ FILE: Playground.playground/contents.xcplayground ================================================ ================================================ FILE: README.md ================================================ ![XLPagerTabStripView](https://raw.githubusercontent.com/xmartlabs/XLPagerTabStrip/master/XLPagerTabTrip.png)

Build status Platform iOS Swift 5 compatible Carthage compatible CocoaPods compatible License: MIT

Made with ❤️ by [XMARTLABS](http://xmartlabs.com). Android [PagerTabStrip](http://developer.android.com/reference/android/support/v4/view/PagerTabStrip.html) for iOS! 👉 Looking for a SwiftUI version? Check out [PagerTabStripView](https://github.com/xmartlabs/PagerTabStripView), it's fully written in pure SwiftUI. 👈 **XLPagerTabStrip** is a *Container View Controller* that allows us to switch easily among a collection of view controllers. Pan gesture can be used to move on to next or previous view controller. It shows a interactive indicator of the current, previous, next child view controllers.
## Getting involved * If you **want to contribute** please feel free to **submit pull requests**. * If you **have a feature request** please **open an issue**. * If you **found a bug** or **need help** please **check older issues, [FAQ](#faq) and threads on [StackOverflow](http://stackoverflow.com/questions/tagged/XLPagerTabStrip) (Tag 'XLPagerTabStrip') before submitting an issue**. **Before contribute check the [CONTRIBUTING](CONTRIBUTING.md) file for more info.** If you use **XLPagerTabStrip** in your app we would love to hear about it! Drop us a line on [twitter](https://twitter.com/xmartlabs). ## Pager Types The library provides 4 different ways to show the view controllers. ### Button Bar This is likely the most common pager type. It's used by many well-known apps such as instagram, youtube, skype, and many others. ### Bar This mode doesn't show a title neither an image. It only shows a bar that indicates the current view controller. ### Twitter A long time ago, the twitter app made use of this type of pager in the app main screen. ### Segmented This mode uses a `UISegmentedControl` to indicate which view controller is being displayed. ## Usage 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. Let's see the steps to do this: ##### Choose which type of pager we want to create First, we must choose the type of pager we want to create. Depending on our choice, we will have to create a view controller that extends from one of the following controllers: `TwitterPagerTabStripViewController`, `ButtonBarPagerTabStripViewController`, `SegmentedPagerTabStripViewController`, `BarPagerTabStripViewController`. > All these built-in pager controllers extend from the base class `PagerTabStripViewController`. > You can also make your custom pager controller by extending directly from `PagerTabStripViewController` in the event that no pager menu type fits your needs. ```swift import XLPagerTabStrip class MyPagerTabStripName: ButtonBarPagerTabStripViewController { .. } ``` ##### Connect outlets and add layout constraints We strongly recommend using IB to set up our page controller views. Drag a `UIViewController` into the storyboard and set up its class with your pager controller (`MyPagerTabStripName`). Drag a `UIScrollView` into your view controller view and connect `PagerTabStripViewController` `containerView` outlet with the scroll view. Depending on which type of paging view controller you are working with you may have to connect more outlets. For `BarPagerTabStripViewController`, we should connect `barView` outlet. barView type is UIView. `ButtonBarPagerTabStripViewController` requires us to connect `buttonBarView` outlet. `buttonBarView` type is `ButtonBarView` which extends from `UICollectionView`. `SegmentedPagerTabStripViewController` has a `segmentedControl` outlet; if the outlet is not connected the library try to set up the navigationItem `titleView` property using a `UISegmentedControl`. `TwitterPagerTabStripViewController` doesn't require us to connect any additional outlet. > 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. ##### Provide the view controllers that will appear embedded into the PagerTabStrip view controller You can provide the view controllers by overriding `func viewControllers(for: pagerTabStripController: PagerTabStripViewController) -> [UIViewController]` method. ```swift override public func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { return [MyEmbeddedViewController(), MySecondEmbeddedViewController()] } ``` > The method above is the only method declared in `PagerTabStripDataSource` protocol. We don't need to explicitly conform to it since base pager class already does it. ##### Provide information to show in each indicator Every UIViewController that will appear within the PagerTabStrip needs to provide either a title or an image. In order to do so they should conform to `IndicatorInfoProvider` by implementing `func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo` which provides the information required to show the PagerTabStrip menu (indicator) associated with the view controller. ```swift class MyEmbeddedViewController: UITableViewController, IndicatorInfoProvider { func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo { return IndicatorInfo(title: "My Child title") } } ``` **For a detailed step-by-step guide about how to use the library, please check out this community [blog post](https://medium.com/michaeladeyeri/how-to-implement-android-like-tab-layouts-in-ios-using-swift-3-578516c3aa9).** That's it! We're done! 🍻🍻 ## Customization ##### Pager Behaviour The pager indicator can be updated progressive as we swipe or at once in the middle of the transition between the view controllers. By setting up `pagerBehaviour` property we can choose how the indicator should be updated. ```swift public var pagerBehaviour: PagerTabStripBehaviour ``` ```swift public enum PagerTabStripBehaviour { case common(skipIntermediteViewControllers: Bool) case progressive(skipIntermediteViewControllers: Bool, elasticIndicatorLimit: Bool) } ``` Default Values: ```swift // Twitter Type PagerTabStripBehaviour.common(skipIntermediateViewControllers: true) // Segmented Type PagerTabStripBehaviour.common(skipIntermediateViewControllers: true) // Bar Type PagerTabStripBehaviour.progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true) // ButtonBar Type PagerTabStripBehaviour.progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true) ``` As you might have noticed, `common` and `progressive` enumeration cases have `skipIntermediateViewControllers` and `elasticIndicatorLimit` associated values. `skipIntermediateViewControllers` allows us to skip intermediate view controllers when a tab indicator is tapped. `elasticIndicatorLimit` allows us to tension the indicator when we reach a limit, I mean when we try to move forward from last indicator or move back from first indicator. ##### PagerTabStripDelegate & PagerTabStripIsProgressiveDelegate Normally we don't need to implement these protocols because each pager type already conforms to it in order to properly update its indicator. However, there may be some scenarios when overriding a method may come in handy. ```swift public protocol PagerTabStripDelegate: class { func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int) } public protocol PagerTabStripIsProgressiveDelegate : PagerTabStripDelegate { func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) } ``` > Again, the method invoked by the library depends on the `pagerBehaviour` value. ### ButtonBar Customization ```swift settings.style.buttonBarBackgroundColor: UIColor? // buttonBar minimumInteritemSpacing value, note that button bar extends from UICollectionView settings.style.buttonBarMinimumInteritemSpacing: CGFloat? // buttonBar minimumLineSpacing value settings.style.buttonBarMinimumLineSpacing: CGFloat? // buttonBar flow layout left content inset value settings.style.buttonBarLeftContentInset: CGFloat? // buttonBar flow layout right content inset value settings.style.buttonBarRightContentInset: CGFloat? // selected bar view is created programmatically so it's important to set up the following 2 properties properly settings.style.selectedBarBackgroundColor = UIColor.black settings.style.selectedBarHeight: CGFloat = 5 // each buttonBar item is a UICollectionView cell of type ButtonBarViewCell settings.style.buttonBarItemBackgroundColor: UIColor? settings.style.buttonBarItemFont = UIFont.systemFont(ofSize: 18) // helps to determine the cell width, it represent the space before and after the title label settings.style.buttonBarItemLeftRightMargin: CGFloat = 8 settings.style.buttonBarItemTitleColor: UIColor? // in case the barView items do not fill the screen width this property stretch the cells to fill the screen settings.style.buttonBarItemsShouldFillAvailableWidth = true // only used if button bar is created programmatically and not using storyboards or nib files as recommended. public var buttonBarHeight: CGFloat? ``` **Important:** Settings should be called before `viewDidLoad` is called. ```swift override func viewDidLoad() { self.settings.style.selectedBarHeight = 2 self.settings.style.selectedBarBackgroundColor = UIColor.white super.viewDidLoad() } ``` ##### Update cells when selected indicator changes We may need to update the indicator cell when the displayed view controller changes. The following function properties help to accomplish that. Depending on our pager `pagerBehaviour` value we will have to set up `changeCurrentIndex` or `changeCurrentIndexProgressive`. ```swift public var changeCurrentIndex: ((oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, animated: Bool) -> Void)? public var changeCurrentIndexProgressive: ((oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void)? ``` Let's see an example: ```swift changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in guard changeCurrentIndex == true else { return } oldCell?.label.textColor = UIColor(white: 1, alpha: 0.6) newCell?.label.textColor = UIColor.white if animated { UIView.animate(withDuration: 0.1, animations: { () -> Void in newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) }) } else { newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) } } ``` ### Bar Type Customization ```swift settings.style.barBackgroundColor: UIColor? settings.style.selectedBarBackgroundColor: UIColor? // barHeight is only set up when the bar is created programmatically and not using storyboards or xib files as recommended. settings.style.barHeight: CGFloat = 5 ``` ### Twitter Type Customization ```swift settings.style.dotColor = UIColor(white: 1, alpha: 0.4) settings.style.selectedDotColor = UIColor.white settings.style.portraitTitleFont = UIFont.systemFont(ofSize: 18) settings.style.landscapeTitleFont = UIFont.systemFont(ofSize: 15) settings.style.titleColor = UIColor.white ``` ### Segmented Type Customization ```swift settings.style.segmentedControlColor: UIColor? ``` ## Requirements * iOS 9.3+ * Xcode 10.2+ ## Examples Follow these 3 steps to run Example project: Clone XLPagerTabStrip repository, open XLPagerTabStrip workspace and run the *Example* project. ## Installation ### CocoaPods [CocoaPods](https://cocoapods.org/) is a dependency manager for Cocoa projects. To install XLPagerTabStrip, simply add the following line to your Podfile: ```ruby pod 'XLPagerTabStrip', '~> 9.0' ``` ### Carthage [Carthage](https://github.com/Carthage/Carthage) is a simple, decentralized dependency manager for Cocoa. To install XLPagerTabStrip, simply add the following line to your Cartfile: ```ogdl github "xmartlabs/XLPagerTabStrip" ~> 9.0 ``` ### SPM - File > Swift Packages > Add Package Dependency - Add `https://github.com/xmartlabs/XLPagerTabStrip.git` - Select "Up to Next Major" with "9.0.0" ## FAQ #### How to change the visible child view controller programmatically `PagerTabStripViewController` provides the following methods to programmatically change the visible child view controller: ```swift func moveToViewController(at index: Int) func moveToViewController(at index: Int, animated: Bool) func moveTo(viewController: UIViewController) func moveTo(viewController: UIViewController, animated: Bool) ``` #### How to migrate from Swift 2 to Swift 3 Check out [our migration guide](https://github.com/xmartlabs/XLPagerTabStrip/blob/master/Migration.md) ## Author * [Martin Barreto](https://github.com/mtnBarreto) ([@mtnBarreto](https://twitter.com/mtnBarreto)) ## Change Log This can be found in the [CHANGELOG.md](CHANGELOG.md) file. ================================================ FILE: Sources/XLPagerTabStrip/BarPagerTabStripViewController.swift ================================================ // BarPagerTabStripViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit public struct BarPagerTabStripSettings { public struct Style { public var barBackgroundColor: UIColor? public var selectedBarBackgroundColor: UIColor? public var barHeight: CGFloat = 5 // barHeight is ony set up when the bar is created programatically and not using storyboards or xib files. } public var style = Style() } open class BarPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate { public var settings = BarPagerTabStripSettings() @IBOutlet weak public var barView: BarView! required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) delegate = self datasource = self } public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) delegate = self datasource = self } open override func viewDidLoad() { super.viewDidLoad() barView = barView ?? { let barView = BarView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: settings.style.barHeight)) barView.autoresizingMask = .flexibleWidth barView.backgroundColor = .black barView.selectedBar.backgroundColor = .white return barView }() barView.backgroundColor = settings.style.barBackgroundColor ?? barView.backgroundColor barView.selectedBar.backgroundColor = settings.style.selectedBarBackgroundColor ?? barView.selectedBar.backgroundColor } open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if barView.superview == nil { view.addSubview(barView) } barView.optionsCount = viewControllers.count barView.moveTo(index: currentIndex, animated: false) } open override func reloadPagerTabStripView() { super.reloadPagerTabStripView() barView.optionsCount = viewControllers.count if isViewLoaded { barView.moveTo(index: currentIndex, animated: false) } } // MARK: - PagerTabStripDelegate open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) { barView.move(fromIndex: fromIndex, toIndex: toIndex, progressPercentage: progressPercentage) } open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int) { barView.moveTo(index: toIndex, animated: true) } } ================================================ FILE: Sources/XLPagerTabStrip/BarView.swift ================================================ // BarView.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit open class BarView: UIView { open lazy var selectedBar: UIView = { [unowned self] in let selectedBar = UIView(frame: CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)) return selectedBar }() var optionsCount = 1 { willSet(newOptionsCount) { if newOptionsCount <= selectedIndex { selectedIndex = optionsCount - 1 } } } var selectedIndex = 0 required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) addSubview(selectedBar) } override init(frame: CGRect) { super.init(frame: frame) addSubview(selectedBar) } // MARK: - Helpers private func updateSelectedBarPosition(with animation: Bool) { var frame = selectedBar.frame frame.size.width = self.frame.size.width / CGFloat(optionsCount) frame.origin.x = frame.size.width * CGFloat(selectedIndex) if animation { UIView.animate(withDuration: 0.3, animations: { [weak self] in self?.selectedBar.frame = frame }) } else { selectedBar.frame = frame } } open func moveTo(index: Int, animated: Bool) { selectedIndex = index updateSelectedBarPosition(with: animated) } open func move(fromIndex: Int, toIndex: Int, progressPercentage: CGFloat) { selectedIndex = (progressPercentage > 0.5) ? toIndex : fromIndex var newFrame = selectedBar.frame newFrame.size.width = frame.size.width / CGFloat(optionsCount) var fromFrame = newFrame fromFrame.origin.x = newFrame.size.width * CGFloat(fromIndex) var toFrame = newFrame toFrame.origin.x = toFrame.size.width * CGFloat(toIndex) var targetFrame = fromFrame targetFrame.origin.x += (toFrame.origin.x - targetFrame.origin.x) * CGFloat(progressPercentage) selectedBar.frame = targetFrame } open override func layoutSubviews() { super.layoutSubviews() updateSelectedBarPosition(with: false) } } ================================================ FILE: Sources/XLPagerTabStrip/BaseButtonBarPagerTabStripViewController.swift ================================================ // BaseButtonBarPagerTabStripViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit open class BaseButtonBarPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate, UICollectionViewDelegate, UICollectionViewDataSource { public var settings = ButtonBarPagerTabStripSettings() public var buttonBarItemSpec: ButtonBarItemSpec! 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 return self.calculateWidths() }() public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) delegate = self datasource = self } required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) delegate = self datasource = self } open override func viewDidLoad() { super.viewDidLoad() let buttonBarViewAux = buttonBarView ?? { let flowLayout = UICollectionViewFlowLayout() flowLayout.scrollDirection = .horizontal 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 buttonBar.selectedBar.backgroundColor = .black buttonBar.autoresizingMask = .flexibleWidth var newContainerViewFrame = containerView.frame newContainerViewFrame.origin.y = buttonBarHeight newContainerViewFrame.size.height = containerView.frame.size.height - (buttonBarHeight - containerView.frame.origin.y) containerView.frame = newContainerViewFrame return buttonBar }() buttonBarView = buttonBarViewAux if buttonBarView.superview == nil { view.addSubview(buttonBarView) } if buttonBarView.delegate == nil { buttonBarView.delegate = self } if buttonBarView.dataSource == nil { buttonBarView.dataSource = self } buttonBarView.scrollsToTop = false 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 = 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 buttonBarView.selectedBarVerticalAlignment = settings.style.selectedBarVerticalAlignment buttonBarView.selectedBarHeight = settings.style.selectedBarHeight // register button bar item cell switch buttonBarItemSpec! { case .nibFile(let nibName, let bundle, _): buttonBarView.register(UINib(nibName: nibName, bundle: bundle), forCellWithReuseIdentifier:"Cell") case .cellClass: buttonBarView.register(ButtonBarCellType.self, forCellWithReuseIdentifier:"Cell") } //- } open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) buttonBarView.layoutIfNeeded() isViewAppearing = true } open override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) isViewAppearing = false } open override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() guard isViewAppearing || isViewRotating else { return } // Force the UICollectionViewFlowLayout to get laid out again with the new size if // a) The view is appearing. This ensures that // collectionView:layout:sizeForItemAtIndexPath: is called for a second time // when the view is shown and when the view *frame(s)* are actually set // (we need the view frame's to have been set to work out the size's and on the // first call to collectionView:layout:sizeForItemAtIndexPath: the view frame(s) // aren't set correctly) // b) The view is rotating. This ensures that // collectionView:layout:sizeForItemAtIndexPath: is called again and can use the views // *new* frame so that the buttonBarView cell's actually get resized correctly cachedCellWidths = calculateWidths() buttonBarView.collectionViewLayout.invalidateLayout() // When the view first appears or is rotated we also need to ensure that the barButtonView's // selectedBar is resized and its contentOffset/scroll is set correctly (the selected // tab/cell may end up either skewed or off screen after a rotation otherwise) buttonBarView.moveTo(index: currentIndex, animated: false, swipeDirection: .none, pagerScroll: .scrollOnlyIfOutOfScreen) buttonBarView.selectItem(at: IndexPath(item: currentIndex, section: 0), animated: false, scrollPosition: []) } // MARK: - View Rotation open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) } // MARK: - Public Methods open override func reloadPagerTabStripView() { super.reloadPagerTabStripView() guard isViewLoaded else { return } buttonBarView.reloadData() cachedCellWidths = calculateWidths() buttonBarView.moveTo(index: currentIndex, animated: false, swipeDirection: .none, pagerScroll: .yes) } open func calculateStretchedCellWidths(_ minimumCellWidths: [CGFloat], suggestedStretchedCellWidth: CGFloat, previousNumberOfLargeCells: Int) -> CGFloat { var numberOfLargeCells = 0 var totalWidthOfLargeCells: CGFloat = 0 for minimumCellWidthValue in minimumCellWidths where minimumCellWidthValue > suggestedStretchedCellWidth { totalWidthOfLargeCells += minimumCellWidthValue numberOfLargeCells += 1 } guard numberOfLargeCells > previousNumberOfLargeCells else { return suggestedStretchedCellWidth } 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 let numberOfSmallCells = numberOfCells - numberOfLargeCells let newSuggestedStretchedCellWidth = (collectionViewAvailiableWidth - totalWidthOfLargeCells - cellSpacingTotal) / CGFloat(numberOfSmallCells) return calculateStretchedCellWidths(minimumCellWidths, suggestedStretchedCellWidth: newSuggestedStretchedCellWidth, previousNumberOfLargeCells: numberOfLargeCells) } open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int) { guard shouldUpdateButtonBarView else { return } buttonBarView.moveTo(index: toIndex, animated: true, swipeDirection: toIndex < fromIndex ? .right : .left, pagerScroll: .yes) if let changeCurrentIndex = changeCurrentIndex { let oldCell = buttonBarView.cellForItem(at: IndexPath(item: currentIndex != fromIndex ? fromIndex : toIndex, section: 0)) as? ButtonBarCellType let newCell = buttonBarView.cellForItem(at: IndexPath(item: currentIndex, section: 0)) as? ButtonBarCellType changeCurrentIndex(oldCell, newCell, true) } } open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) { guard shouldUpdateButtonBarView else { return } buttonBarView.move(fromIndex: fromIndex, toIndex: toIndex, progressPercentage: progressPercentage, pagerScroll: .yes) if let changeCurrentIndexProgressive = changeCurrentIndexProgressive { let oldCell = buttonBarView.cellForItem(at: IndexPath(item: currentIndex != fromIndex ? fromIndex : toIndex, section: 0)) as? ButtonBarCellType let newCell = buttonBarView.cellForItem(at: IndexPath(item: currentIndex, section: 0)) as? ButtonBarCellType changeCurrentIndexProgressive(oldCell, newCell, progressPercentage, indexWasChanged, true) } } // MARK: - UICollectionViewDelegateFlowLayut @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") } return CGSize(width: cellWidthValue, height: collectionView.frame.size.height) } open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { guard indexPath.item != currentIndex else { return } buttonBarView.moveTo(index: indexPath.item, animated: true, swipeDirection: .none, pagerScroll: .yes) shouldUpdateButtonBarView = false let oldCell = buttonBarView.cellForItem(at: IndexPath(item: currentIndex, section: 0)) as? ButtonBarCellType let newCell = buttonBarView.cellForItem(at: IndexPath(item: indexPath.item, section: 0)) as? ButtonBarCellType if pagerBehaviour.isProgressiveIndicator { if let changeCurrentIndexProgressive = changeCurrentIndexProgressive { changeCurrentIndexProgressive(oldCell, newCell, 1, true, true) } } else { if let changeCurrentIndex = changeCurrentIndex { changeCurrentIndex(oldCell, newCell, true) } } moveToViewController(at: indexPath.item) } // MARK: - UICollectionViewDataSource open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return viewControllers.count } open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 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 // swiftlint:disable:this force_cast let indicatorInfo = childController.indicatorInfo(for: self) configure(cell: cell, for: indicatorInfo) if pagerBehaviour.isProgressiveIndicator { if let changeCurrentIndexProgressive = changeCurrentIndexProgressive { changeCurrentIndexProgressive(currentIndex == indexPath.item ? nil : cell, currentIndex == indexPath.item ? cell : nil, 1, true, false) } } else { if let changeCurrentIndex = changeCurrentIndex { changeCurrentIndex(currentIndex == indexPath.item ? nil : cell, currentIndex == indexPath.item ? cell : nil, false) } } return cell } // MARK: - UIScrollViewDelegate open override func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { super.scrollViewDidEndScrollingAnimation(scrollView) guard scrollView == containerView else { return } shouldUpdateButtonBarView = true } 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 // 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 // swiftlint:disable:this force_cast let indicatorInfo = childController.indicatorInfo(for: self) switch buttonBarItemSpec! { case .cellClass(let widthCallback): let width = widthCallback(indicatorInfo) minimumCellWidths.append(width) collectionViewContentWidth += width case .nibFile(_, _, let widthCallback): let width = widthCallback(indicatorInfo) minimumCellWidths.append(width) collectionViewContentWidth += width } } let cellSpacingTotal = CGFloat(numberOfCells - 1) * flowLayout.minimumLineSpacing collectionViewContentWidth += cellSpacingTotal let collectionViewAvailableVisibleWidth = buttonBarView.frame.size.width - flowLayout.sectionInset.left - flowLayout.sectionInset.right if !settings.style.buttonBarItemsShouldFillAvailableWidth || collectionViewAvailableVisibleWidth < collectionViewContentWidth { return minimumCellWidths } else { let stretchedCellWidthIfAllEqual = (collectionViewAvailableVisibleWidth - cellSpacingTotal) / CGFloat(numberOfCells) let generalMinimumCellWidth = calculateStretchedCellWidths(minimumCellWidths, suggestedStretchedCellWidth: stretchedCellWidthIfAllEqual, previousNumberOfLargeCells: 0) var stretchedCellWidths = [CGFloat]() for minimumCellWidthValue in minimumCellWidths { let cellWidth = (minimumCellWidthValue > generalMinimumCellWidth) ? minimumCellWidthValue : generalMinimumCellWidth stretchedCellWidths.append(cellWidth) } return stretchedCellWidths } } private var shouldUpdateButtonBarView = true } open class ExampleBaseButtonBarPagerTabStripViewController: BaseButtonBarPagerTabStripViewController { public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) initialize() } public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) initialize() } open func initialize() { #if SWIFT_PACKAGE var bundle = Bundle.module #else var bundle = Bundle(for: ButtonBarViewCell.self) #endif 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 label.text = childItemInfo.title let labelSize = label.intrinsicContentSize return labelSize.width + CGFloat(self?.settings.style.buttonBarItemLeftRightMargin ?? 8 * 2) }) } open override func configure(cell: ButtonBarViewCell, for indicatorInfo: IndicatorInfo) { cell.label.text = indicatorInfo.title cell.accessibilityLabel = indicatorInfo.accessibilityLabel if let image = indicatorInfo.image { cell.imageView.image = image } if let highlightedImage = indicatorInfo.highlightedImage { cell.imageView.highlightedImage = highlightedImage } } } ================================================ FILE: Sources/XLPagerTabStrip/ButtonBarPagerTabStripViewController.swift ================================================ // ButtonBarPagerTabStripViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit public enum ButtonBarItemSpec { case nibFile(nibName: String, bundle: Bundle?, width:((IndicatorInfo)-> CGFloat)) case cellClass(width:((IndicatorInfo)-> CGFloat)) public var weight: ((IndicatorInfo) -> CGFloat) { switch self { case .cellClass(let widthCallback): return widthCallback case .nibFile(_, _, let widthCallback): return widthCallback } } } public struct ButtonBarPagerTabStripSettings { public struct Style { public var buttonBarBackgroundColor: UIColor? public var buttonBarMinimumInteritemSpacing: CGFloat? public var buttonBarMinimumLineSpacing: CGFloat? public var buttonBarLeftContentInset: CGFloat? public var buttonBarRightContentInset: CGFloat? public var selectedBarBackgroundColor = UIColor.black public var selectedBarHeight: CGFloat = 5 public var selectedBarVerticalAlignment: SelectedBarVerticalAlignment = .bottom public var buttonBarItemBackgroundColor: UIColor? public var buttonBarItemFont = UIFont.systemFont(ofSize: 18) public var buttonBarItemLeftRightMargin: CGFloat = 8 public var buttonBarItemTitleColor: UIColor? public var buttonBarItemsShouldFillAvailableWidth = true // only used if button bar is created programaticaly and not using storyboards or nib files public var buttonBarHeight: CGFloat? } public var style = Style() } open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate, UICollectionViewDelegate, UICollectionViewDataSource { public var settings = ButtonBarPagerTabStripSettings() public var buttonBarItemSpec: ButtonBarItemSpec! public var changeCurrentIndex: ((_ oldCell: ButtonBarViewCell?, _ newCell: ButtonBarViewCell?, _ animated: Bool) -> Void)? public var changeCurrentIndexProgressive: ((_ oldCell: ButtonBarViewCell?, _ newCell: ButtonBarViewCell?, _ progressPercentage: CGFloat, _ changeCurrentIndex: Bool, _ animated: Bool) -> Void)? @IBOutlet public weak var buttonBarView: ButtonBarView! lazy private var cachedCellWidths: [CGFloat]? = { [unowned self] in return self.calculateWidths() }() override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) delegate = self datasource = self } required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) delegate = self datasource = self } open override func viewDidLoad() { super.viewDidLoad() #if SWIFT_PACKAGE var bundle = Bundle.module #else var bundle = Bundle(for: ButtonBarViewCell.self) #endif 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.text = childItemInfo.title let labelSize = label.intrinsicContentSize return labelSize.width + (self?.settings.style.buttonBarItemLeftRightMargin ?? 8) * 2 }) let buttonBarViewAux = buttonBarView ?? { let flowLayout = UICollectionViewFlowLayout() flowLayout.scrollDirection = .horizontal 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 buttonBar.selectedBar.backgroundColor = .black buttonBar.autoresizingMask = .flexibleWidth var newContainerViewFrame = containerView.frame newContainerViewFrame.origin.y = buttonBarHeight newContainerViewFrame.size.height = containerView.frame.size.height - (buttonBarHeight - containerView.frame.origin.y) containerView.frame = newContainerViewFrame return buttonBar }() buttonBarView = buttonBarViewAux if buttonBarView.superview == nil { view.addSubview(buttonBarView) } if buttonBarView.delegate == nil { buttonBarView.delegate = self } if buttonBarView.dataSource == nil { buttonBarView.dataSource = self } buttonBarView.scrollsToTop = false 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 = 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 buttonBarView.selectedBarHeight = settings.style.selectedBarHeight buttonBarView.selectedBarVerticalAlignment = settings.style.selectedBarVerticalAlignment // register button bar item cell switch buttonBarItemSpec! { case .nibFile(let nibName, let bundle, _): buttonBarView.register(UINib(nibName: nibName, bundle: bundle), forCellWithReuseIdentifier:"Cell") case .cellClass: buttonBarView.register(ButtonBarViewCell.self, forCellWithReuseIdentifier:"Cell") } //- } open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) buttonBarView.layoutIfNeeded() } open override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() guard isViewAppearing || isViewRotating else { return } // Force the UICollectionViewFlowLayout to get laid out again with the new size if // a) The view is appearing. This ensures that // collectionView:layout:sizeForItemAtIndexPath: is called for a second time // when the view is shown and when the view *frame(s)* are actually set // (we need the view frame's to have been set to work out the size's and on the // first call to collectionView:layout:sizeForItemAtIndexPath: the view frame(s) // aren't set correctly) // b) The view is rotating. This ensures that // collectionView:layout:sizeForItemAtIndexPath: is called again and can use the views // *new* frame so that the buttonBarView cell's actually get resized correctly cachedCellWidths = calculateWidths() buttonBarView.collectionViewLayout.invalidateLayout() // When the view first appears or is rotated we also need to ensure that the barButtonView's // selectedBar is resized and its contentOffset/scroll is set correctly (the selected // tab/cell may end up either skewed or off screen after a rotation otherwise) buttonBarView.moveTo(index: currentIndex, animated: false, swipeDirection: .none, pagerScroll: .scrollOnlyIfOutOfScreen) buttonBarView.selectItem(at: IndexPath(item: currentIndex, section: 0), animated: false, scrollPosition: []) } // MARK: - Public Methods open override func reloadPagerTabStripView() { super.reloadPagerTabStripView() guard isViewLoaded else { return } buttonBarView.reloadData() cachedCellWidths = calculateWidths() buttonBarView.moveTo(index: currentIndex, animated: false, swipeDirection: .none, pagerScroll: .yes) } open func calculateStretchedCellWidths(_ minimumCellWidths: [CGFloat], suggestedStretchedCellWidth: CGFloat, previousNumberOfLargeCells: Int) -> CGFloat { var numberOfLargeCells = 0 var totalWidthOfLargeCells: CGFloat = 0 for minimumCellWidthValue in minimumCellWidths where minimumCellWidthValue > suggestedStretchedCellWidth { totalWidthOfLargeCells += minimumCellWidthValue numberOfLargeCells += 1 } guard numberOfLargeCells > previousNumberOfLargeCells else { return suggestedStretchedCellWidth } 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 let numberOfSmallCells = numberOfCells - numberOfLargeCells let newSuggestedStretchedCellWidth = (collectionViewAvailiableWidth - totalWidthOfLargeCells - cellSpacingTotal) / CGFloat(numberOfSmallCells) return calculateStretchedCellWidths(minimumCellWidths, suggestedStretchedCellWidth: newSuggestedStretchedCellWidth, previousNumberOfLargeCells: numberOfLargeCells) } open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int) { guard shouldUpdateButtonBarView else { return } buttonBarView.moveTo(index: toIndex, animated: false, swipeDirection: toIndex < fromIndex ? .right : .left, pagerScroll: .yes) if let changeCurrentIndex = changeCurrentIndex { let oldIndexPath = IndexPath(item: currentIndex != fromIndex ? fromIndex : toIndex, section: 0) let newIndexPath = IndexPath(item: currentIndex, section: 0) let cells = cellForItems(at: [oldIndexPath, newIndexPath], reloadIfNotVisible: collectionViewDidLoad) changeCurrentIndex(cells.first!, cells.last!, true) } } open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) { guard shouldUpdateButtonBarView else { return } buttonBarView.move(fromIndex: fromIndex, toIndex: toIndex, progressPercentage: progressPercentage, pagerScroll: .yes) if let changeCurrentIndexProgressive = changeCurrentIndexProgressive { let oldIndexPath = IndexPath(item: currentIndex != fromIndex ? fromIndex : toIndex, section: 0) let newIndexPath = IndexPath(item: currentIndex, section: 0) let cells = cellForItems(at: [oldIndexPath, newIndexPath], reloadIfNotVisible: collectionViewDidLoad) changeCurrentIndexProgressive(cells.first!, cells.last!, progressPercentage, indexWasChanged, true) } } private func cellForItems(at indexPaths: [IndexPath], reloadIfNotVisible reload: Bool = true) -> [ButtonBarViewCell?] { let cells = indexPaths.map { buttonBarView.cellForItem(at: $0) as? ButtonBarViewCell } if reload { let indexPathsToReload = cells.enumerated() .compactMap { (arg) -> IndexPath? in let (index, cell) = arg return cell == nil ? indexPaths[index] : nil } .compactMap { (indexPath: IndexPath) -> IndexPath? in return (indexPath.item >= 0 && indexPath.item < buttonBarView.numberOfItems(inSection: indexPath.section)) ? indexPath : nil } if !indexPathsToReload.isEmpty { buttonBarView.reloadItems(at: indexPathsToReload) } } return cells } // MARK: - UICollectionViewDelegateFlowLayut @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") } return CGSize(width: cellWidthValue, height: collectionView.frame.size.height) } open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { guard indexPath.item != currentIndex else { return } buttonBarView.moveTo(index: indexPath.item, animated: true, swipeDirection: .none, pagerScroll: .yes) shouldUpdateButtonBarView = false let oldIndexPath = IndexPath(item: currentIndex, section: 0) let newIndexPath = IndexPath(item: indexPath.item, section: 0) let cells = cellForItems(at: [oldIndexPath, newIndexPath], reloadIfNotVisible: collectionViewDidLoad) if pagerBehaviour.isProgressiveIndicator { if let changeCurrentIndexProgressive = changeCurrentIndexProgressive { changeCurrentIndexProgressive(cells.first!, cells.last!, 1, true, true) } } else { if let changeCurrentIndex = changeCurrentIndex { changeCurrentIndex(cells.first!, cells.last!, true) } } moveToViewController(at: indexPath.item) } // MARK: - UICollectionViewDataSource open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return viewControllers.count } open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as? ButtonBarViewCell else { fatalError("UICollectionViewCell should be or extend from ButtonBarViewCell") } collectionViewDidLoad = true let childController = viewControllers[indexPath.item] as! IndicatorInfoProvider // swiftlint:disable:this force_cast let indicatorInfo = childController.indicatorInfo(for: self) cell.label.text = indicatorInfo.title cell.label.font = settings.style.buttonBarItemFont cell.label.textColor = settings.style.buttonBarItemTitleColor ?? cell.label.textColor cell.contentView.backgroundColor = settings.style.buttonBarItemBackgroundColor ?? cell.contentView.backgroundColor cell.backgroundColor = settings.style.buttonBarItemBackgroundColor ?? cell.backgroundColor if let image = indicatorInfo.image { cell.imageView.image = image } if let highlightedImage = indicatorInfo.highlightedImage { cell.imageView.highlightedImage = highlightedImage } configureCell(cell, indicatorInfo: indicatorInfo) if pagerBehaviour.isProgressiveIndicator { if let changeCurrentIndexProgressive = changeCurrentIndexProgressive { changeCurrentIndexProgressive(currentIndex == indexPath.item ? nil : cell, currentIndex == indexPath.item ? cell : nil, 1, true, false) } } else { if let changeCurrentIndex = changeCurrentIndex { changeCurrentIndex(currentIndex == indexPath.item ? nil : cell, currentIndex == indexPath.item ? cell : nil, false) } } cell.isAccessibilityElement = true cell.accessibilityLabel = indicatorInfo.accessibilityLabel ?? cell.label.text cell.accessibilityTraits.insert([.button, .header]) return cell } // MARK: - UIScrollViewDelegate open override func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { super.scrollViewDidEndScrollingAnimation(scrollView) guard scrollView == containerView else { return } shouldUpdateButtonBarView = true } open func configureCell(_ cell: ButtonBarViewCell, indicatorInfo: IndicatorInfo) { } private func calculateWidths() -> [CGFloat] { 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 // swiftlint:disable:this force_cast let indicatorInfo = childController.indicatorInfo(for: self) switch buttonBarItemSpec! { case .cellClass(let widthCallback): let width = widthCallback(indicatorInfo) minimumCellWidths.append(width) collectionViewContentWidth += width case .nibFile(_, _, let widthCallback): let width = widthCallback(indicatorInfo) minimumCellWidths.append(width) collectionViewContentWidth += width } } let cellSpacingTotal = CGFloat(numberOfCells - 1) * flowLayout.minimumLineSpacing collectionViewContentWidth += cellSpacingTotal let collectionViewAvailableVisibleWidth = buttonBarView.frame.size.width - flowLayout.sectionInset.left - flowLayout.sectionInset.right if !settings.style.buttonBarItemsShouldFillAvailableWidth || collectionViewAvailableVisibleWidth < collectionViewContentWidth { return minimumCellWidths } else { let stretchedCellWidthIfAllEqual = (collectionViewAvailableVisibleWidth - cellSpacingTotal) / CGFloat(numberOfCells) let generalMinimumCellWidth = calculateStretchedCellWidths(minimumCellWidths, suggestedStretchedCellWidth: stretchedCellWidthIfAllEqual, previousNumberOfLargeCells: 0) var stretchedCellWidths = [CGFloat]() for minimumCellWidthValue in minimumCellWidths { let cellWidth = (minimumCellWidthValue > generalMinimumCellWidth) ? minimumCellWidthValue : generalMinimumCellWidth stretchedCellWidths.append(cellWidth) } return stretchedCellWidths } } private var shouldUpdateButtonBarView = true private var collectionViewDidLoad = false } ================================================ FILE: Sources/XLPagerTabStrip/ButtonBarView.swift ================================================ // ButtonBarView.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import UIKit public enum PagerScroll { case no case yes case scrollOnlyIfOutOfScreen } public enum SelectedBarAlignment { case left case center case right case progressive } public enum SelectedBarVerticalAlignment { case top case middle case bottom } open class ButtonBarView: UICollectionView { open lazy var selectedBar: UIView = { [unowned self] in let bar = UIView(frame: CGRect(x: 0, y: self.frame.size.height - CGFloat(self.selectedBarHeight), width: 0, height: CGFloat(self.selectedBarHeight))) bar.layer.zPosition = 9999 return bar }() internal var selectedBarHeight: CGFloat = 4 { didSet { updateSelectedBarYPosition() } } var selectedBarVerticalAlignment: SelectedBarVerticalAlignment = .bottom var selectedBarAlignment: SelectedBarAlignment = .center var selectedIndex = 0 required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) addSubview(selectedBar) } public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { super.init(frame: frame, collectionViewLayout: layout) addSubview(selectedBar) } open func moveTo(index: Int, animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) { selectedIndex = index updateSelectedBarPosition(animated, swipeDirection: swipeDirection, 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 let numberOfItems = dataSource!.collectionView(self, numberOfItemsInSection: 0) var toFrame: CGRect if toIndex < 0 || toIndex > numberOfItems - 1 { if toIndex < 0 { let cellAtts = layoutAttributesForItem(at: IndexPath(item: 0, section: 0)) toFrame = cellAtts!.frame.offsetBy(dx: -cellAtts!.frame.size.width, dy: 0) } else { let cellAtts = layoutAttributesForItem(at: IndexPath(item: (numberOfItems - 1), section: 0)) toFrame = cellAtts!.frame.offsetBy(dx: cellAtts!.frame.size.width, dy: 0) } } else { toFrame = layoutAttributesForItem(at: IndexPath(item: toIndex, section: 0))!.frame } var targetFrame = fromFrame targetFrame.size.height = selectedBar.frame.size.height targetFrame.size.width += (toFrame.size.width - fromFrame.size.width) * progressPercentage targetFrame.origin.x += (toFrame.origin.x - fromFrame.origin.x) * progressPercentage selectedBar.frame = CGRect(x: targetFrame.origin.x, y: selectedBar.frame.origin.y, width: targetFrame.size.width, height: selectedBar.frame.size.height) var targetContentOffset: CGFloat = 0.0 if contentSize.width > frame.size.width { let toContentOffset = contentOffsetForCell(withFrame: toFrame, andIndex: toIndex) let fromContentOffset = contentOffsetForCell(withFrame: fromFrame, andIndex: fromIndex) targetContentOffset = fromContentOffset + ((toContentOffset - fromContentOffset) * progressPercentage) } setContentOffset(CGPoint(x: targetContentOffset, y: 0), animated: false) } open func updateSelectedBarPosition(_ animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) { var selectedBarFrame = selectedBar.frame let selectedCellIndexPath = IndexPath(item: selectedIndex, section: 0) let attributes = layoutAttributesForItem(at: selectedCellIndexPath) let selectedCellFrame = attributes!.frame updateContentOffset(animated: animated, pagerScroll: pagerScroll, toFrame: selectedCellFrame, toIndex: (selectedCellIndexPath as NSIndexPath).row) selectedBarFrame.size.width = selectedCellFrame.size.width selectedBarFrame.origin.x = selectedCellFrame.origin.x if animated { UIView.animate(withDuration: 0.3, animations: { [weak self] in self?.selectedBar.frame = selectedBarFrame }) } else { selectedBar.frame = selectedBarFrame } } // MARK: - Helpers 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 // swiftlint:disable:this force_cast var alignmentOffset: CGFloat = 0.0 switch selectedBarAlignment { case .left: alignmentOffset = sectionInset.left case .right: alignmentOffset = frame.size.width - sectionInset.right - cellFrame.size.width case .center: alignmentOffset = (frame.size.width - cellFrame.size.width) * 0.5 case .progressive: let cellHalfWidth = cellFrame.size.width * 0.5 let leftAlignmentOffset = sectionInset.left + cellHalfWidth let rightAlignmentOffset = frame.size.width - sectionInset.right - cellHalfWidth let numberOfItems = dataSource!.collectionView(self, numberOfItemsInSection: 0) let progress = index / (numberOfItems - 1) alignmentOffset = leftAlignmentOffset + (rightAlignmentOffset - leftAlignmentOffset) * CGFloat(progress) - cellHalfWidth } var contentOffset = cellFrame.origin.x - alignmentOffset contentOffset = max(0, contentOffset) contentOffset = min(contentSize.width - frame.size.width, contentOffset) return contentOffset } private func updateSelectedBarYPosition() { var selectedBarFrame = selectedBar.frame switch selectedBarVerticalAlignment { case .top: selectedBarFrame.origin.y = 0 case .middle: selectedBarFrame.origin.y = (frame.size.height - selectedBarHeight) / 2 case .bottom: selectedBarFrame.origin.y = frame.size.height - selectedBarHeight } selectedBarFrame.size.height = selectedBarHeight selectedBar.frame = selectedBarFrame } override open func layoutSubviews() { super.layoutSubviews() updateSelectedBarYPosition() } } ================================================ FILE: Sources/XLPagerTabStrip/ButtonBarViewCell.swift ================================================ // ButtonBarViewCell.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import UIKit import Foundation open class ButtonBarViewCell: UICollectionViewCell { @IBOutlet open var imageView: UIImageView! @IBOutlet open var label: UILabel! public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) isAccessibilityElement = true accessibilityTraits.insert([.button, .header]) } open override var isSelected: Bool { get { return super.isSelected } set { super.isSelected = newValue if (newValue) { accessibilityTraits.insert(.selected) } else { accessibilityTraits.remove(.selected) } } } } ================================================ FILE: Sources/XLPagerTabStrip/IndicatorInfo.swift ================================================ // IndicatorInfo.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit public struct IndicatorInfo { public var title: String? public var image: UIImage? public var highlightedImage: UIImage? public var accessibilityLabel: String? public var userInfo: Any? public init(title: String?) { self.title = title self.accessibilityLabel = title } public init(image: UIImage?, highlightedImage: UIImage? = nil, userInfo: Any? = nil) { self.image = image self.highlightedImage = highlightedImage self.userInfo = userInfo } public init(title: String?, image: UIImage?, highlightedImage: UIImage? = nil, userInfo: Any? = nil) { self.title = title self.accessibilityLabel = title self.image = image self.highlightedImage = highlightedImage self.userInfo = userInfo } public init(title: String?, accessibilityLabel:String?, image: UIImage?, highlightedImage: UIImage? = nil, userInfo: Any? = nil) { self.title = title self.accessibilityLabel = accessibilityLabel self.image = image self.highlightedImage = highlightedImage self.userInfo = userInfo } } extension IndicatorInfo : ExpressibleByStringLiteral { public init(stringLiteral value: String) { title = value accessibilityLabel = value } public init(extendedGraphemeClusterLiteral value: String) { title = value accessibilityLabel = value } public init(unicodeScalarLiteral value: String) { title = value accessibilityLabel = value } } ================================================ FILE: Sources/XLPagerTabStrip/PagerTabStripBehaviour.swift ================================================ // PagerTabStripOptions.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation public enum PagerTabStripBehaviour { case common(skipIntermediateViewControllers: Bool) case progressive(skipIntermediateViewControllers: Bool, elasticIndicatorLimit: Bool) public var skipIntermediateViewControllers: Bool { switch self { case .common(let skipIntermediateViewControllers): return skipIntermediateViewControllers case .progressive(let skipIntermediateViewControllers, _): return skipIntermediateViewControllers } } public var isProgressiveIndicator: Bool { switch self { case .common: return false case .progressive: return true } } public var isElasticIndicatorLimit: Bool { switch self { case .common: return false case .progressive(_, let elasticIndicatorLimit): return elasticIndicatorLimit } } } ================================================ FILE: Sources/XLPagerTabStrip/PagerTabStripError.swift ================================================ // PagerTabStripError.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation public enum PagerTabStripError: Error { case viewControllerOutOfBounds } ================================================ FILE: Sources/XLPagerTabStrip/PagerTabStripViewController.swift ================================================ // PagerTabStripViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit // MARK: Protocols public protocol IndicatorInfoProvider { func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo } public protocol PagerTabStripDelegate: AnyObject { func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int) } public protocol PagerTabStripIsProgressiveDelegate: PagerTabStripDelegate { func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) } public protocol PagerTabStripDataSource: AnyObject { func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] } // MARK: PagerTabStripViewController open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { @IBOutlet weak public var containerView: UIScrollView! open weak var delegate: PagerTabStripDelegate? open weak var datasource: PagerTabStripDataSource? open var pagerBehaviour = PagerTabStripBehaviour.progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true) open private(set) var viewControllers = [UIViewController]() open private(set) var currentIndex = 0 open private(set) var preCurrentIndex = 0 // used *only* to store the index to which move when the pager becomes visible open var pageWidth: CGFloat { return containerView.bounds.width } open var scrollPercentage: CGFloat { if swipeDirection != .right { let module = fmod(containerView.contentOffset.x, pageWidth) return module == 0.0 ? 1.0 : module / pageWidth } return 1 - fmod(containerView.contentOffset.x >= 0 ? containerView.contentOffset.x : pageWidth + containerView.contentOffset.x, pageWidth) / pageWidth } open var swipeDirection: SwipeDirection { if containerView.contentOffset.x > lastContentOffset { return .left } else if containerView.contentOffset.x < lastContentOffset { return .right } return .none } override open func viewDidLoad() { super.viewDidLoad() let conteinerViewAux = containerView ?? { let containerView = UIScrollView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height)) containerView.autoresizingMask = [.flexibleWidth, .flexibleHeight] return containerView }() containerView = conteinerViewAux if containerView.superview == nil { view.addSubview(containerView) } containerView.bounces = true containerView.alwaysBounceHorizontal = true containerView.alwaysBounceVertical = false containerView.scrollsToTop = false containerView.delegate = self containerView.showsVerticalScrollIndicator = false containerView.showsHorizontalScrollIndicator = false containerView.isPagingEnabled = true reloadViewControllers() let childController = viewControllers[currentIndex] addChild(childController) childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth] containerView.addSubview(childController.view) childController.didMove(toParent: self) } open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) isViewAppearing = true children.forEach { $0.beginAppearanceTransition(true, animated: animated) } } override open func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) lastSize = containerView.bounds.size updateIfNeeded() let needToUpdateCurrentChild = preCurrentIndex != currentIndex if needToUpdateCurrentChild { moveToViewController(at: preCurrentIndex) } isViewAppearing = false children.forEach { $0.endAppearanceTransition() } } open override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) children.forEach { $0.beginAppearanceTransition(false, animated: animated) } } open override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) children.forEach { $0.endAppearanceTransition() } } override open func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() updateIfNeeded() } open override var shouldAutomaticallyForwardAppearanceMethods: Bool { return false } open func moveToViewController(at index: Int, animated: Bool = true) { guard isViewLoaded && view.window != nil && currentIndex != index else { preCurrentIndex = index return } if animated && pagerBehaviour.skipIntermediateViewControllers && abs(currentIndex - index) > 1 { var tmpViewControllers = viewControllers let currentChildVC = viewControllers[currentIndex] let fromIndex = currentIndex < index ? index - 1 : index + 1 let fromChildVC = viewControllers[fromIndex] tmpViewControllers[currentIndex] = fromChildVC tmpViewControllers[fromIndex] = currentChildVC pagerTabStripChildViewControllersForScrolling = tmpViewControllers 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 { (navigationController?.view ?? view).isUserInteractionEnabled = !animated containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: animated) } } open func moveTo(viewController: UIViewController, animated: Bool = true) { moveToViewController(at: viewControllers.firstIndex(of: viewController)!, animated: animated) } // MARK: - PagerTabStripDataSource open func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { assertionFailure("Sub-class must implement the PagerTabStripDataSource viewControllers(for:) method") return [] } // MARK: - Helpers open func updateIfNeeded() { if isViewLoaded && !lastSize.equalTo(containerView.bounds.size) { updateContent() } } open func canMoveTo(index: Int) -> Bool { return currentIndex != index && viewControllers.count > index } open func pageOffsetForChild(at index: Int) -> CGFloat { return CGFloat(index) * containerView.bounds.width } 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 { guard let index = viewControllers.firstIndex(of: viewController) else { throw PagerTabStripError.viewControllerOutOfBounds } return offsetForChild(at: index) } open func pageFor(contentOffset: CGFloat) -> Int { let result = virtualPageFor(contentOffset: contentOffset) return pageFor(virtualPage: result) } open func virtualPageFor(contentOffset: CGFloat) -> Int { return Int((contentOffset + 1.5 * pageWidth) / pageWidth) - 1 } open func pageFor(virtualPage: Int) -> Int { if virtualPage < 0 { return 0 } if virtualPage > viewControllers.count - 1 { return viewControllers.count - 1 } return virtualPage } open func updateContent() { if lastSize.width != containerView.bounds.size.width { lastSize = containerView.bounds.size containerView.contentOffset = CGPoint(x: pageOffsetForChild(at: currentIndex), y: 0) } lastSize = containerView.bounds.size let pagerViewControllers = pagerTabStripChildViewControllersForScrolling ?? viewControllers containerView.contentSize = CGSize(width: containerView.bounds.width * CGFloat(pagerViewControllers.count), height: containerView.contentSize.height) for (index, childController) in pagerViewControllers.enumerated() { let pageOffsetForChild = self.pageOffsetForChild(at: index) 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) 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(toParent: self) childController.endAppearanceTransition() } } else { if childController.parent != nil { childController.beginAppearanceTransition(false, animated: false) childController.willMove(toParent: nil) childController.view.removeFromSuperview() childController.removeFromParent() childController.endAppearanceTransition() } } } let oldCurrentIndex = currentIndex let virtualPage = virtualPageFor(contentOffset: containerView.contentOffset.x) let newCurrentIndex = pageFor(virtualPage: virtualPage) currentIndex = newCurrentIndex preCurrentIndex = currentIndex let changeCurrentIndex = newCurrentIndex != oldCurrentIndex if let progressiveDelegate = self as? PagerTabStripIsProgressiveDelegate, pagerBehaviour.isProgressiveIndicator { let (fromIndex, toIndex, scrollPercentage) = progressiveIndicatorData(virtualPage) 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 where childController.parent != nil { childController.beginAppearanceTransition(false, animated: false) childController.willMove(toParent: nil) childController.view.removeFromSuperview() childController.removeFromParent() childController.endAppearanceTransition() } reloadViewControllers() containerView.contentSize = CGSize(width: containerView.bounds.width * CGFloat(viewControllers.count), height: containerView.contentSize.height) if currentIndex >= viewControllers.count { currentIndex = viewControllers.count - 1 } preCurrentIndex = currentIndex containerView.contentOffset = CGPoint(x: pageOffsetForChild(at: currentIndex), y: 0) updateContent() } // MARK: - UIScrollViewDelegate open func scrollViewDidScroll(_ scrollView: UIScrollView) { if containerView == scrollView { updateContent() lastContentOffset = scrollView.contentOffset.x } } open func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { if containerView == scrollView { lastPageNumber = pageFor(contentOffset: scrollView.contentOffset.x) } } open func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { if containerView == scrollView { pagerTabStripChildViewControllersForScrolling = nil (navigationController?.view ?? view).isUserInteractionEnabled = true updateContent() } } // MARK: - Orientation open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) isViewRotating = true pageBeforeRotate = currentIndex coordinator.animate(alongsideTransition: nil) { [weak self] _ in guard let me = self else { return } me.isViewRotating = false me.currentIndex = me.pageBeforeRotate me.preCurrentIndex = me.currentIndex me.updateIfNeeded() } } // MARK: Private private func progressiveIndicatorData(_ virtualPage: Int) -> (Int, Int, CGFloat) { let count = viewControllers.count var fromIndex = currentIndex var toIndex = currentIndex let direction = swipeDirection if direction == .left { if virtualPage > count - 1 { fromIndex = count - 1 toIndex = count } else { if self.scrollPercentage >= 0.5 { fromIndex = max(toIndex - 1, 0) } else { toIndex = fromIndex + 1 } } } else if direction == .right { if virtualPage < 0 { fromIndex = 0 toIndex = -1 } else { if self.scrollPercentage > 0.5 { fromIndex = min(toIndex + 1, count - 1) } else { toIndex = fromIndex - 1 } } } let scrollPercentage = pagerBehaviour.isElasticIndicatorLimit ? self.scrollPercentage : ((toIndex < 0 || toIndex >= count) ? 0.0 : self.scrollPercentage) return (fromIndex, toIndex, scrollPercentage) } private func reloadViewControllers() { guard let dataSource = datasource else { fatalError("dataSource must not be nil") } viewControllers = dataSource.viewControllers(for: self) // viewControllers 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 IndicatorInfoProvider") }} } private var pagerTabStripChildViewControllersForScrolling: [UIViewController]? private var lastPageNumber = 0 private var lastContentOffset: CGFloat = 0.0 private var pageBeforeRotate = 0 private var lastSize = CGSize(width: 0, height: 0) internal var isViewRotating = false internal var isViewAppearing = false } ================================================ FILE: Sources/XLPagerTabStrip/Resources/ButtonCell.xib ================================================ ================================================ FILE: Sources/XLPagerTabStrip/SegmentedPagerTabStripViewController.swift ================================================ // SegmentedPagerTabStripViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit public struct SegmentedPagerTabStripSettings { public struct Style { public var segmentedControlColor: UIColor? } public var style = Style() } open class SegmentedPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripDelegate { @IBOutlet weak public var segmentedControl: UISegmentedControl! open var settings = SegmentedPagerTabStripSettings() public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) pagerBehaviour = PagerTabStripBehaviour.common(skipIntermediateViewControllers: true) delegate = self datasource = self } required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) pagerBehaviour = PagerTabStripBehaviour.common(skipIntermediateViewControllers: true) delegate = self datasource = self } private(set) var shouldUpdateSegmentedControl = true open override func viewDidLoad() { super.viewDidLoad() let auxSegmentedControl = segmentedControl ?? UISegmentedControl() segmentedControl = auxSegmentedControl if segmentedControl.superview == nil { navigationItem.titleView = segmentedControl } segmentedControl.tintColor = settings.style.segmentedControlColor ?? segmentedControl.tintColor segmentedControl.addTarget(self, action: #selector(SegmentedPagerTabStripViewController.segmentedControlChanged(_:)), for: .valueChanged) reloadSegmentedControl() } open override func reloadPagerTabStripView() { super.reloadPagerTabStripView() if isViewLoaded { reloadSegmentedControl() } } func reloadSegmentedControl() { segmentedControl.removeAllSegments() 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 { segmentedControl.insertSegment(withTitle: child.indicatorInfo(for: self).title, at: index, animated: false) } } segmentedControl.selectedSegmentIndex = currentIndex } @objc func segmentedControlChanged(_ sender: UISegmentedControl) { let index = sender.selectedSegmentIndex updateIndicator(for: self, fromIndex: currentIndex, toIndex: index) shouldUpdateSegmentedControl = false moveToViewController(at: index) } // MARK: - PagerTabStripDelegate open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int) { if shouldUpdateSegmentedControl { segmentedControl.selectedSegmentIndex = toIndex } } // MARK: - UIScrollViewDelegate open override func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { super.scrollViewDidEndScrollingAnimation(scrollView) shouldUpdateSegmentedControl = true } } ================================================ FILE: Sources/XLPagerTabStrip/SwipeDirection.swift ================================================ // SwipeDirection.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation public enum SwipeDirection { case left case right case none } ================================================ FILE: Sources/XLPagerTabStrip/TwitterPagerTabStripViewController.swift ================================================ // TwitterPagerTabStripViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit #if SWIFT_PACKAGE import FXPageControl #endif public struct TwitterPagerTabStripSettings { public struct Style { public var dotColor = UIColor(white: 1, alpha: 0.4) public var selectedDotColor = UIColor.white public var portraitTitleFont = UIFont.systemFont(ofSize: 18) public var landscapeTitleFont = UIFont.systemFont(ofSize: 15) public var titleColor = UIColor.white } public var style = Style() } open class TwitterPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate { open var settings = TwitterPagerTabStripSettings() public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) pagerBehaviour = .progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true) delegate = self datasource = self } required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) pagerBehaviour = .progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true) delegate = self datasource = self } open override func viewDidLoad() { super.viewDidLoad() if titleView.superview == nil { navigationItem.titleView = titleView } // keep watching the frame of titleView titleView.addObserver(self, forKeyPath: "frame", options: [.new, .old], context: nil) guard let navigationController = navigationController else { fatalError("TwitterPagerTabStripViewController should be embedded in a UINavigationController") } titleView.frame = CGRect(x: 0, y: 0, width: navigationController.navigationBar.frame.width, height: navigationController.navigationBar.frame.height) titleView.addSubview(titleScrollView) titleView.addSubview(pageControl) reloadNavigationViewItems() } open override func reloadPagerTabStripView() { super.reloadPagerTabStripView() guard isViewLoaded else { return } reloadNavigationViewItems() setNavigationViewItemsPosition(updateAlpha: true) } // MARK: - PagerTabStripDelegate open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) { // move indicator scroll view guard let distance = distanceValue else { return } var xOffset: CGFloat = 0 if fromIndex < toIndex { xOffset = distance * CGFloat(fromIndex) + distance * progressPercentage } else if fromIndex > toIndex { xOffset = distance * CGFloat(fromIndex) - distance * progressPercentage } else { xOffset = distance * CGFloat(fromIndex) } titleScrollView.contentOffset = CGPoint(x: xOffset, y: 0) // update alpha of titles setAlphaWith(offset: xOffset, andDistance: distance) // update page control page pageControl.currentPage = currentIndex } open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int) { fatalError() } open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { guard object as AnyObject === titleView && keyPath == "frame" && change?[NSKeyValueChangeKey.kindKey] as? UInt == NSKeyValueChange.setting.rawValue else { return } let oldRect = (change![NSKeyValueChangeKey.oldKey]! as AnyObject).cgRectValue let newRect = (change![NSKeyValueChangeKey.oldKey]! as AnyObject).cgRectValue if (oldRect?.equalTo(newRect!))! { titleScrollView.frame = CGRect(x: 0, y: 0, width: titleView.frame.width, height: titleScrollView.frame.height) setNavigationViewItemsPosition(updateAlpha: true) } } deinit { if isViewLoaded { titleView.removeObserver(self, forKeyPath: "frame") } } open override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() setNavigationViewItemsPosition(updateAlpha: false) } // MARK: - Helpers private lazy var titleView: UIView = { let navigationView = UIView() navigationView.autoresizingMask = [.flexibleWidth, .flexibleHeight] return navigationView }() private lazy var titleScrollView: UIScrollView = { [unowned self] in let titleScrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 44)) titleScrollView.autoresizingMask = [.flexibleWidth, .flexibleHeight] titleScrollView.bounces = true titleScrollView.scrollsToTop = false titleScrollView.delegate = self titleScrollView.showsVerticalScrollIndicator = false titleScrollView.showsHorizontalScrollIndicator = false titleScrollView.isPagingEnabled = true titleScrollView.isUserInteractionEnabled = false titleScrollView.alwaysBounceHorizontal = true titleScrollView.alwaysBounceVertical = false return titleScrollView }() private lazy var pageControl: FXPageControl = { [unowned self] in let pageControl = FXPageControl() pageControl.backgroundColor = .clear pageControl.dotSize = 3.8 pageControl.dotSpacing = 4.0 pageControl.dotColor = self.settings.style.dotColor pageControl.selectedDotColor = self.settings.style.selectedDotColor pageControl.isUserInteractionEnabled = false return pageControl }() private var childTitleLabels = [UILabel]() private func reloadNavigationViewItems() { // remove all child view controller header labels childTitleLabels.forEach { $0.removeFromSuperview() } childTitleLabels.removeAll() for (index, item) in viewControllers.enumerated() { let child = item as! IndicatorInfoProvider // swiftlint:disable:this force_cast let indicatorInfo = child.indicatorInfo(for: self) let navTitleLabel: UILabel = { let label = UILabel() label.text = indicatorInfo.title label.font = UIWindow.isPortrait ? settings.style.portraitTitleFont : settings.style.landscapeTitleFont label.textColor = settings.style.titleColor label.alpha = 0 return label }() navTitleLabel.alpha = currentIndex == index ? 1 : 0 navTitleLabel.textColor = settings.style.titleColor titleScrollView.addSubview(navTitleLabel) childTitleLabels.append(navTitleLabel) } } private func setNavigationViewItemsPosition(updateAlpha: Bool) { guard let distance = distanceValue else { return } let isPortrait = UIWindow.isPortrait let navBarHeight: CGFloat = navigationController!.navigationBar.frame.size.height for (index, label) in childTitleLabels.enumerated() { if updateAlpha { label.alpha = currentIndex == index ? 1 : 0 } label.font = isPortrait ? settings.style.portraitTitleFont : settings.style.landscapeTitleFont let viewSize = label.intrinsicContentSize let originX = distance - viewSize.width/2 + CGFloat(index) * distance let originY = (CGFloat(navBarHeight) - viewSize.height) / 2 label.frame = CGRect(x: originX, y: originY - 2, width: viewSize.width, height: viewSize.height) label.tag = index } let xOffset = distance * CGFloat(currentIndex) titleScrollView.contentOffset = CGPoint(x: xOffset, y: 0) pageControl.numberOfPages = childTitleLabels.count pageControl.currentPage = currentIndex let viewSize = pageControl.sizeForNumber(ofPages: childTitleLabels.count) let originX = distance - viewSize.width / 2 pageControl.frame = CGRect(x: originX, y: navBarHeight - 10, width: viewSize.width, height: viewSize.height) } private func setAlphaWith(offset: CGFloat, andDistance distance: CGFloat) { for (index, label) in childTitleLabels.enumerated() { label.alpha = { if offset < distance * CGFloat(index) { return (offset - distance * CGFloat(index - 1)) / distance } else { return 1 - ((offset - distance * CGFloat(index)) / distance) } }() } } private var distanceValue: CGFloat? { return navigationController.map { $0.navigationBar.convert($0.navigationBar.center, to: titleView) }?.x } } ================================================ FILE: Sources/XLPagerTabStrip/UIWindow+Pager.swift ================================================ // TwitterPagerTabStripViewController.swift // XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) // // Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) // // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import Foundation import UIKit extension UIWindow { static var isLandscape: Bool { if #available(iOS 13.0, *) { return UIApplication.shared.windows .first? .windowScene? .interfaceOrientation .isLandscape ?? false } else { return UIApplication.shared.statusBarOrientation.isLandscape } } static var isPortrait: Bool { if #available(iOS 13.0, *) { return UIApplication.shared.windows .first? .windowScene? .interfaceOrientation .isPortrait ?? false } else { return UIApplication.shared.statusBarOrientation.isPortrait } } } ================================================ FILE: Tests/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType BNDL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1 ================================================ FILE: Tests/XLPagerTabStripTests.swift ================================================ // // XLPagerTabStripTests.swift // XLPagerTabStripTests // // Copyright © 2016 Xmartlabs SRL. All rights reserved. // import XCTest @testable import XLPagerTabStrip class XLPagerTabStripTests: XCTestCase { override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. } override func tearDown() { // Put teardown code here. This method is called after the invocation of each test method in the class. super.tearDown() } func testExample() { // This is an example of a functional test case. // Use XCTAssert and related functions to verify your tests produce the correct results. } func testPerformanceExample() { // This is an example of a performance test case. self.measure { // Put the code you want to measure the time of here. } } } ================================================ FILE: XLPagerTabStrip/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType FMWK CFBundleShortVersionString 9.0.0 CFBundleSignature ???? CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass ================================================ FILE: XLPagerTabStrip/XLPagerTabStrip.h ================================================ // // XLPagerTabStrip.h // XLPagerTabStrip // // Copyright © 2016 Xmartlabs SRL. All rights reserved. // #import //! Project version number for XLPagerTabStrip. FOUNDATION_EXPORT double XLPagerTabStripVersionNumber; //! Project version string for XLPagerTabStrip. FOUNDATION_EXPORT const unsigned char XLPagerTabStripVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import #import "FXPageControl.h" ================================================ FILE: XLPagerTabStrip.podspec ================================================ Pod::Spec.new do |s| s.name = "XLPagerTabStrip" s.version = "9.1.0" s.summary = "Android PagerTabStrip for iOS and much more." s.homepage = "https://github.com/xmartlabs/XLPagerTabStrip" s.license = { type: 'MIT', file: 'LICENSE' } s.author = { "Martin Barreto" => "martin@xmartlabs.com" } s.source = { git: "https://github.com/xmartlabs/XLPagerTabStrip.git", tag: s.version.to_s } s.social_media_url = 'https://twitter.com/xmartlabs' s.ios.deployment_target = '11.0' s.requires_arc = true s.ios.source_files = 'Sources/**/*.{swift}', 'ObjC/*.{h,m}' s.ios.frameworks = 'UIKit', 'Foundation' s.resource_bundles = { 'XLPagerTabStrip' => ['Sources/**/ButtonCell.xib'] } s.swift_version = "5.0" end ================================================ FILE: XLPagerTabStrip.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 48; objects = { /* Begin PBXBuildFile section */ 281BFDC11C511C420090C26F /* IndicatorInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 281BFDC01C511C420090C26F /* IndicatorInfo.swift */; }; 281BFDC31C511F120090C26F /* PagerTabStripBehaviour.swift in Sources */ = {isa = PBXBuildFile; fileRef = 281BFDC21C511F120090C26F /* PagerTabStripBehaviour.swift */; }; 287D0A6E1C4B73BD004566D6 /* XLPagerTabStripTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 287D0A6D1C4B73BD004566D6 /* XLPagerTabStripTests.swift */; }; 28C83C841C54229A000B2902 /* BaseButtonBarPagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28C83C831C54229A000B2902 /* BaseButtonBarPagerTabStripViewController.swift */; }; 28E098BE1C5002D90083B788 /* PagerTabStripError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28E098BD1C5002D90083B788 /* PagerTabStripError.swift */; }; 28E098C01C5003130083B788 /* SwipeDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28E098BF1C5003130083B788 /* SwipeDirection.swift */; }; 28F828811C494B2C00330CF4 /* XLPagerTabStrip.h in Headers */ = {isa = PBXBuildFile; fileRef = 28F828801C494B2C00330CF4 /* XLPagerTabStrip.h */; settings = {ATTRIBUTES = (Public, ); }; }; 28F828881C494B2C00330CF4 /* XLPagerTabStrip.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28F8287D1C494B2C00330CF4 /* XLPagerTabStrip.framework */; }; 3174BB1228E2B81700847CF0 /* FXPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 3174BB1028E2B81700847CF0 /* FXPageControl.m */; }; 3174BB1328E2B81700847CF0 /* FXPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 3174BB1128E2B81700847CF0 /* FXPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3174BB1828E2C46A00847CF0 /* ButtonCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3174BB1728E2C46A00847CF0 /* ButtonCell.xib */; }; CB0986C41C51391600DF7087 /* ButtonBarPagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB0986C31C51391600DF7087 /* ButtonBarPagerTabStripViewController.swift */; }; CB0986C61C51395E00DF7087 /* ButtonBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB0986C51C51395E00DF7087 /* ButtonBarView.swift */; }; CB0986C81C5158A000DF7087 /* ButtonBarViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB0986C71C5158A000DF7087 /* ButtonBarViewCell.swift */; }; CB71C6EE1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB71C6ED1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift */; }; CB86ED6B1C4D6E6C00DA463B /* PagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB86ED6A1C4D6E6C00DA463B /* PagerTabStripViewController.swift */; }; CBA0A1FC1C502DA300C5748C /* BarPagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBA0A1FA1C502DA300C5748C /* BarPagerTabStripViewController.swift */; }; CBA0A1FD1C502DA300C5748C /* BarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBA0A1FB1C502DA300C5748C /* BarView.swift */; }; CBBD43621C527E80001A748E /* TwitterPagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBBD43611C527E80001A748E /* TwitterPagerTabStripViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 28F828891C494B2C00330CF4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 28F828741C494B2C00330CF4 /* Project object */; proxyType = 1; remoteGlobalIDString = 28F8287C1C494B2C00330CF4; remoteInfo = XLPagerTabStrip; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 281BFDC01C511C420090C26F /* IndicatorInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndicatorInfo.swift; sourceTree = ""; }; 281BFDC21C511F120090C26F /* PagerTabStripBehaviour.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PagerTabStripBehaviour.swift; sourceTree = ""; }; 287D0A6D1C4B73BD004566D6 /* XLPagerTabStripTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = XLPagerTabStripTests.swift; path = Tests/XLPagerTabStripTests.swift; sourceTree = SOURCE_ROOT; }; 28C83C831C54229A000B2902 /* BaseButtonBarPagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseButtonBarPagerTabStripViewController.swift; sourceTree = ""; }; 28E098BD1C5002D90083B788 /* PagerTabStripError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PagerTabStripError.swift; sourceTree = ""; }; 28E098BF1C5003130083B788 /* SwipeDirection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeDirection.swift; sourceTree = ""; }; 28F8287D1C494B2C00330CF4 /* XLPagerTabStrip.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = XLPagerTabStrip.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 28F828801C494B2C00330CF4 /* XLPagerTabStrip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XLPagerTabStrip.h; sourceTree = ""; }; 28F828821C494B2C00330CF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28F828871C494B2C00330CF4 /* XLPagerTabStripTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XLPagerTabStripTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 28F8288E1C494B2C00330CF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28F8289B1C494BF100330CF4 /* Playground.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Playground.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 3174BB1028E2B81700847CF0 /* FXPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FXPageControl.m; sourceTree = ""; }; 3174BB1128E2B81700847CF0 /* FXPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FXPageControl.h; sourceTree = ""; }; 3174BB1728E2C46A00847CF0 /* ButtonCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ButtonCell.xib; sourceTree = ""; }; CB0986C31C51391600DF7087 /* ButtonBarPagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonBarPagerTabStripViewController.swift; sourceTree = ""; }; CB0986C51C51395E00DF7087 /* ButtonBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonBarView.swift; sourceTree = ""; }; CB0986C71C5158A000DF7087 /* ButtonBarViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonBarViewCell.swift; sourceTree = ""; }; CB71C6ED1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegmentedPagerTabStripViewController.swift; sourceTree = ""; }; CB86ED6A1C4D6E6C00DA463B /* PagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = PagerTabStripViewController.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; CBA0A1FA1C502DA300C5748C /* BarPagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarPagerTabStripViewController.swift; sourceTree = ""; }; CBA0A1FB1C502DA300C5748C /* BarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarView.swift; sourceTree = ""; }; CBBD43611C527E80001A748E /* TwitterPagerTabStripViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwitterPagerTabStripViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 28F828791C494B2C00330CF4 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 28F828841C494B2C00330CF4 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 28F828881C494B2C00330CF4 /* XLPagerTabStrip.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 281BFDBE1C511B890090C26F /* Views */ = { isa = PBXGroup; children = ( CBA0A1FB1C502DA300C5748C /* BarView.swift */, CB0986C51C51395E00DF7087 /* ButtonBarView.swift */, CB0986C71C5158A000DF7087 /* ButtonBarViewCell.swift */, ); name = Views; sourceTree = ""; }; 281BFDBF1C511B9A0090C26F /* Controllers */ = { isa = PBXGroup; children = ( CBA0A1FA1C502DA300C5748C /* BarPagerTabStripViewController.swift */, CB86ED6A1C4D6E6C00DA463B /* PagerTabStripViewController.swift */, CB71C6ED1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift */, CB0986C31C51391600DF7087 /* ButtonBarPagerTabStripViewController.swift */, CBBD43611C527E80001A748E /* TwitterPagerTabStripViewController.swift */, 28C83C831C54229A000B2902 /* BaseButtonBarPagerTabStripViewController.swift */, ); name = Controllers; sourceTree = ""; }; 28F828731C494B2C00330CF4 = { isa = PBXGroup; children = ( 28F8289B1C494BF100330CF4 /* Playground.playground */, 28F828971C494B4200330CF4 /* Sources */, 28F8287F1C494B2C00330CF4 /* XLPagerTabStrip */, 28F8288B1C494B2C00330CF4 /* Tests */, 28F8287E1C494B2C00330CF4 /* Products */, ); sourceTree = ""; }; 28F8287E1C494B2C00330CF4 /* Products */ = { isa = PBXGroup; children = ( 28F8287D1C494B2C00330CF4 /* XLPagerTabStrip.framework */, 28F828871C494B2C00330CF4 /* XLPagerTabStripTests.xctest */, ); name = Products; sourceTree = ""; }; 28F8287F1C494B2C00330CF4 /* XLPagerTabStrip */ = { isa = PBXGroup; children = ( 28F828801C494B2C00330CF4 /* XLPagerTabStrip.h */, 28F828821C494B2C00330CF4 /* Info.plist */, ); path = XLPagerTabStrip; sourceTree = ""; }; 28F8288B1C494B2C00330CF4 /* Tests */ = { isa = PBXGroup; children = ( 28F8288E1C494B2C00330CF4 /* Info.plist */, 287D0A6D1C4B73BD004566D6 /* XLPagerTabStripTests.swift */, ); path = Tests; sourceTree = ""; }; 28F828971C494B4200330CF4 /* Sources */ = { isa = PBXGroup; children = ( 3174BB0F28E2B81700847CF0 /* ObjC */, 3174BB1628E2C46A00847CF0 /* Resources */, 281BFDBF1C511B9A0090C26F /* Controllers */, 281BFDBE1C511B890090C26F /* Views */, 28E098BD1C5002D90083B788 /* PagerTabStripError.swift */, 28E098BF1C5003130083B788 /* SwipeDirection.swift */, 281BFDC01C511C420090C26F /* IndicatorInfo.swift */, 281BFDC21C511F120090C26F /* PagerTabStripBehaviour.swift */, ); name = Sources; path = Sources/XLPagerTabStrip; sourceTree = ""; }; 3174BB0F28E2B81700847CF0 /* ObjC */ = { isa = PBXGroup; children = ( 3174BB1028E2B81700847CF0 /* FXPageControl.m */, 3174BB1128E2B81700847CF0 /* FXPageControl.h */, ); path = ObjC; sourceTree = SOURCE_ROOT; }; 3174BB1628E2C46A00847CF0 /* Resources */ = { isa = PBXGroup; children = ( 3174BB1728E2C46A00847CF0 /* ButtonCell.xib */, ); name = Resources; path = Sources/XLPagerTabStrip/Resources; sourceTree = SOURCE_ROOT; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 28F8287A1C494B2C00330CF4 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 28F828811C494B2C00330CF4 /* XLPagerTabStrip.h in Headers */, 3174BB1328E2B81700847CF0 /* FXPageControl.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 28F8287C1C494B2C00330CF4 /* XLPagerTabStrip */ = { isa = PBXNativeTarget; buildConfigurationList = 28F828911C494B2C00330CF4 /* Build configuration list for PBXNativeTarget "XLPagerTabStrip" */; buildPhases = ( 28F828781C494B2C00330CF4 /* Sources */, 28F828791C494B2C00330CF4 /* Frameworks */, 28F8287A1C494B2C00330CF4 /* Headers */, 28F8287B1C494B2C00330CF4 /* Resources */, CB25B8F81EBCF0CE00FEB0A2 /* SwiftLint */, ); buildRules = ( ); dependencies = ( ); name = XLPagerTabStrip; productName = XLPagerTabStrip; productReference = 28F8287D1C494B2C00330CF4 /* XLPagerTabStrip.framework */; productType = "com.apple.product-type.framework"; }; 28F828861C494B2C00330CF4 /* XLPagerTabStripTests */ = { isa = PBXNativeTarget; buildConfigurationList = 28F828941C494B2C00330CF4 /* Build configuration list for PBXNativeTarget "XLPagerTabStripTests" */; buildPhases = ( 28F828831C494B2C00330CF4 /* Sources */, 28F828841C494B2C00330CF4 /* Frameworks */, 28F828851C494B2C00330CF4 /* Resources */, ); buildRules = ( ); dependencies = ( 28F8288A1C494B2C00330CF4 /* PBXTargetDependency */, ); name = XLPagerTabStripTests; productName = XLPagerTabStripTests; productReference = 28F828871C494B2C00330CF4 /* XLPagerTabStripTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 28F828741C494B2C00330CF4 /* Project object */ = { isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; LastUpgradeCheck = 1020; TargetAttributes = { 28F8287C1C494B2C00330CF4 = { CreatedOnToolsVersion = 7.2; LastSwiftMigration = 1020; ProvisioningStyle = Manual; }; 28F828861C494B2C00330CF4 = { CreatedOnToolsVersion = 7.2; LastSwiftMigration = 1020; }; }; }; buildConfigurationList = 28F828771C494B2C00330CF4 /* Build configuration list for PBXProject "XLPagerTabStrip" */; compatibilityVersion = "Xcode 8.0"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( English, en, ); mainGroup = 28F828731C494B2C00330CF4; productRefGroup = 28F8287E1C494B2C00330CF4 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 28F8287C1C494B2C00330CF4 /* XLPagerTabStrip */, 28F828861C494B2C00330CF4 /* XLPagerTabStripTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 28F8287B1C494B2C00330CF4 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 3174BB1828E2C46A00847CF0 /* ButtonCell.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 28F828851C494B2C00330CF4 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* 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\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 28F828781C494B2C00330CF4 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 28C83C841C54229A000B2902 /* BaseButtonBarPagerTabStripViewController.swift in Sources */, CB0986C61C51395E00DF7087 /* ButtonBarView.swift in Sources */, CBBD43621C527E80001A748E /* TwitterPagerTabStripViewController.swift in Sources */, CBA0A1FD1C502DA300C5748C /* BarView.swift in Sources */, 3174BB1228E2B81700847CF0 /* FXPageControl.m in Sources */, 281BFDC31C511F120090C26F /* PagerTabStripBehaviour.swift in Sources */, CBA0A1FC1C502DA300C5748C /* BarPagerTabStripViewController.swift in Sources */, CB71C6EE1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift in Sources */, 28E098BE1C5002D90083B788 /* PagerTabStripError.swift in Sources */, 281BFDC11C511C420090C26F /* IndicatorInfo.swift in Sources */, CB86ED6B1C4D6E6C00DA463B /* PagerTabStripViewController.swift in Sources */, 28E098C01C5003130083B788 /* SwipeDirection.swift in Sources */, CB0986C81C5158A000DF7087 /* ButtonBarViewCell.swift in Sources */, CB0986C41C51391600DF7087 /* ButtonBarPagerTabStripViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 28F828831C494B2C00330CF4 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 287D0A6E1C4B73BD004566D6 /* XLPagerTabStripTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 28F8288A1C494B2C00330CF4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 28F8287C1C494B2C00330CF4 /* XLPagerTabStrip */; targetProxy = 28F828891C494B2C00330CF4 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ 28F8288F1C494B2C00330CF4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 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_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = 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; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.3; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; name = Debug; }; 28F828901C494B2C00330CF4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 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_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = 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; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; name = Release; }; 28F828921C494B2C00330CF4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { BITCODE_GENERATION_MODE = marker; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CODE_SIGN_STYLE = Manual; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = XLPagerTabStrip/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStrip; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_VERSION = 5.0; }; name = Debug; }; 28F828931C494B2C00330CF4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { BITCODE_GENERATION_MODE = bitcode; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CODE_SIGN_STYLE = Manual; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = XLPagerTabStrip/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStrip; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_VERSION = 5.0; }; name = Release; }; 28F828951C494B2C00330CF4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStripTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; }; name = Debug; }; 28F828961C494B2C00330CF4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStripTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 28F828771C494B2C00330CF4 /* Build configuration list for PBXProject "XLPagerTabStrip" */ = { isa = XCConfigurationList; buildConfigurations = ( 28F8288F1C494B2C00330CF4 /* Debug */, 28F828901C494B2C00330CF4 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 28F828911C494B2C00330CF4 /* Build configuration list for PBXNativeTarget "XLPagerTabStrip" */ = { isa = XCConfigurationList; buildConfigurations = ( 28F828921C494B2C00330CF4 /* Debug */, 28F828931C494B2C00330CF4 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 28F828941C494B2C00330CF4 /* Build configuration list for PBXNativeTarget "XLPagerTabStripTests" */ = { isa = XCConfigurationList; buildConfigurations = ( 28F828951C494B2C00330CF4 /* Debug */, 28F828961C494B2C00330CF4 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 28F828741C494B2C00330CF4 /* Project object */; } ================================================ FILE: XLPagerTabStrip.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: XLPagerTabStrip.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist ================================================ IDEDidComputeMac32BitWarning ================================================ FILE: XLPagerTabStrip.xcodeproj/xcshareddata/xcschemes/XLPagerTabStrip.xcscheme ================================================ ================================================ FILE: XLPagerTabStrip.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: XLPagerTabStrip.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist ================================================ IDEDidComputeMac32BitWarning