diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..2dba349 --- /dev/null +++ b/Podfile @@ -0,0 +1,3 @@ +platform :ios, '7.0' + +pod 'XLDataLoader', '~> 1.1', :inhibit_warnings => true diff --git a/README.md b/README.md new file mode 100644 index 0000000..e4998a8 --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +XLPagerTabStrip +--------------- + +By [XMARTLABS](http://xmartlabs.com). + +Android [XLPagerTabStrip](http://developer.android.com/reference/android/support/v4/view/PagerTabStrip.html) for iOS! + +**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. + +![Screenshot of native Calendar Event Example](XLPagerTabStrip/Demo/PagerSlidingTabStrip.gif) + +Purpose +-------- + **XLPagerTabStrip** helps us deal with view controllers that have the same relevance for the user like Android PagerTabStrip and PageView do. Since you're able to navigate between a large amount of view controllers, XLPagerTabStrip is an scalable and nice solution for this problem. + + +How to use it +-------------- + +Integrate `XLPagerTabStrip` is as easy as following these steps: + +1. Create a UIViewController class that should extend from either `XLSegmentedPagerTabStripViewController`, `XLBarPagerTabStripViewController`, `XLButtonBarPagerTabStripViewController`. + +2. The recently created concrete view controller should conform to `XLPagerTabStripViewControllerDataSource` implementing: `-(NSArray *)childViewControllersForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController;` + +3. (Recomended) Set up your view controllers using a nib file or a Storyboard. We need to connect some IBOutlets (take a look at the [Demo folder](XLPagerTabStrip/Demo)). + +4. Enjoy! + +For further details take a look at the [Demo folder](XLPagerTabStrip/Demo) to see the code of examples shown above. + + +Installation +-------------------------- + +The easiest way to use `XLPagerTabStrip` in your app is via [CocoaPods](http://cocoapods.org/ "CocoaPods"). + +1. Add the following line in the project's Podfile file: +`pod 'XLPagerTabStrip', '~> 1.0.0'`. +2. Run the command `pod install` from the Podfile folder directory. + + +Customization +-------------- + +The most interesting customizable features are: + +* Ability to skip intermediate view controllers when tapped on a "tab". +* Update the bar view indicator either when scroll offset changes or at the middle of the screen. +* Indicators can be added at any position of the screen through storyboard layouts. +* Add space padding between view controllers. + + + +Requirements +----------------------------- + +* ARC +* iOS 7.0 and above + + +Release Notes +-------------- + +Version 1.0.0 (cocoaPod) + +* Initial release + + +Contributors +------------ +* Martin Barreto - [@mtnBarreto](http://twitter.com/mtnBarreto) +* Washington Miranda + + +XLPagerTabStrip was inspired by [Tell Marquet](http://about.tellmarket.com/) app. + +Contact +---------------- + +Any suggestion or question? Please create a Github issue or reach us out. + +[xmartlabs.com](http://xmartlabs.com). +[@xmartlabs](http://twitter.com/xmartlabs "@xmartlabs") diff --git a/XLPagerTabStrip.podspec b/XLPagerTabStrip.podspec new file mode 100644 index 0000000..50e7f78 --- /dev/null +++ b/XLPagerTabStrip.podspec @@ -0,0 +1,15 @@ +Pod::Spec.new do |s| + s.name = 'XLPagerTabStrip' + s.version = '1.0.0' + s.license = 'MIT' + s.summary = 'Android PagerTabStrip for iOS and much more!' + s.description = <<-DESC + DESC + s.homepage = 'https://github.com/xmartlabs/XLPagerTabStrip' + s.authors = { 'Martin Barreto' => 'martin@xmartlabs.com', 'Washington Miranda' => 'mirandaacevedo@gmail.com' } + s.source = { :git => 'https://github.com/xmartlabs/XLPagerTabStrip.git', :tag => 'v1.0.0' } + s.source_files = 'XLPagerTabStrip/XL/**/*.{h,m}' + s.requires_arc = true + s.ios.deployment_target = '7.0' + s.ios.frameworks = 'UIKit', 'Foundation' +end diff --git a/XLPagerTabStrip.xcodeproj/project.pbxproj b/XLPagerTabStrip.xcodeproj/project.pbxproj new file mode 100644 index 0000000..0382f35 --- /dev/null +++ b/XLPagerTabStrip.xcodeproj/project.pbxproj @@ -0,0 +1,559 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 28B63A8C1A459F5900225C66 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63A8B1A459F5900225C66 /* main.m */; }; + 28B63A8F1A459F5900225C66 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63A8E1A459F5900225C66 /* AppDelegate.m */; }; + 28B63A971A459F5900225C66 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 28B63A961A459F5900225C66 /* Images.xcassets */; }; + 28B63AA61A459F5900225C66 /* XLPagerTabStripTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AA51A459F5900225C66 /* XLPagerTabStripTests.m */; }; + 28B63AC31A45A4C500225C66 /* BarExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AB11A45A4C500225C66 /* BarExampleViewController.m */; }; + 28B63AC41A45A4C500225C66 /* ButtonBarExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AB31A45A4C500225C66 /* ButtonBarExampleViewController.m */; }; + 28B63AC51A45A4C500225C66 /* MailBoxChildViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AB61A45A4C500225C66 /* MailBoxChildViewController.m */; }; + 28B63AC61A45A4C500225C66 /* MailBoxTableChildViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AB81A45A4C500225C66 /* MailBoxTableChildViewController.m */; }; + 28B63AC71A45A4C500225C66 /* PostCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63ABB1A45A4C500225C66 /* PostCell.m */; }; + 28B63AC81A45A4C500225C66 /* XLJSONSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63ABE1A45A4C500225C66 /* XLJSONSerialization.m */; }; + 28B63AC91A45A4C500225C66 /* PagerSlidingTabStrip.gif in Resources */ = {isa = PBXBuildFile; fileRef = 28B63ABF1A45A4C500225C66 /* PagerSlidingTabStrip.gif */; }; + 28B63ACA1A45A4C500225C66 /* SegmentedExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AC11A45A4C500225C66 /* SegmentedExampleViewController.m */; }; + 28B63ACB1A45A4C500225C66 /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 28B63AC21A45A4C500225C66 /* Storyboard.storyboard */; }; + 28B63ADC1A45A4CD00225C66 /* XLBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63ACF1A45A4CD00225C66 /* XLBarView.m */; }; + 28B63ADD1A45A4CD00225C66 /* XLButtonBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AD11A45A4CD00225C66 /* XLButtonBarView.m */; }; + 28B63ADE1A45A4CD00225C66 /* XLButtonBarViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AD31A45A4CD00225C66 /* XLButtonBarViewCell.m */; }; + 28B63AE51A45A8EE00225C66 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28B63AE31A45A8EE00225C66 /* LaunchScreen.xib */; }; + 28B63AEF1A45B26600225C66 /* XLBarPagerTabStripViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AE81A45B26600225C66 /* XLBarPagerTabStripViewController.m */; }; + 28B63AF01A45B26600225C66 /* XLButtonBarPagerTabStripViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AEA1A45B26600225C66 /* XLButtonBarPagerTabStripViewController.m */; }; + 28B63AF11A45B26600225C66 /* XLPagerTabStripViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AEC1A45B26600225C66 /* XLPagerTabStripViewController.m */; }; + 28B63AF21A45B26600225C66 /* XLSegmentedPagerTabStripViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28B63AEE1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 28B63AA01A459F5900225C66 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 28B63A7E1A459F5900225C66 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 28B63A851A459F5900225C66; + remoteInfo = XLPagerTabStrip; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 28B63A861A459F5900225C66 /* XLPagerTabStrip.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XLPagerTabStrip.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 28B63A8A1A459F5900225C66 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 28B63A8B1A459F5900225C66 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 28B63A8D1A459F5900225C66 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 28B63A8E1A459F5900225C66 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 28B63A961A459F5900225C66 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 28B63A9F1A459F5900225C66 /* XLPagerTabStripTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XLPagerTabStripTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 28B63AA41A459F5900225C66 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 28B63AA51A459F5900225C66 /* XLPagerTabStripTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XLPagerTabStripTests.m; sourceTree = ""; }; + 28B63AB01A45A4C500225C66 /* BarExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BarExampleViewController.h; sourceTree = ""; }; + 28B63AB11A45A4C500225C66 /* BarExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BarExampleViewController.m; sourceTree = ""; }; + 28B63AB21A45A4C500225C66 /* ButtonBarExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonBarExampleViewController.h; sourceTree = ""; }; + 28B63AB31A45A4C500225C66 /* ButtonBarExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ButtonBarExampleViewController.m; sourceTree = ""; }; + 28B63AB51A45A4C500225C66 /* MailBoxChildViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MailBoxChildViewController.h; sourceTree = ""; }; + 28B63AB61A45A4C500225C66 /* MailBoxChildViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MailBoxChildViewController.m; sourceTree = ""; }; + 28B63AB71A45A4C500225C66 /* MailBoxTableChildViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MailBoxTableChildViewController.h; sourceTree = ""; }; + 28B63AB81A45A4C500225C66 /* MailBoxTableChildViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MailBoxTableChildViewController.m; sourceTree = ""; }; + 28B63ABA1A45A4C500225C66 /* PostCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PostCell.h; sourceTree = ""; }; + 28B63ABB1A45A4C500225C66 /* PostCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PostCell.m; sourceTree = ""; }; + 28B63ABD1A45A4C500225C66 /* XLJSONSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XLJSONSerialization.h; sourceTree = ""; }; + 28B63ABE1A45A4C500225C66 /* XLJSONSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XLJSONSerialization.m; sourceTree = ""; }; + 28B63ABF1A45A4C500225C66 /* PagerSlidingTabStrip.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = PagerSlidingTabStrip.gif; sourceTree = ""; }; + 28B63AC01A45A4C500225C66 /* SegmentedExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SegmentedExampleViewController.h; sourceTree = ""; }; + 28B63AC11A45A4C500225C66 /* SegmentedExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SegmentedExampleViewController.m; sourceTree = ""; }; + 28B63AC21A45A4C500225C66 /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard.storyboard; sourceTree = ""; }; + 28B63ACE1A45A4CD00225C66 /* XLBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XLBarView.h; sourceTree = ""; }; + 28B63ACF1A45A4CD00225C66 /* XLBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XLBarView.m; sourceTree = ""; }; + 28B63AD01A45A4CD00225C66 /* XLButtonBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XLButtonBarView.h; sourceTree = ""; }; + 28B63AD11A45A4CD00225C66 /* XLButtonBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XLButtonBarView.m; sourceTree = ""; }; + 28B63AD21A45A4CD00225C66 /* XLButtonBarViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XLButtonBarViewCell.h; sourceTree = ""; }; + 28B63AD31A45A4CD00225C66 /* XLButtonBarViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XLButtonBarViewCell.m; sourceTree = ""; }; + 28B63AE41A45A8EE00225C66 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = XLPagerTabStrip/Base.lproj/LaunchScreen.xib; sourceTree = SOURCE_ROOT; }; + 28B63AE71A45B26600225C66 /* XLBarPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLBarPagerTabStripViewController.h; path = Controllers/XLBarPagerTabStripViewController.h; sourceTree = ""; }; + 28B63AE81A45B26600225C66 /* XLBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLBarPagerTabStripViewController.m; path = Controllers/XLBarPagerTabStripViewController.m; sourceTree = ""; }; + 28B63AE91A45B26600225C66 /* XLButtonBarPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLButtonBarPagerTabStripViewController.h; path = Controllers/XLButtonBarPagerTabStripViewController.h; sourceTree = ""; }; + 28B63AEA1A45B26600225C66 /* XLButtonBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLButtonBarPagerTabStripViewController.m; path = Controllers/XLButtonBarPagerTabStripViewController.m; sourceTree = ""; }; + 28B63AEB1A45B26600225C66 /* XLPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLPagerTabStripViewController.h; path = Controllers/XLPagerTabStripViewController.h; sourceTree = ""; }; + 28B63AEC1A45B26600225C66 /* XLPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLPagerTabStripViewController.m; path = Controllers/XLPagerTabStripViewController.m; sourceTree = ""; }; + 28B63AED1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLSegmentedPagerTabStripViewController.h; path = Controllers/XLSegmentedPagerTabStripViewController.h; sourceTree = ""; }; + 28B63AEE1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLSegmentedPagerTabStripViewController.m; path = Controllers/XLSegmentedPagerTabStripViewController.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 28B63A831A459F5900225C66 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 28B63A9C1A459F5900225C66 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 28B63A7D1A459F5900225C66 = { + isa = PBXGroup; + children = ( + 28B63A881A459F5900225C66 /* XLPagerTabStrip */, + 28B63AA21A459F5900225C66 /* XLPagerTabStripTests */, + 28B63A871A459F5900225C66 /* Products */, + ); + sourceTree = ""; + }; + 28B63A871A459F5900225C66 /* Products */ = { + isa = PBXGroup; + children = ( + 28B63A861A459F5900225C66 /* XLPagerTabStrip.app */, + 28B63A9F1A459F5900225C66 /* XLPagerTabStripTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 28B63A881A459F5900225C66 /* XLPagerTabStrip */ = { + isa = PBXGroup; + children = ( + 28B63ACC1A45A4CD00225C66 /* XL */, + 28B63AAF1A45A4C500225C66 /* Demo */, + 28B63A8D1A459F5900225C66 /* AppDelegate.h */, + 28B63A8E1A459F5900225C66 /* AppDelegate.m */, + 28B63A961A459F5900225C66 /* Images.xcassets */, + 28B63A891A459F5900225C66 /* Supporting Files */, + ); + path = XLPagerTabStrip; + sourceTree = ""; + }; + 28B63A891A459F5900225C66 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 28B63A8A1A459F5900225C66 /* Info.plist */, + 28B63A8B1A459F5900225C66 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 28B63AA21A459F5900225C66 /* XLPagerTabStripTests */ = { + isa = PBXGroup; + children = ( + 28B63AA51A459F5900225C66 /* XLPagerTabStripTests.m */, + 28B63AA31A459F5900225C66 /* Supporting Files */, + ); + path = XLPagerTabStripTests; + sourceTree = ""; + }; + 28B63AA31A459F5900225C66 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 28B63AA41A459F5900225C66 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 28B63AAF1A45A4C500225C66 /* Demo */ = { + isa = PBXGroup; + children = ( + 28B63AE31A45A8EE00225C66 /* LaunchScreen.xib */, + 28B63AB01A45A4C500225C66 /* BarExampleViewController.h */, + 28B63AB11A45A4C500225C66 /* BarExampleViewController.m */, + 28B63AB21A45A4C500225C66 /* ButtonBarExampleViewController.h */, + 28B63AB31A45A4C500225C66 /* ButtonBarExampleViewController.m */, + 28B63AB41A45A4C500225C66 /* ChildViewController */, + 28B63ABC1A45A4C500225C66 /* Helpers */, + 28B63ABF1A45A4C500225C66 /* PagerSlidingTabStrip.gif */, + 28B63AC01A45A4C500225C66 /* SegmentedExampleViewController.h */, + 28B63AC11A45A4C500225C66 /* SegmentedExampleViewController.m */, + 28B63AC21A45A4C500225C66 /* Storyboard.storyboard */, + ); + path = Demo; + sourceTree = ""; + }; + 28B63AB41A45A4C500225C66 /* ChildViewController */ = { + isa = PBXGroup; + children = ( + 28B63AB51A45A4C500225C66 /* MailBoxChildViewController.h */, + 28B63AB61A45A4C500225C66 /* MailBoxChildViewController.m */, + 28B63AB71A45A4C500225C66 /* MailBoxTableChildViewController.h */, + 28B63AB81A45A4C500225C66 /* MailBoxTableChildViewController.m */, + 28B63AB91A45A4C500225C66 /* Views */, + ); + path = ChildViewController; + sourceTree = ""; + }; + 28B63AB91A45A4C500225C66 /* Views */ = { + isa = PBXGroup; + children = ( + 28B63ABA1A45A4C500225C66 /* PostCell.h */, + 28B63ABB1A45A4C500225C66 /* PostCell.m */, + ); + path = Views; + sourceTree = ""; + }; + 28B63ABC1A45A4C500225C66 /* Helpers */ = { + isa = PBXGroup; + children = ( + 28B63ABD1A45A4C500225C66 /* XLJSONSerialization.h */, + 28B63ABE1A45A4C500225C66 /* XLJSONSerialization.m */, + ); + path = Helpers; + sourceTree = ""; + }; + 28B63ACC1A45A4CD00225C66 /* XL */ = { + isa = PBXGroup; + children = ( + 28B63AE61A45B24100225C66 /* Controllers */, + 28B63ACD1A45A4CD00225C66 /* Views */, + ); + path = XL; + sourceTree = ""; + }; + 28B63ACD1A45A4CD00225C66 /* Views */ = { + isa = PBXGroup; + children = ( + 28B63ACE1A45A4CD00225C66 /* XLBarView.h */, + 28B63ACF1A45A4CD00225C66 /* XLBarView.m */, + 28B63AD01A45A4CD00225C66 /* XLButtonBarView.h */, + 28B63AD11A45A4CD00225C66 /* XLButtonBarView.m */, + 28B63AD21A45A4CD00225C66 /* XLButtonBarViewCell.h */, + 28B63AD31A45A4CD00225C66 /* XLButtonBarViewCell.m */, + ); + path = Views; + sourceTree = ""; + }; + 28B63AE61A45B24100225C66 /* Controllers */ = { + isa = PBXGroup; + children = ( + 28B63AE71A45B26600225C66 /* XLBarPagerTabStripViewController.h */, + 28B63AE81A45B26600225C66 /* XLBarPagerTabStripViewController.m */, + 28B63AE91A45B26600225C66 /* XLButtonBarPagerTabStripViewController.h */, + 28B63AEA1A45B26600225C66 /* XLButtonBarPagerTabStripViewController.m */, + 28B63AEB1A45B26600225C66 /* XLPagerTabStripViewController.h */, + 28B63AEC1A45B26600225C66 /* XLPagerTabStripViewController.m */, + 28B63AED1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.h */, + 28B63AEE1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.m */, + ); + name = Controllers; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 28B63A851A459F5900225C66 /* XLPagerTabStrip */ = { + isa = PBXNativeTarget; + buildConfigurationList = 28B63AA91A459F5900225C66 /* Build configuration list for PBXNativeTarget "XLPagerTabStrip" */; + buildPhases = ( + 28B63A821A459F5900225C66 /* Sources */, + 28B63A831A459F5900225C66 /* Frameworks */, + 28B63A841A459F5900225C66 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = XLPagerTabStrip; + productName = XLPagerTabStrip; + productReference = 28B63A861A459F5900225C66 /* XLPagerTabStrip.app */; + productType = "com.apple.product-type.application"; + }; + 28B63A9E1A459F5900225C66 /* XLPagerTabStripTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 28B63AAC1A459F5900225C66 /* Build configuration list for PBXNativeTarget "XLPagerTabStripTests" */; + buildPhases = ( + 28B63A9B1A459F5900225C66 /* Sources */, + 28B63A9C1A459F5900225C66 /* Frameworks */, + 28B63A9D1A459F5900225C66 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 28B63AA11A459F5900225C66 /* PBXTargetDependency */, + ); + name = XLPagerTabStripTests; + productName = XLPagerTabStripTests; + productReference = 28B63A9F1A459F5900225C66 /* XLPagerTabStripTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 28B63A7E1A459F5900225C66 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + ORGANIZATIONNAME = Xmartlabs; + TargetAttributes = { + 28B63A851A459F5900225C66 = { + CreatedOnToolsVersion = 6.1.1; + }; + 28B63A9E1A459F5900225C66 = { + CreatedOnToolsVersion = 6.1.1; + TestTargetID = 28B63A851A459F5900225C66; + }; + }; + }; + buildConfigurationList = 28B63A811A459F5900225C66 /* Build configuration list for PBXProject "XLPagerTabStrip" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 28B63A7D1A459F5900225C66; + productRefGroup = 28B63A871A459F5900225C66 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 28B63A851A459F5900225C66 /* XLPagerTabStrip */, + 28B63A9E1A459F5900225C66 /* XLPagerTabStripTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 28B63A841A459F5900225C66 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 28B63AE51A45A8EE00225C66 /* LaunchScreen.xib in Resources */, + 28B63AC91A45A4C500225C66 /* PagerSlidingTabStrip.gif in Resources */, + 28B63A971A459F5900225C66 /* Images.xcassets in Resources */, + 28B63ACB1A45A4C500225C66 /* Storyboard.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 28B63A9D1A459F5900225C66 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 28B63A821A459F5900225C66 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 28B63AC51A45A4C500225C66 /* MailBoxChildViewController.m in Sources */, + 28B63AF11A45B26600225C66 /* XLPagerTabStripViewController.m in Sources */, + 28B63AC41A45A4C500225C66 /* ButtonBarExampleViewController.m in Sources */, + 28B63ADC1A45A4CD00225C66 /* XLBarView.m in Sources */, + 28B63AC81A45A4C500225C66 /* XLJSONSerialization.m in Sources */, + 28B63ADD1A45A4CD00225C66 /* XLButtonBarView.m in Sources */, + 28B63AC71A45A4C500225C66 /* PostCell.m in Sources */, + 28B63ACA1A45A4C500225C66 /* SegmentedExampleViewController.m in Sources */, + 28B63ADE1A45A4CD00225C66 /* XLButtonBarViewCell.m in Sources */, + 28B63A8F1A459F5900225C66 /* AppDelegate.m in Sources */, + 28B63AF21A45B26600225C66 /* XLSegmentedPagerTabStripViewController.m in Sources */, + 28B63AEF1A45B26600225C66 /* XLBarPagerTabStripViewController.m in Sources */, + 28B63AC31A45A4C500225C66 /* BarExampleViewController.m in Sources */, + 28B63AF01A45B26600225C66 /* XLButtonBarPagerTabStripViewController.m in Sources */, + 28B63A8C1A459F5900225C66 /* main.m in Sources */, + 28B63AC61A45A4C500225C66 /* MailBoxTableChildViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 28B63A9B1A459F5900225C66 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 28B63AA61A459F5900225C66 /* XLPagerTabStripTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 28B63AA11A459F5900225C66 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 28B63A851A459F5900225C66 /* XLPagerTabStrip */; + targetProxy = 28B63AA01A459F5900225C66 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 28B63AE31A45A8EE00225C66 /* LaunchScreen.xib */ = { + isa = PBXVariantGroup; + children = ( + 28B63AE41A45A8EE00225C66 /* Base */, + ); + name = LaunchScreen.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 28B63AA71A459F5900225C66 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + 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 = 8.1; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 28B63AA81A459F5900225C66 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + 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 = 8.1; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 28B63AAA1A459F5900225C66 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = XLPagerTabStrip/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 28B63AAB1A459F5900225C66 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = XLPagerTabStrip/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 28B63AAD1A459F5900225C66 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = XLPagerTabStripTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/XLPagerTabStrip.app/XLPagerTabStrip"; + }; + name = Debug; + }; + 28B63AAE1A459F5900225C66 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + INFOPLIST_FILE = XLPagerTabStripTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/XLPagerTabStrip.app/XLPagerTabStrip"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 28B63A811A459F5900225C66 /* Build configuration list for PBXProject "XLPagerTabStrip" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 28B63AA71A459F5900225C66 /* Debug */, + 28B63AA81A459F5900225C66 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 28B63AA91A459F5900225C66 /* Build configuration list for PBXNativeTarget "XLPagerTabStrip" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 28B63AAA1A459F5900225C66 /* Debug */, + 28B63AAB1A459F5900225C66 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 28B63AAC1A459F5900225C66 /* Build configuration list for PBXNativeTarget "XLPagerTabStripTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 28B63AAD1A459F5900225C66 /* Debug */, + 28B63AAE1A459F5900225C66 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 28B63A7E1A459F5900225C66 /* Project object */; +} diff --git a/XLPagerTabStrip.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/XLPagerTabStrip.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..be7ae33 --- /dev/null +++ b/XLPagerTabStrip.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/XLPagerTabStrip/AppDelegate.h b/XLPagerTabStrip/AppDelegate.h new file mode 100644 index 0000000..52e62a2 --- /dev/null +++ b/XLPagerTabStrip/AppDelegate.h @@ -0,0 +1,32 @@ +// +// AppDelegate.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/XLPagerTabStrip/AppDelegate.m b/XLPagerTabStrip/AppDelegate.m new file mode 100644 index 0000000..1283662 --- /dev/null +++ b/XLPagerTabStrip/AppDelegate.m @@ -0,0 +1,43 @@ +// +// AppDelegate.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLJSONSerialization.h" +#import "XLSegmentedPagerTabStripViewController.h" +#import "MailBoxChildViewController.h" +#import "MailBoxTableChildViewController.h" + +#import "AppDelegate.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + [[XLJSONSerialization sharedInstance] postsData]; + return YES; + +} + + +@end diff --git a/XLPagerTabStrip/Base.lproj/LaunchScreen.xib b/XLPagerTabStrip/Base.lproj/LaunchScreen.xib new file mode 100644 index 0000000..b0a7dd4 --- /dev/null +++ b/XLPagerTabStrip/Base.lproj/LaunchScreen.xib @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/XLPagerTabStrip/Demo/BarExampleViewController.h b/XLPagerTabStrip/Demo/BarExampleViewController.h new file mode 100644 index 0000000..57f1ac9 --- /dev/null +++ b/XLPagerTabStrip/Demo/BarExampleViewController.h @@ -0,0 +1,31 @@ +// +// BarContainerViewController.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLBarPagerTabStripViewController.h" +#import "XLPagerTabStripViewController.h" + +@interface BarExampleViewController : XLBarPagerTabStripViewController + +@end diff --git a/XLPagerTabStrip/Demo/BarExampleViewController.m b/XLPagerTabStrip/Demo/BarExampleViewController.m new file mode 100644 index 0000000..c0e9246 --- /dev/null +++ b/XLPagerTabStrip/Demo/BarExampleViewController.m @@ -0,0 +1,64 @@ +// +// BarContainerViewController.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "MailBoxTableChildViewController.h" +#import "MailBoxChildViewController.h" +#import "BarExampleViewController.h" + +@interface BarExampleViewController () +@end + +@implementation BarExampleViewController + +- (instancetype)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + } + return self; +} + + + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. + [self.barView.selectedBar setBackgroundColor:[UIColor orangeColor]]; +} + +#pragma mark - XLPagerTabStripViewControllerDataSource + +-(NSArray *)childViewControllersForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController +{ + // create child view controllers that will be managed by XLPagerTabStripViewController + MailBoxTableChildViewController * child_1 = [[MailBoxTableChildViewController alloc] initWithStyle:UITableViewStylePlain]; + MailBoxChildViewController * child_2 = [[MailBoxChildViewController alloc] init]; + MailBoxTableChildViewController * child_3 = [[MailBoxTableChildViewController alloc] initWithStyle:UITableViewStyleGrouped]; + MailBoxChildViewController * child_4 = [[MailBoxChildViewController alloc] init]; + return @[child_1, child_2, child_3, child_4]; +} + +@end diff --git a/XLPagerTabStrip/Demo/ButtonBarExampleViewController.h b/XLPagerTabStrip/Demo/ButtonBarExampleViewController.h new file mode 100644 index 0000000..afcdbd8 --- /dev/null +++ b/XLPagerTabStrip/Demo/ButtonBarExampleViewController.h @@ -0,0 +1,30 @@ +// +// ButtonContainerViewController.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLButtonBarPagerTabStripViewController.h" + +@interface ButtonBarExampleViewController : XLButtonBarPagerTabStripViewController + +@end diff --git a/XLPagerTabStrip/Demo/ButtonBarExampleViewController.m b/XLPagerTabStrip/Demo/ButtonBarExampleViewController.m new file mode 100644 index 0000000..2dc89d0 --- /dev/null +++ b/XLPagerTabStrip/Demo/ButtonBarExampleViewController.m @@ -0,0 +1,58 @@ +// +// ButtonContainerViewController.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "MailBoxTableChildViewController.h" +#import "MailBoxChildViewController.h" +#import "ButtonBarExampleViewController.h" + +@interface ButtonBarExampleViewController () + +@end + +@implementation ButtonBarExampleViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + [self.buttonBarView.selectedBar setBackgroundColor:[UIColor orangeColor]]; +} + +#pragma mark - XLPagerTabStripViewControllerDataSource + +-(NSArray *)childViewControllersForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController +{ + // create child view controllers that will be managed by XLPagerTabStripViewController + MailBoxTableChildViewController * child_1 = [[MailBoxTableChildViewController alloc] initWithStyle:UITableViewStylePlain]; + MailBoxChildViewController * child_2 = [[MailBoxChildViewController alloc] init]; + MailBoxTableChildViewController * child_3 = [[MailBoxTableChildViewController alloc] initWithStyle:UITableViewStyleGrouped]; + MailBoxChildViewController * child_4 = [[MailBoxChildViewController alloc] init]; + MailBoxTableChildViewController * child_5 = [[MailBoxTableChildViewController alloc] initWithStyle:UITableViewStylePlain]; + MailBoxChildViewController * child_6 = [[MailBoxChildViewController alloc] init]; + MailBoxTableChildViewController * child_7 = [[MailBoxTableChildViewController alloc] initWithStyle:UITableViewStyleGrouped]; + MailBoxChildViewController * child_8 = [[MailBoxChildViewController alloc] init]; + return @[child_1, child_2, child_3, child_4, child_5, child_6, child_7, child_8]; +} + +@end diff --git a/XLPagerTabStrip/Demo/ChildViewController/MailBoxChildViewController.h b/XLPagerTabStrip/Demo/ChildViewController/MailBoxChildViewController.h new file mode 100644 index 0000000..ccbfecc --- /dev/null +++ b/XLPagerTabStrip/Demo/ChildViewController/MailBoxChildViewController.h @@ -0,0 +1,31 @@ +// +// MailBoxChildViewController.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLPagerTabStripViewController.h" +#import + +@interface MailBoxChildViewController : UIViewController + +@end diff --git a/XLPagerTabStrip/Demo/ChildViewController/MailBoxChildViewController.m b/XLPagerTabStrip/Demo/ChildViewController/MailBoxChildViewController.m new file mode 100644 index 0000000..70ce9ef --- /dev/null +++ b/XLPagerTabStrip/Demo/ChildViewController/MailBoxChildViewController.m @@ -0,0 +1,72 @@ +// +// MailBoxChildViewController.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "MailBoxChildViewController.h" + +@implementation MailBoxChildViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + [self.view setBackgroundColor:[UIColor whiteColor]]; + // Do any additional setup after loading the view. + UILabel * label = [[UILabel alloc] init]; + [label setTranslatesAutoresizingMaskIntoConstraints:NO]; + label.text = @"XLPagerTabStrip"; + [self.view addSubview:label]; + + + [self.view addConstraint:[NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0]]; + [self.view addConstraint:[NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:-50.0]]; +} + +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; +} + + +#pragma mark - XLPagerTabStripViewControllerDelegate + +-(NSString *)titleForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController +{ + return @"View"; +} + +-(UIColor *)colorForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController +{ + return [UIColor whiteColor]; +} + +@end diff --git a/XLPagerTabStrip/Demo/ChildViewController/MailBoxTableChildViewController.h b/XLPagerTabStrip/Demo/ChildViewController/MailBoxTableChildViewController.h new file mode 100644 index 0000000..168d371 --- /dev/null +++ b/XLPagerTabStrip/Demo/ChildViewController/MailBoxTableChildViewController.h @@ -0,0 +1,32 @@ +// +// MailBoxTableChildViewController.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 +#import "XLPagerTabStripViewController.h" + +@interface MailBoxTableChildViewController : UITableViewController + + +@end diff --git a/XLPagerTabStrip/Demo/ChildViewController/MailBoxTableChildViewController.m b/XLPagerTabStrip/Demo/ChildViewController/MailBoxTableChildViewController.m new file mode 100644 index 0000000..c7332ec --- /dev/null +++ b/XLPagerTabStrip/Demo/ChildViewController/MailBoxTableChildViewController.m @@ -0,0 +1,167 @@ +// +// MailBoxTableChildViewController.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLJSONSerialization.h" +#import "PostCell.h" +#import "MailBoxTableChildViewController.h" + +NSString *const kCellIdentifier = @"PostCell"; + +@implementation MailBoxTableChildViewController +{ + NSArray * _posts; + PostCell * _offScreenCell; +} + +- (id)initWithStyle:(UITableViewStyle)style +{ + self = [super initWithStyle:style]; + if (self) { + _posts = [[XLJSONSerialization sharedInstance] postsData]; + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + [self.tableView registerClass:[PostCell class] forCellReuseIdentifier:kCellIdentifier]; +} + + +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return _posts.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + PostCell *cell = (PostCell *) [tableView dequeueReusableCellWithIdentifier:kCellIdentifier forIndexPath:indexPath]; + + cell.userName.text = [_posts objectAtIndex:indexPath.row][@"post"][@"user"][@"name"]; + cell.postDate.text = [self timeAgo:[self dateFromString:[_posts objectAtIndex:indexPath.row][@"post"][@"created_at"]]]; + cell.postText.text = [_posts objectAtIndex:indexPath.row][@"post"][@"text"]; + [cell.postText setPreferredMaxLayoutWidth:self.view.bounds.size.width]; + [cell.userImage setImage:[UIImage imageNamed:[cell.userName.text stringByReplacingOccurrencesOfString:@" " withString:@"_"]]]; + return cell; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (!_offScreenCell) + { + _offScreenCell = (PostCell *)[self.tableView dequeueReusableCellWithIdentifier:kCellIdentifier]; + // Dummy Data + _offScreenCell.userName.text = @"offscreen name"; + _offScreenCell.postDate.text = @"7m"; + [_offScreenCell.userImage setImage:[UIImage imageNamed:@"default-avatar"]]; + } + _offScreenCell.postText.text = [_posts objectAtIndex:indexPath.row][@"post"][@"text"]; + [_offScreenCell.postText setPreferredMaxLayoutWidth:self.view.bounds.size.width]; + [_offScreenCell.contentView setNeedsLayout]; + [_offScreenCell.contentView layoutIfNeeded]; + CGSize size = [_offScreenCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; + return size.height + 1; +} + +#pragma mark - XLPagerTabStripViewControllerDelegate + +-(NSString *)titleForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController +{ + return @"Table View"; +} + +-(UIColor *)colorForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController +{ + return [UIColor whiteColor]; +} + + +#pragma mark - Helpers + +#define SECONDS_IN_A_MINUTE 60 +#define SECONDS_IN_A_HOUR 3600 +#define SECONDS_IN_A_DAY 86400 +#define SECONDS_IN_A_MONTH_OF_30_DAYS 2592000 +#define SECONDS_IN_A_YEAR_OF_MONTH_OF_30_DAYS 31104000 + +- (NSString *)timeAgo:(NSDate *)date { + NSTimeInterval distanceBetweenDates = [date timeIntervalSinceDate:[NSDate date]] * (-1); + int distance = (int)floorf(distanceBetweenDates); + if (distance <= 0) { + return @"now"; + } + else if (distance < SECONDS_IN_A_MINUTE) { + return [NSString stringWithFormat:@"%ds", distance]; + } + else if (distance < SECONDS_IN_A_HOUR) { + distance = distance / SECONDS_IN_A_MINUTE; + return [NSString stringWithFormat:@"%dm", distance]; + } + else if (distance < SECONDS_IN_A_DAY) { + distance = distance / SECONDS_IN_A_HOUR; + return [NSString stringWithFormat:@"%dh", distance]; + } + else if (distance < SECONDS_IN_A_MONTH_OF_30_DAYS) { + distance = distance / SECONDS_IN_A_DAY; + return [NSString stringWithFormat:@"%dd", distance]; + } + else if (distance < SECONDS_IN_A_YEAR_OF_MONTH_OF_30_DAYS) { + distance = distance / SECONDS_IN_A_MONTH_OF_30_DAYS; + return [NSString stringWithFormat:@"%dmo", distance]; + } else { + distance = distance / SECONDS_IN_A_YEAR_OF_MONTH_OF_30_DAYS; + return [NSString stringWithFormat:@"%dy", distance]; + } +} + +-(NSDate *)dateFromString:(NSString *)dateString +{ + // date formatter + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]]; + [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"]; + // hot fix from date + NSRange range = [dateString rangeOfString:@"."]; + if (range.location != NSNotFound){ + dateString = [dateString substringToIndex:range.location]; + } + return [formatter dateFromString:dateString]; +} + + +@end diff --git a/XLPagerTabStrip/Demo/ChildViewController/Views/PostCell.h b/XLPagerTabStrip/Demo/ChildViewController/Views/PostCell.h new file mode 100644 index 0000000..1ec2841 --- /dev/null +++ b/XLPagerTabStrip/Demo/ChildViewController/Views/PostCell.h @@ -0,0 +1,40 @@ +// +// PostCell.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 + + +@interface PostTextLabel : UILabel +@end + + +@interface PostCell : UITableViewCell + +@property (nonatomic) UIImageView * userImage; +@property (nonatomic) UILabel * userName; +@property (nonatomic) PostTextLabel * postText; +@property (nonatomic) UILabel * postDate; + +@end diff --git a/XLPagerTabStrip/Demo/ChildViewController/Views/PostCell.m b/XLPagerTabStrip/Demo/ChildViewController/Views/PostCell.m new file mode 100644 index 0000000..1286fdc --- /dev/null +++ b/XLPagerTabStrip/Demo/ChildViewController/Views/PostCell.m @@ -0,0 +1,159 @@ +// +// PostCell.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "PostCell.h" + +@implementation PostCell + +@synthesize userImage = _userImage; +@synthesize userName = _userName; +@synthesize postText = _postText; +@synthesize postDate = _postDate; + +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + // Initialization code + + [self.contentView addSubview:self.userImage]; + [self.contentView addSubview:self.userName]; + [self.contentView addSubview:self.postText]; + [self.contentView addSubview:self.postDate]; + + [self.contentView addConstraints:[self layoutConstraints]]; + } + return self; +} + +#pragma mark - Views + +-(UIImageView *)userImage +{ + if (_userImage) return _userImage; + _userImage = [UIImageView new]; + [_userImage setTranslatesAutoresizingMaskIntoConstraints:NO]; + _userImage.layer.masksToBounds = YES; + _userImage.layer.cornerRadius = 10.0f; + return _userImage; +} + +-(UILabel *)userName +{ + if (_userName) return _userName; + _userName = [UILabel new]; + [_userName setTranslatesAutoresizingMaskIntoConstraints:NO]; + _userName.font = [UIFont fontWithName:@"HelveticaNeue" size:15]; + [_userName setContentCompressionResistancePriority:500 forAxis:UILayoutConstraintAxisHorizontal]; + + return _userName; +} + +-(PostTextLabel *)postText +{ + if (_postText) return _postText; + _postText = [PostTextLabel new]; + [_postText setTranslatesAutoresizingMaskIntoConstraints:NO]; + _postText.font = [UIFont fontWithName:@"HelveticaNeue" size:12]; + + _postText.lineBreakMode = NSLineBreakByWordWrapping; + _postText.numberOfLines = 0; + + return _postText; +} + +-(UILabel *)postDate +{ + if (_postDate) return _postDate; + _postDate = [UILabel new]; + [_postDate setTranslatesAutoresizingMaskIntoConstraints:NO]; + _postDate.textColor = [UIColor grayColor]; + _postDate.font = [UIFont fontWithName:@"HelveticaNeue" size:12]; + [_postDate setTextAlignment:NSTextAlignmentRight]; + return _postDate; +} + + +#pragma mark - Layout Constraints + +-(NSArray *)layoutConstraints{ + + NSMutableArray * result = [NSMutableArray array]; + + NSDictionary * views = @{ @"image": self.userImage, + @"name": self.userName, + @"text": self.postText, + @"date" : self.postDate }; + + NSDictionary *metrics = @{@"imgSize":@50.0, + @"margin" :@12.0}; + + [result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(margin)-[image(imgSize)]-[name]" + options:NSLayoutFormatAlignAllTop + metrics:metrics + views:views]]; + + [result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[name]-[date]-20-|" + options:NSLayoutFormatAlignAllBaseline + metrics:metrics + views:views]]; + + [result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(margin)-[image(imgSize)]" + options:0 + metrics:metrics + views:views]]; + + [result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[name]-[text]-20-|" + options:NSLayoutFormatAlignAllLeft + metrics:metrics + views:views]]; + + [result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[text]-20-|" + options:NSLayoutFormatAlignAllBaseline + metrics:metrics + views:views]]; + return result; +} + +@end + + +@implementation PostTextLabel + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code + } + return self; +} + +- (void) layoutSubviews { + [super layoutSubviews]; + self.preferredMaxLayoutWidth = self.bounds.size.width; +} + +@end diff --git a/XLPagerTabStrip/Demo/Helpers/XLJSONSerialization.h b/XLPagerTabStrip/Demo/Helpers/XLJSONSerialization.h new file mode 100644 index 0000000..844a595 --- /dev/null +++ b/XLPagerTabStrip/Demo/Helpers/XLJSONSerialization.h @@ -0,0 +1,34 @@ +// +// XLJSONSerialization.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 + +@interface XLJSONSerialization : NSObject + ++ (instancetype)sharedInstance; + +@property (readonly) NSArray * postsData; + +@end diff --git a/XLPagerTabStrip/Demo/Helpers/XLJSONSerialization.m b/XLPagerTabStrip/Demo/Helpers/XLJSONSerialization.m new file mode 100644 index 0000000..9b312b5 --- /dev/null +++ b/XLPagerTabStrip/Demo/Helpers/XLJSONSerialization.m @@ -0,0 +1,57 @@ +// +// XLJSONSerialization.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLJSONSerialization.h" + +@implementation XLJSONSerialization + + +@synthesize postsData = _postData; + ++ (instancetype)sharedInstance +{ + static XLJSONSerialization * _sharedInstance = nil; + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + _sharedInstance = [[self alloc] init]; + + }); + return _sharedInstance; +} + +-(NSArray *)postsData +{ + if (_postData){ + return _postData; + } + NSString * 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\"}}}]"; + + NSData * jsonData = [jsonStr dataUsingEncoding:NSUTF8StringEncoding]; + + return [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil]; +} + +@end diff --git a/XLPagerTabStrip/Demo/PagerSlidingTabStrip.gif b/XLPagerTabStrip/Demo/PagerSlidingTabStrip.gif new file mode 100644 index 0000000..d2101e2 Binary files /dev/null and b/XLPagerTabStrip/Demo/PagerSlidingTabStrip.gif differ diff --git a/XLPagerTabStrip/Demo/SegmentedExampleViewController.h b/XLPagerTabStrip/Demo/SegmentedExampleViewController.h new file mode 100644 index 0000000..1637cd5 --- /dev/null +++ b/XLPagerTabStrip/Demo/SegmentedExampleViewController.h @@ -0,0 +1,30 @@ +// +// SegmentedContainerViewController.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLSegmentedPagerTabStripViewController.h" + +@interface SegmentedExampleViewController : XLSegmentedPagerTabStripViewController + +@end diff --git a/XLPagerTabStrip/Demo/SegmentedExampleViewController.m b/XLPagerTabStrip/Demo/SegmentedExampleViewController.m new file mode 100644 index 0000000..0bcdeb8 --- /dev/null +++ b/XLPagerTabStrip/Demo/SegmentedExampleViewController.m @@ -0,0 +1,59 @@ +// +// SegmentedContainerViewController.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "MailBoxChildViewController.h" +#import "MailBoxTableChildViewController.h" +#import "SegmentedExampleViewController.h" + +@interface SegmentedExampleViewController () + +@end + +@implementation SegmentedExampleViewController + + +- (instancetype)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + self.skipIntermediateViewControllers = NO; + } + return self; +} + +#pragma mark - XLPagerTabStripViewControllerDataSource + +-(NSArray *)childViewControllersForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController +{ + // create child view controllers that will be managed by XLPagerTabStripViewController + MailBoxTableChildViewController * child_1 = [[MailBoxTableChildViewController alloc] initWithStyle:UITableViewStylePlain]; + MailBoxChildViewController * child_2 = [[MailBoxChildViewController alloc] init]; + MailBoxTableChildViewController * child_3 = [[MailBoxTableChildViewController alloc] initWithStyle:UITableViewStyleGrouped]; + MailBoxChildViewController * child_4 = [[MailBoxChildViewController alloc] init]; + return @[child_1, child_2, child_3, child_4]; +} + + +@end diff --git a/XLPagerTabStrip/Demo/Storyboard.storyboard b/XLPagerTabStrip/Demo/Storyboard.storyboard new file mode 100644 index 0000000..fe7086e --- /dev/null +++ b/XLPagerTabStrip/Demo/Storyboard.storyboard @@ -0,0 +1,317 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/Contents.json b/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..e657539 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,31 @@ +{ + "images" : [ + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "xl_appicon_58.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "xl_appicon_80.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "xl_appicon_120.png", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/xl_appicon_120.png b/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/xl_appicon_120.png new file mode 100644 index 0000000..55f76ae Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/xl_appicon_120.png differ diff --git a/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/xl_appicon_58.png b/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/xl_appicon_58.png new file mode 100644 index 0000000..69a3ddd Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/xl_appicon_58.png differ diff --git a/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/xl_appicon_80.png b/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/xl_appicon_80.png new file mode 100644 index 0000000..28b1468 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/AppIcon.appiconset/xl_appicon_80.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Launch.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Launch.imageset/Contents.json new file mode 100644 index 0000000..b1264e3 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Launch.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "xl_splash@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Launch.imageset/xl_splash@2x.png b/XLPagerTabStrip/Images.xcassets/Launch.imageset/xl_splash@2x.png new file mode 100644 index 0000000..30ed4e2 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Launch.imageset/xl_splash@2x.png differ diff --git a/XLPagerTabStrip/Images.xcassets/LaunchImage.launchimage/Contents.json b/XLPagerTabStrip/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..e087df6 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,24 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "retina4", + "filename" : "xl_splash@2x.png", + "minimum-system-version" : "7.0", + "orientation" : "portrait", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/LaunchImage.launchimage/xl_splash@2x.png b/XLPagerTabStrip/Images.xcassets/LaunchImage.launchimage/xl_splash@2x.png new file mode 100644 index 0000000..30ed4e2 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/LaunchImage.launchimage/xl_splash@2x.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Apu_Nahasapeemapetilon.imageset/Apu_Nahasapeemapetilon.png b/XLPagerTabStrip/Images.xcassets/Simpsons/Apu_Nahasapeemapetilon.imageset/Apu_Nahasapeemapetilon.png new file mode 100644 index 0000000..c672db7 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/Apu_Nahasapeemapetilon.imageset/Apu_Nahasapeemapetilon.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Apu_Nahasapeemapetilon.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/Apu_Nahasapeemapetilon.imageset/Contents.json new file mode 100644 index 0000000..cf9b8d6 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/Apu_Nahasapeemapetilon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Apu_Nahasapeemapetilon.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Bart_Simpsons.imageset/Bart_Simpsons.png b/XLPagerTabStrip/Images.xcassets/Simpsons/Bart_Simpsons.imageset/Bart_Simpsons.png new file mode 100644 index 0000000..f218733 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/Bart_Simpsons.imageset/Bart_Simpsons.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Bart_Simpsons.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/Bart_Simpsons.imageset/Contents.json new file mode 100644 index 0000000..6f27ef7 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/Bart_Simpsons.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Bart_Simpsons.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Homer_Simpsons.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/Homer_Simpsons.imageset/Contents.json new file mode 100644 index 0000000..3689187 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/Homer_Simpsons.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Homer_Simpsons.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Homer_Simpsons.imageset/Homer_Simpsons.png b/XLPagerTabStrip/Images.xcassets/Simpsons/Homer_Simpsons.imageset/Homer_Simpsons.png new file mode 100644 index 0000000..194d9f6 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/Homer_Simpsons.imageset/Homer_Simpsons.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Lisa_Simpsons.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/Lisa_Simpsons.imageset/Contents.json new file mode 100644 index 0000000..9d697ff --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/Lisa_Simpsons.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Lisa_Simpsons.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Lisa_Simpsons.imageset/Lisa_Simpsons.png b/XLPagerTabStrip/Images.xcassets/Simpsons/Lisa_Simpsons.imageset/Lisa_Simpsons.png new file mode 100644 index 0000000..da566b8 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/Lisa_Simpsons.imageset/Lisa_Simpsons.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Maggie_Simpsons.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/Maggie_Simpsons.imageset/Contents.json new file mode 100644 index 0000000..dde48fa --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/Maggie_Simpsons.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Maggie_Simpsons.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Maggie_Simpsons.imageset/Maggie_Simpsons.png b/XLPagerTabStrip/Images.xcassets/Simpsons/Maggie_Simpsons.imageset/Maggie_Simpsons.png new file mode 100644 index 0000000..a445a3f Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/Maggie_Simpsons.imageset/Maggie_Simpsons.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Marge_Simpsons.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/Marge_Simpsons.imageset/Contents.json new file mode 100644 index 0000000..d9f5573 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/Marge_Simpsons.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Marge_Simpsons.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Marge_Simpsons.imageset/Marge_Simpsons.png b/XLPagerTabStrip/Images.xcassets/Simpsons/Marge_Simpsons.imageset/Marge_Simpsons.png new file mode 100644 index 0000000..a4dd75e Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/Marge_Simpsons.imageset/Marge_Simpsons.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Montgomery_Burns.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/Montgomery_Burns.imageset/Contents.json new file mode 100644 index 0000000..e35f8ab --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/Montgomery_Burns.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Montgomery_Burns.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Montgomery_Burns.imageset/Montgomery_Burns.png b/XLPagerTabStrip/Images.xcassets/Simpsons/Montgomery_Burns.imageset/Montgomery_Burns.png new file mode 100644 index 0000000..6ae4344 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/Montgomery_Burns.imageset/Montgomery_Burns.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Ned_Flanders.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/Ned_Flanders.imageset/Contents.json new file mode 100644 index 0000000..fbfe418 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/Ned_Flanders.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Ned_Flanders.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Ned_Flanders.imageset/Ned_Flanders.png b/XLPagerTabStrip/Images.xcassets/Simpsons/Ned_Flanders.imageset/Ned_Flanders.png new file mode 100644 index 0000000..f24dd91 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/Ned_Flanders.imageset/Ned_Flanders.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Otto_Mann.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/Otto_Mann.imageset/Contents.json new file mode 100644 index 0000000..8c56cf6 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/Otto_Mann.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Otto_Mann.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/Otto_Mann.imageset/Otto_Mann.png b/XLPagerTabStrip/Images.xcassets/Simpsons/Otto_Mann.imageset/Otto_Mann.png new file mode 100644 index 0000000..e82bf1c Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/Otto_Mann.imageset/Otto_Mann.png differ diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/default-avatar.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/Simpsons/default-avatar.imageset/Contents.json new file mode 100644 index 0000000..03ef1ee --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/Simpsons/default-avatar.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "default-avatar@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/Simpsons/default-avatar.imageset/default-avatar@2x.png b/XLPagerTabStrip/Images.xcassets/Simpsons/default-avatar.imageset/default-avatar@2x.png new file mode 100644 index 0000000..e2ee1b2 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/Simpsons/default-avatar.imageset/default-avatar@2x.png differ diff --git a/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Selected.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Selected.imageset/Contents.json new file mode 100644 index 0000000..74b5faa --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Selected.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Posts_Selected.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Selected.imageset/Posts_Selected.png b/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Selected.imageset/Posts_Selected.png new file mode 100644 index 0000000..dfdc281 Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Selected.imageset/Posts_Selected.png differ diff --git a/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Unselected.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Unselected.imageset/Contents.json new file mode 100644 index 0000000..5268e1a --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Unselected.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Posts_Unselected.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Unselected.imageset/Posts_Unselected.png b/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Unselected.imageset/Posts_Unselected.png new file mode 100644 index 0000000..1d28c7d Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/TabBar/Posts_Unselected.imageset/Posts_Unselected.png differ diff --git a/XLPagerTabStrip/Images.xcassets/TabBar/Users_Selected.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/TabBar/Users_Selected.imageset/Contents.json new file mode 100644 index 0000000..7fab421 --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/TabBar/Users_Selected.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Users_Selected.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/TabBar/Users_Selected.imageset/Users_Selected.png b/XLPagerTabStrip/Images.xcassets/TabBar/Users_Selected.imageset/Users_Selected.png new file mode 100644 index 0000000..64a1bfa Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/TabBar/Users_Selected.imageset/Users_Selected.png differ diff --git a/XLPagerTabStrip/Images.xcassets/TabBar/Users_Unselected.imageset/Contents.json b/XLPagerTabStrip/Images.xcassets/TabBar/Users_Unselected.imageset/Contents.json new file mode 100644 index 0000000..5c3f84a --- /dev/null +++ b/XLPagerTabStrip/Images.xcassets/TabBar/Users_Unselected.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Users_Unselected.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/XLPagerTabStrip/Images.xcassets/TabBar/Users_Unselected.imageset/Users_Unselected.png b/XLPagerTabStrip/Images.xcassets/TabBar/Users_Unselected.imageset/Users_Unselected.png new file mode 100644 index 0000000..db93d1a Binary files /dev/null and b/XLPagerTabStrip/Images.xcassets/TabBar/Users_Unselected.imageset/Users_Unselected.png differ diff --git a/XLPagerTabStrip/Info.plist b/XLPagerTabStrip/Info.plist new file mode 100644 index 0000000..1679552 --- /dev/null +++ b/XLPagerTabStrip/Info.plist @@ -0,0 +1,42 @@ + + + + + UILaunchImageFile + LaunchImage + UILaunchStoryboardName + LaunchScreen + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.xmartlabs.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Storyboard + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.h b/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.h new file mode 100644 index 0000000..22f9756 --- /dev/null +++ b/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.h @@ -0,0 +1,33 @@ +// +// XLBarPagerTabStripViewController.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLBarView.h" +#import "XLPagerTabStripViewController.h" + +@interface XLBarPagerTabStripViewController : XLPagerTabStripViewController + +@property (nonatomic) IBOutlet XLBarView * barView; + +@end diff --git a/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m new file mode 100644 index 0000000..60d8985 --- /dev/null +++ b/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m @@ -0,0 +1,82 @@ +// +// XLBarPagerTabStripViewController.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLBarPagerTabStripViewController.h" + +@interface XLBarPagerTabStripViewController () + +@end + +@implementation XLBarPagerTabStripViewController + +- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + } + return self; +} + +- (instancetype)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + } + return self; +} + + +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + if (!self.barView.superview){ + [self.view addSubview:self.barView]; + } + else{ + [self.barView setOptionsAmount:[self.dataSource childViewControllersForPagerTabStripViewController:self].count animated:NO]; + [self.barView moveToIndex:self.currentIndex animated:NO]; + } +} + +-(XLBarView *)barView +{ + if (_barView) return _barView; + _barView = [[XLBarView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 5.0f) optionsAmount:[self.dataSource childViewControllersForPagerTabStripViewController:self].count selectedOptionIndex:self.currentIndex]; + _barView.backgroundColor = [UIColor orangeColor]; + _barView.selectedBar.backgroundColor = [UIColor blackColor]; + _barView.autoresizingMask = UIViewAutoresizingFlexibleWidth; + return _barView; +} + +#pragma mark - XLPagerTabStripViewControllerDelegate + +-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController +{ + [self.barView moveToIndex:[self.pagerTabStripChildViewControllers indexOfObject:toViewController] animated:YES]; +} + + + +@end diff --git a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h new file mode 100644 index 0000000..e917343 --- /dev/null +++ b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h @@ -0,0 +1,33 @@ +// +// XLButtonBarPagerTabStripViewController.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLButtonBarView.h" +#import "XLPagerTabStripViewController.h" + +@interface XLButtonBarPagerTabStripViewController : XLPagerTabStripViewController + +@property (readonly, nonatomic) XLButtonBarView * buttonBarView; + +@end diff --git a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m new file mode 100644 index 0000000..3bf74cb --- /dev/null +++ b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m @@ -0,0 +1,176 @@ +// +// XLButtonBarPagerTabStripViewController.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLButtonBarViewCell.h" +#import "XLButtonBarPagerTabStripViewController.h" + +@interface XLButtonBarPagerTabStripViewController () + +@property (nonatomic) IBOutlet XLButtonBarView * buttonBarView; +@property (nonatomic) BOOL shouldUpdateButtonBarView; + +@end + +@implementation XLButtonBarPagerTabStripViewController +{ + XLButtonBarViewCell * _sizeCell; +} + +- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + self.shouldUpdateButtonBarView = YES; + } + return self; +} + +- (instancetype)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + self.shouldUpdateButtonBarView = YES; + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. + if (!self.buttonBarView.superview){ + [self.view addSubview:self.buttonBarView]; + } + if (!self.buttonBarView.delegate){ + self.buttonBarView.delegate = self; + } + if (!self.buttonBarView.dataSource){ + self.buttonBarView.dataSource = self; + } + self.buttonBarView.labelFont = [UIFont fontWithName:@"Helvetica-Bold" size:18.0f]; + self.buttonBarView.leftRightMargin = 8; + UICollectionViewFlowLayout * flowLayout = (id)self.buttonBarView.collectionViewLayout; + [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; + [self.buttonBarView setShowsHorizontalScrollIndicator:NO]; +} + +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + UICollectionViewLayoutAttributes *attributes = [self.buttonBarView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex inSection:0]]; + CGRect cellRect = attributes.frame; + [self.buttonBarView.selectedBar setFrame:CGRectMake(cellRect.origin.x, self.buttonBarView.frame.size.height - 5, cellRect.size.width, 5)]; +} + + +-(XLButtonBarView *)buttonBarView +{ + if (_buttonBarView) return _buttonBarView; + UICollectionViewFlowLayout * flowLayout = [[UICollectionViewFlowLayout alloc] init]; + [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; + [flowLayout setSectionInset:UIEdgeInsetsMake(0, 35, 0, 35)]; + _buttonBarView = [[XLButtonBarView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50.0f) collectionViewLayout:flowLayout]; + _buttonBarView.backgroundColor = [UIColor orangeColor]; + _buttonBarView.selectedBar.backgroundColor = [UIColor blackColor]; + _buttonBarView.autoresizingMask = UIViewAutoresizingFlexibleWidth; + return _buttonBarView; +} + +#pragma mark - XLPagerTabStripViewControllerDelegate + +-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController +{ + if (self.shouldUpdateButtonBarView){ + NSUInteger newIndex = [self.pagerTabStripChildViewControllers indexOfObject:toViewController]; + XLPagerTabStripDirection direction = XLPagerTabStripDirectionLeft; + if (newIndex < [self.pagerTabStripChildViewControllers indexOfObject:fromViewController]){ + direction = XLPagerTabStripDirectionRight; + } + [self.buttonBarView moveToIndex:newIndex animated:YES swipeDirection:direction]; + } +} + + + +#pragma merk - UICollectionViewDelegateFlowLayout + +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath +{ + UILabel * label = [[UILabel alloc] init]; + [label setTranslatesAutoresizingMaskIntoConstraints:NO]; + label.font = self.buttonBarView.labelFont; + UIViewController * childController = [self.pagerTabStripChildViewControllers objectAtIndex:indexPath.item]; + [label setText:[childController titleForPagerTabStripViewController:self]]; + CGSize labelSize = [label intrinsicContentSize]; + + return CGSizeMake(labelSize.width + (self.buttonBarView.leftRightMargin * 2), collectionView.frame.size.height); +} + +#pragma mark - UICollectionViewDelegate + + +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath +{ + [self.buttonBarView moveToIndex:indexPath.item animated:YES swipeDirection:XLPagerTabStripDirectionNone]; + self.shouldUpdateButtonBarView = NO; + [self moveToViewControllerAtIndex:indexPath.item]; +} + +#pragma merk - UICollectionViewDataSource + +-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section +{ + return self.pagerTabStripChildViewControllers.count; +} + +// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath: +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath +{ + UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; + if (!cell){ + cell = [[XLButtonBarViewCell alloc] initWithFrame:CGRectMake(0, 0, 50, self.buttonBarView.frame.size.height)]; + } + NSAssert([cell isKindOfClass:[XLButtonBarViewCell class]], @"UICollectionViewCell should be or extend XLButtonBarViewCell"); + XLButtonBarViewCell * buttonBarCell = (XLButtonBarViewCell *)cell; + UIViewController * childController = [self.pagerTabStripChildViewControllers objectAtIndex:indexPath.item]; + + [buttonBarCell.label setText:[childController titleForPagerTabStripViewController:self]]; + + return buttonBarCell; +} + + +#pragma mark - UIScrollViewDelegate + +-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView +{ + [super scrollViewDidEndScrollingAnimation:scrollView]; + if (scrollView == self.containerView){ + self.shouldUpdateButtonBarView = YES; + } +} + + +@end diff --git a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h new file mode 100644 index 0000000..dca9084 --- /dev/null +++ b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h @@ -0,0 +1,89 @@ +// +// XLPagerTabStripViewController.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 +#import + +@class XLPagerTabStripViewController; + +/** + The `XLPagerTabStripChildItem` protocol is adopted by child controllers of XLPagerTabStripViewController. Each child view controller has to define a color and either a image or string in order to create the related UISegmentedControl option and update the color accordingly when the selected child view controller change. + */ +@protocol XLPagerTabStripChildItem + +@required + +- (NSString *)titleForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController; + +@optional + +- (UIImage *)imageForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController; +- (UIColor *)colorForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController; + +@end + + + +typedef NS_ENUM(NSUInteger, XLPagerTabStripDirection) { + XLPagerTabStripDirectionLeft, + XLPagerTabStripDirectionRight, + XLPagerTabStripDirectionNone +}; + + + +@protocol XLPagerTabStripViewControllerDelegate + +@optional + +-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController; + +@end + + +@protocol XLPagerTabStripViewControllerDataSource + +@required + +-(NSArray *)childViewControllersForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController; + +@end + + + +@interface XLPagerTabStripViewController : UIViewController + +@property (readonly) NSArray * pagerTabStripChildViewControllers; +@property (nonatomic, retain) IBOutlet UIScrollView * containerView; +@property (nonatomic, assign) IBOutlet id delegate; +@property (nonatomic, assign) IBOutlet id dataSource; + +@property (readonly) NSUInteger currentIndex; +@property BOOL skipIntermediateViewControllers; + +-(void)moveToViewControllerAtIndex:(NSUInteger)index; +-(void)moveToViewController:(UIViewController *)viewController; + +@end diff --git a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m new file mode 100644 index 0000000..b9ab550 --- /dev/null +++ b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m @@ -0,0 +1,339 @@ +// +// XLPagerTabStripViewController +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLPagerTabStripViewController.h" + +@interface XLPagerTabStripViewController () + +@property (nonatomic) NSUInteger currentIndex; + +@end + +@implementation XLPagerTabStripViewController +{ + NSUInteger _lastPageNumber; + CGFloat _lastContentOffset; + NSUInteger _pageBeforeRotate; + NSArray * _originalPagerTabStripChildViewControllers; +} + +@synthesize currentIndex = _currentIndex; + +#pragma maek - initializers + +-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self){ + [self pagerTabStripViewControllerInit]; + } + return self; +} + + +-(id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super initWithCoder:aDecoder]; + if (self) + { + [self pagerTabStripViewControllerInit]; + } + return self; +} + + +-(void)pagerTabStripViewControllerInit +{ + _currentIndex = 0; + _delegate = self; + _dataSource = self; + _lastContentOffset = 0.0f; + _skipIntermediateViewControllers = YES; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + if (!self.containerView){ + self.containerView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds))]; + self.containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + + [self.view addSubview:self.containerView]; + } + self.containerView.bounces = YES; + [self.containerView setAlwaysBounceHorizontal:YES]; + [self.containerView setAlwaysBounceVertical:NO]; + self.containerView.scrollsToTop = NO; + self.containerView.delegate = self; + self.containerView.showsVerticalScrollIndicator = NO; + self.containerView.showsHorizontalScrollIndicator = NO; + self.containerView.pagingEnabled = YES; + + if (self.dataSource){ + _pagerTabStripChildViewControllers = [self.dataSource childViewControllersForPagerTabStripViewController:self]; + } +} + +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + [self.containerView setContentOffset:CGPointMake([self pageOffsetForChildIndex:self.currentIndex], 0) animated:NO]; +} + + +#pragma mark - move to another view controller + +-(void)moveToViewControllerAtIndex:(NSUInteger)index +{ + [self moveToViewControllerAtIndex:index animated:YES]; +} + +-(void)moveToViewControllerAtIndex:(NSInteger)index withDirection:(XLPagerTabStripDirection)direction animated:(BOOL)animated +{ + if (self.skipIntermediateViewControllers && fabs(self.currentIndex - index) > 1){ + NSArray * originalPagerTabStripChildViewControllers = self.pagerTabStripChildViewControllers; + NSMutableArray * tempChildViewControllers = [NSMutableArray arrayWithArray:originalPagerTabStripChildViewControllers]; + UIViewController * currentChildVC = [originalPagerTabStripChildViewControllers objectAtIndex:self.currentIndex]; + NSUInteger fromIndex = (direction == XLPagerTabStripDirectionLeft) ? index - 1 : index + 1; + [tempChildViewControllers setObject:[originalPagerTabStripChildViewControllers objectAtIndex:fromIndex] atIndexedSubscript:self.currentIndex]; + [tempChildViewControllers setObject:currentChildVC atIndexedSubscript:fromIndex]; + _pagerTabStripChildViewControllers = tempChildViewControllers; + [self.containerView setContentOffset:CGPointMake([self pageOffsetForChildIndex:fromIndex], 0) animated:NO]; + if (self.navigationController){ + self.navigationController.view.userInteractionEnabled = NO; + } + else{ + self.view.userInteractionEnabled = NO; + } + _originalPagerTabStripChildViewControllers = originalPagerTabStripChildViewControllers; + [self.containerView setContentOffset:CGPointMake([self pageOffsetForChildIndex:index], 0) animated:YES]; + } + else{ + [self.containerView setContentOffset:CGPointMake([self pageOffsetForChildIndex:index], 0) animated:animated]; + } +} + +-(void)moveToViewControllerAtIndex:(NSUInteger)index animated:(bool)animated +{ + if (![self isViewLoaded]){ + self.currentIndex = index; + } + else{ + if (self.currentIndex < index){ + [self moveToViewControllerAtIndex:index withDirection:XLPagerTabStripDirectionLeft animated:YES]; + } + else if (self.currentIndex > index){ + [self moveToViewControllerAtIndex:index withDirection:XLPagerTabStripDirectionRight animated:YES]; + } + } +} + + +-(void)moveToViewController:(UIViewController *)viewController +{ + [self moveToViewControllerAtIndex:[self.pagerTabStripChildViewControllers indexOfObject:viewController]]; +} + + +#pragma mark - XLPagerTabStripViewControllerDelegate + +-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController{ +} + + +#pragma mark - XLPagerTabStripViewControllerDataSource + +-(NSArray *)childViewControllersForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController +{ + return self.pagerTabStripChildViewControllers; +} + + +#pragma mark - Helpers + +-(BOOL)canMoveToIndex:(NSUInteger)index +{ + return (self.currentIndex != index && self.pagerTabStripChildViewControllers.count > index); +} + +-(CGFloat)pageOffsetForChildIndex:(NSUInteger)index +{ + return (index * CGRectGetWidth(self.containerView.bounds)); +} + +-(CGFloat)offsetForChildIndex:(NSUInteger)index +{ + return (index * CGRectGetWidth(self.containerView.bounds) + ((CGRectGetWidth(self.containerView.bounds) - CGRectGetWidth(self.view.bounds)) * 0.5)); +} + +-(CGFloat)offsetForChildViewController:(UIViewController *)viewController +{ + NSInteger index = [self.pagerTabStripChildViewControllers indexOfObject:viewController]; + if (index == NSNotFound){ + @throw [NSException exceptionWithName:NSRangeException reason:nil userInfo:nil]; + } + return [self offsetForChildIndex:index]; +} + +-(NSUInteger)pageForContentOffset:(CGFloat)contentOffset +{ + return (contentOffset + (0.5f * [self pageWidth])) / [self pageWidth]; +} + +-(CGFloat)pageWidth +{ + return CGRectGetWidth(self.containerView.bounds); +} + +-(CGFloat)scrollPercentage +{ + return fmodf(self.containerView.contentOffset.x, [self pageWidth]) / [self pageWidth]; +} + +-(void)updateContent +{ + NSArray * childViewControllers = self.pagerTabStripChildViewControllers; + self.containerView.contentSize = CGSizeMake(CGRectGetWidth(self.containerView.bounds) * childViewControllers.count, self.containerView.contentSize.height); + NSUInteger currentPage = [self pageForContentOffset:self.containerView.contentOffset.x]; + if (currentPage != self.currentIndex){ + self.currentIndex = currentPage; + } + + [childViewControllers enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + UIViewController * childController = (UIViewController *)obj; + CGFloat pageOffsetForChild = [self pageOffsetForChildIndex:idx]; + if (fabs(self.containerView.contentOffset.x - pageOffsetForChild) < CGRectGetWidth(self.containerView.bounds)){ + if (![childController parentViewController]){ + [self addChildViewController:childController]; + [childController didMoveToParentViewController:self]; + CGFloat childPosition = [self offsetForChildIndex:idx]; + [childController.view setFrame:CGRectMake(childPosition, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.containerView.bounds))]; + childController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; + [self.containerView addSubview:childController.view]; + } + else{ + CGFloat childPosition = [self offsetForChildIndex:idx]; + [childController.view setFrame:CGRectMake(childPosition, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.containerView.bounds))]; + childController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; + } + } + else{ + if ([childController parentViewController]){ + [childController.view removeFromSuperview]; + [childController willMoveToParentViewController:nil]; + [childController removeFromParentViewController]; + } + } + }]; +} + + +#pragma mark - UIScrollViewDelegte + +-(void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + if (self.containerView == scrollView){ + // pan direction + XLPagerTabStripDirection direction = XLPagerTabStripDirectionNone; + if (scrollView.contentOffset.x > _lastContentOffset){ + direction = XLPagerTabStripDirectionLeft; + } + else if (scrollView.contentOffset.x < _lastContentOffset){ + direction = XLPagerTabStripDirectionRight; + } + [self updateContent]; + } +} + + +-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView +{ + if (self.containerView == scrollView){ + _lastPageNumber = [self pageForContentOffset:scrollView.contentOffset.x]; + _lastContentOffset = scrollView.contentOffset.x; + } +} + +-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView +{ + if (self.containerView == scrollView && _originalPagerTabStripChildViewControllers){ + _pagerTabStripChildViewControllers = _originalPagerTabStripChildViewControllers; + _originalPagerTabStripChildViewControllers = nil; + if (self.navigationController){ + self.navigationController.view.userInteractionEnabled = YES; + } + else{ + self.view.userInteractionEnabled = YES; + } + [self updateContent]; + } +} + + +#pragma mark - Properties + + +-(NSUInteger)currentIndex +{ + return _currentIndex; +} + +-(void)setCurrentIndex:(NSUInteger)currentIndex +{ + UIViewController * fromViewController = [self.pagerTabStripChildViewControllers objectAtIndex:_currentIndex]; + _currentIndex = currentIndex; + // invoke delegate method + if ([self.delegate respondsToSelector:@selector(pagerTabStripViewController:updateIndicatorToViewController:fromViewController:)]){ + [self.delegate pagerTabStripViewController:self updateIndicatorToViewController:[self.pagerTabStripChildViewControllers objectAtIndex:_currentIndex] fromViewController:fromViewController]; + } + // +} + +#pragma mark - Orientation + +-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration +{ + _pageBeforeRotate = self.currentIndex; +} + +-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration +{ + self.currentIndex = _pageBeforeRotate; + self.containerView.contentSize = CGSizeMake(CGRectGetWidth(self.containerView.bounds) * self.pagerTabStripChildViewControllers.count, self.containerView.contentSize.height); + [self.containerView setContentOffset:CGPointMake([self pageOffsetForChildIndex:_pageBeforeRotate], 0) animated:NO]; + + [self updateContent]; +} + + +-(void)viewDidLayoutSubviews +{ + //NSLog(@"%s", __PRETTY_FUNCTION__); + [super viewDidLayoutSubviews]; + [self updateContent]; +} + + +@end diff --git a/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.h b/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.h new file mode 100644 index 0000000..01e2f61 --- /dev/null +++ b/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.h @@ -0,0 +1,32 @@ +// +// XLSegmentedPagerTabStripViewController.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLPagerTabStripViewController.h" + +@interface XLSegmentedPagerTabStripViewController : XLPagerTabStripViewController + +@property (nonatomic, readonly) UISegmentedControl * segmentedControl; + +@end diff --git a/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m new file mode 100644 index 0000000..ef6d52a --- /dev/null +++ b/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m @@ -0,0 +1,123 @@ +// +// XLSegmentedPagerTabStripViewController.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLPagerTabStripViewController.h" +#import "XLSegmentedPagerTabStripViewController.h" + +@interface XLSegmentedPagerTabStripViewController () + +@property (nonatomic) IBOutlet UISegmentedControl * segmentedControl; +@property (nonatomic) BOOL shouldUpdateSegmentedControl; + +@end + +@implementation XLSegmentedPagerTabStripViewController + +-(id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super initWithCoder:aDecoder]; + if (self){ + self.shouldUpdateSegmentedControl = YES; + } + return self; +} + +-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self){ + self.shouldUpdateSegmentedControl = YES; + } + return self; +} + +-(void)viewDidLoad +{ + [super viewDidLoad]; + // initialize segmented control + if (!self.segmentedControl.superview) { + [self.navigationItem setTitleView:self.segmentedControl]; + } + [self.segmentedControl removeAllSegments]; + [self.segmentedControl addTarget:self + action:@selector(segmentedControlChanged:) + forControlEvents:UIControlEventValueChanged]; + [self.pagerTabStripChildViewControllers enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + NSAssert([obj conformsToProtocol:@protocol(XLPagerTabStripChildItem)], @"child view controller must conform to XLPagerTabStripChildItem"); + UIViewController * childViewController = (UIViewController *)obj; + if ([childViewController respondsToSelector:@selector(imageForPagerTabStripViewController:)]){ + + [self.segmentedControl insertSegmentWithImage:[childViewController imageForPagerTabStripViewController:self] atIndex:idx animated:NO]; + } + else{ + [self.segmentedControl insertSegmentWithTitle:[childViewController titleForPagerTabStripViewController:self] atIndex:idx animated:NO]; + } + + }]; + [self.segmentedControl setSelectedSegmentIndex:self.currentIndex]; + +} + + + +-(UISegmentedControl *)segmentedControl +{ + if (_segmentedControl) return _segmentedControl; + _segmentedControl = [[UISegmentedControl alloc] init]; + return _segmentedControl; +} + + +-(void)segmentedControlChanged:(UISegmentedControl *)sender +{ + NSInteger index = [sender selectedSegmentIndex]; + [self pagerTabStripViewController:self updateIndicatorToViewController:[[self.dataSource childViewControllersForPagerTabStripViewController:self] objectAtIndex:index] fromViewController:nil]; + self.shouldUpdateSegmentedControl = NO; + [self moveToViewControllerAtIndex:index]; +} + +#pragma mark - XLPagerTabStripViewControllerDelegate + +-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController +{ + if (self.shouldUpdateSegmentedControl){ + UIViewController * childViewController = (UIViewController *)toViewController; + if ([childViewController respondsToSelector:@selector(colorForPagerTabStripViewController:)]){ + [self.segmentedControl setTintColor:[childViewController colorForPagerTabStripViewController:self]]; + } + [self.segmentedControl setSelectedSegmentIndex:[self.pagerTabStripChildViewControllers indexOfObject:childViewController]]; + } +} + + +#pragma mark - UIScrollViewDelegate + +-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView +{ + [super scrollViewDidEndScrollingAnimation:scrollView]; + self.shouldUpdateSegmentedControl = YES; +} + +@end diff --git a/XLPagerTabStrip/XL/Views/XLBarView.h b/XLPagerTabStrip/XL/Views/XLBarView.h new file mode 100644 index 0000000..5ab0ea9 --- /dev/null +++ b/XLPagerTabStrip/XL/Views/XLBarView.h @@ -0,0 +1,37 @@ +// +// XLBarView.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 + +@interface XLBarView : UIView + +@property (readonly, nonatomic) UIView * selectedBar; + +-(id)initWithFrame:(CGRect)frame optionsAmount:(NSUInteger)optionsAmount selectedOptionIndex:(NSUInteger)selectedOptionIndex; + +-(void)moveToIndex:(NSUInteger)index animated:(BOOL)animated; +-(void)setOptionsAmount:(NSUInteger)optionsAmount animated:(BOOL)animated; + +@end diff --git a/XLPagerTabStrip/XL/Views/XLBarView.m b/XLPagerTabStrip/XL/Views/XLBarView.m new file mode 100644 index 0000000..9bc1557 --- /dev/null +++ b/XLPagerTabStrip/XL/Views/XLBarView.m @@ -0,0 +1,118 @@ +// +// XLBarView.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLBarView.h" + +@interface XLBarView() + +@property UIView * selectedBar; +@property NSUInteger optionsAmount; +@property NSUInteger selectedOptionIndex; + +@end + +@implementation XLBarView + +- (instancetype)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + _optionsAmount = 1; + _selectedOptionIndex = 0; + [self addSubview:self.selectedBar]; + } + return self; +} + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code + _optionsAmount = 1; + _selectedOptionIndex = 0; + } + return self; +} + +- (id)initWithFrame:(CGRect)frame optionsAmount:(NSUInteger)optionsAmount selectedOptionIndex:(NSUInteger)selectedOptionIndex +{ + self = [self initWithFrame:frame]; + if (self){ + _optionsAmount = optionsAmount; + _selectedOptionIndex = selectedOptionIndex; + [self addSubview:self.selectedBar]; + } + return self; +} + +-(UIView *)selectedBar +{ + if (_selectedBar) return _selectedBar; + _selectedBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; + [self updateSelectedBarPositionWithAnimation:NO]; + return _selectedBar; +} + + +#pragma mark - Helpers + +-(void)updateSelectedBarPositionWithAnimation:(BOOL)animation +{ + CGRect frame = self.selectedBar.frame; + frame.size.width = self.frame.size.width / self.optionsAmount; + frame.origin.x = frame.size.width * self.selectedOptionIndex; + if (animation){ + [UIView animateWithDuration:0.3 animations:^{ + [self.selectedBar setFrame:frame]; + }]; + } + else{ + self.selectedBar.frame = frame; + } +} + +-(void)moveToIndex:(NSUInteger)index animated:(BOOL)animated +{ + self.selectedOptionIndex = index; + [self updateSelectedBarPositionWithAnimation:animated]; +} + + +-(void)setOptionsAmount:(NSUInteger)optionsAmount animated:(BOOL)animated +{ + self.optionsAmount = optionsAmount; + if (self.optionsAmount <= self.selectedOptionIndex){ + self.selectedOptionIndex = self.optionsAmount - 1; + } + [self updateSelectedBarPositionWithAnimation:animated]; +} + +-(void)layoutSubviews +{ + [self updateSelectedBarPositionWithAnimation:NO]; +} + +@end diff --git a/XLPagerTabStrip/XL/Views/XLButtonBarView.h b/XLPagerTabStrip/XL/Views/XLButtonBarView.h new file mode 100644 index 0000000..f3ced0c --- /dev/null +++ b/XLPagerTabStrip/XL/Views/XLButtonBarView.h @@ -0,0 +1,42 @@ +// +// XLButtonBarView.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 + +#import "XLPagerTabStripViewController.h" + + +@interface XLButtonBarView : UICollectionView + +@property (readonly, nonatomic) UIView * selectedBar; +@property UIFont * labelFont; +@property NSUInteger leftRightMargin; + +-(void)moveToIndex:(NSUInteger)index animated:(BOOL)animated swipeDirection:(XLPagerTabStripDirection)swipeDirection; + + + + +@end diff --git a/XLPagerTabStrip/XL/Views/XLButtonBarView.m b/XLPagerTabStrip/XL/Views/XLButtonBarView.m new file mode 100644 index 0000000..fa5b089 --- /dev/null +++ b/XLPagerTabStrip/XL/Views/XLButtonBarView.m @@ -0,0 +1,118 @@ +// +// XLButtonBarView.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLButtonBarView.h" + +@interface XLButtonBarView () + +@property UIView * selectedBar; +@property NSUInteger selectedOptionIndex; + +@end + +@implementation XLButtonBarView + + +- (instancetype)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + [self initializeXLButtonBarView]; + } + return self; +} + + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self initializeXLButtonBarView]; + } + return self; +} + +-(void)initializeXLButtonBarView +{ + _selectedOptionIndex = 0; + [self addSubview:self.selectedBar]; +} + + +-(void)moveToIndex:(NSUInteger)index animated:(BOOL)animated swipeDirection:(XLPagerTabStripDirection)swipeDirection +{ + if (self.selectedOptionIndex != index){ + self.selectedOptionIndex = index; + [self updateSelectedBarPositionWithAnimation:animated swipeDirection:swipeDirection]; + } +} + + +-(void)updateSelectedBarPositionWithAnimation:(BOOL)animation swipeDirection:(XLPagerTabStripDirection)swipeDirection +{ + CGRect frame = self.selectedBar.frame; + UICollectionViewCell * cell = [self.dataSource collectionView:self cellForItemAtIndexPath:[NSIndexPath indexPathForItem:self.selectedOptionIndex inSection:0]]; + if (cell){ + if (swipeDirection != XLPagerTabStripDirectionNone){ + if (swipeDirection == XLPagerTabStripDirectionLeft) + { + float xValue = MIN(self.contentSize.width - self.frame.size.width, cell.frame.origin.x <= 35 ? 0 : cell.frame.origin.x - 35); + [self setContentOffset:CGPointMake(xValue, 0) animated:animation]; + } + else if (swipeDirection == XLPagerTabStripDirectionRight){ + float xValue = MAX(0, cell.frame.origin.x + cell.frame.size.width - self.frame.size.width + 35); + [self setContentOffset:CGPointMake(xValue, 0) animated:animation]; + } + + } + } + frame.size.width = cell.frame.size.width; + frame.origin.x = cell.frame.origin.x; + frame.origin.y = cell.frame.size.height - frame.size.height; + if (animation){ + [UIView animateWithDuration:0.3 animations:^{ + [self.selectedBar setFrame:frame]; + }]; + } + else{ + self.selectedBar.frame = frame; + } +} + + +#pragma mark - Properties + +-(UIView *)selectedBar +{ + if (_selectedBar) return _selectedBar; + _selectedBar = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - 5, self.frame.size.width, 5)]; + _selectedBar.layer.zPosition = 9999; + _selectedBar.backgroundColor = [UIColor blackColor]; + return _selectedBar; +} + + +@end diff --git a/XLPagerTabStrip/XL/Views/XLButtonBarViewCell.h b/XLPagerTabStrip/XL/Views/XLButtonBarViewCell.h new file mode 100644 index 0000000..bea7faa --- /dev/null +++ b/XLPagerTabStrip/XL/Views/XLButtonBarViewCell.h @@ -0,0 +1,33 @@ +// +// XLButtonBarViewCell.h +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 + +@interface XLButtonBarViewCell : UICollectionViewCell + +@property (readonly, nonatomic) UIImageView * imageView; +@property (readonly, nonatomic) UILabel * label; + +@end diff --git a/XLPagerTabStrip/XL/Views/XLButtonBarViewCell.m b/XLPagerTabStrip/XL/Views/XLButtonBarViewCell.m new file mode 100644 index 0000000..f76e7c0 --- /dev/null +++ b/XLPagerTabStrip/XL/Views/XLButtonBarViewCell.m @@ -0,0 +1,40 @@ +// +// XLButtonBarViewCell.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 "XLButtonBarViewCell.h" + +@interface XLButtonBarViewCell() + +@property IBOutlet UIImageView * imageView; +@property IBOutlet UILabel * label; + +@end + +@implementation XLButtonBarViewCell + + + + +@end diff --git a/XLPagerTabStrip/main.m b/XLPagerTabStrip/main.m new file mode 100644 index 0000000..2511df6 --- /dev/null +++ b/XLPagerTabStrip/main.m @@ -0,0 +1,33 @@ +// +// main.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/XLPagerTabStripTests/Info.plist b/XLPagerTabStripTests/Info.plist new file mode 100644 index 0000000..8a57cd3 --- /dev/null +++ b/XLPagerTabStripTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.xmartlabs.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/XLPagerTabStripTests/XLPagerTabStripTests.m b/XLPagerTabStripTests/XLPagerTabStripTests.m new file mode 100644 index 0000000..0043cf5 --- /dev/null +++ b/XLPagerTabStripTests/XLPagerTabStripTests.m @@ -0,0 +1,57 @@ +// +// XLPagerTabStripTests.m +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2014 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 +#import + +@interface XLPagerTabStripTests : XCTestCase + +@end + +@implementation XLPagerTabStripTests + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + XCTAssert(YES, @"Pass"); +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end