Skip to content

Commit

Permalink
Merge pull request xmartlabs#8 from xmartlabs/dev
Browse files Browse the repository at this point in the history
Added isProgressiveIndicator property. Now we can update the current ind...
  • Loading branch information
Martin Barreto committed Feb 10, 2015
2 parents cbc7cea + fe5b872 commit 0804156
Show file tree
Hide file tree
Showing 17 changed files with 328 additions and 97 deletions.
4 changes: 2 additions & 2 deletions XLPagerTabStrip/Base.lproj/LaunchScreen.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
Expand All @@ -14,7 +14,7 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2014 Xmartlabs. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="20.5"/>
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
Expand Down
3 changes: 3 additions & 0 deletions XLPagerTabStrip/Demo/BarExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ - (instancetype)initWithCoder:(NSCoder *)coder
self = [super initWithCoder:coder];
if (self) {
_isReload = NO;
self.isProgressiveIndicator = YES;
}
return self;
}
Expand Down Expand Up @@ -81,6 +82,8 @@ -(NSArray *)childViewControllersForPagerTabStripViewController:(XLPagerTabStripV
-(void)reloadPagerTabStripView
{
_isReload = YES;
self.isProgressiveIndicator = (rand() % 2 == 0);
self.isElasticIndicatorLimit = (rand() % 2 == 0);;
[super reloadPagerTabStripView];
}

Expand Down
5 changes: 3 additions & 2 deletions XLPagerTabStrip/Demo/ButtonBarExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ @implementation ButtonBarExampleViewController
BOOL _isReload;
}


- (void)viewDidLoad {
[super viewDidLoad];
self.isProgressiveIndicator = NO;
// Do any additional setup after loading the view.
[self.buttonBarView.selectedBar setBackgroundColor:[UIColor orangeColor]];
}
Expand Down Expand Up @@ -71,8 +71,9 @@ -(NSArray *)childViewControllersForPagerTabStripViewController:(XLPagerTabStripV
-(void)reloadPagerTabStripView
{
_isReload = YES;
self.isProgressiveIndicator = (rand() % 2 == 0);
self.isElasticIndicatorLimit = (rand() % 2 == 0);
[super reloadPagerTabStripView];
}


@end
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ -(NSString *)titleForPagerTabStripViewController:(XLPagerTabStripViewController

-(UIColor *)colorForPagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController
{
return [UIColor whiteColor];
return [UIColor blackColor];
}

@end
38 changes: 38 additions & 0 deletions XLPagerTabStrip/Demo/Helpers/ReloadExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,60 @@

@interface ReloadExampleViewController ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@end

@implementation ReloadExampleViewController

- (void)viewDidLoad {
[super viewDidLoad];
if (self.navigationController){
UILabel *bigLabel = [[UILabel alloc] init];
bigLabel.backgroundColor = [UIColor clearColor];
bigLabel.textColor = [UIColor whiteColor];
bigLabel.font = [UIFont boldSystemFontOfSize:20];
bigLabel.adjustsFontSizeToFitWidth = YES;
self.navigationItem.titleView = bigLabel;
[bigLabel sizeToFit];
}
[[self childViewControllers] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[XLPagerTabStripViewController class]]){
XLPagerTabStripViewController * pagerController = (id)obj;
[self updateTitle:pagerController];
*stop = YES;
}
}];


}

- (IBAction)reloadTapped:(id)sender {
[[self childViewControllers] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[XLPagerTabStripViewController class]]){
XLPagerTabStripViewController * pagerController = (id)obj;
[pagerController reloadPagerTabStripView];
[self updateTitle:pagerController];
*stop = YES;
}
}];
}

-(void)updateTitle:(XLPagerTabStripViewController *)pagerController
{
NSString * title = @"isProgressiveIndicator = NO";
if (pagerController.isProgressiveIndicator){
if (pagerController.isElasticIndicatorLimit){
title = @"isProgressiveIndicator = YES, isElasticIndicatorLimit = YES";
}
else{
title = @"isProgressiveIndicator = YES, isElasticIndicatorLimit = NO";
}
}

self.titleLabel.text = title;
((UILabel *)self.navigationItem.titleView).text = title;
[((UILabel *)self.navigationItem.titleView) sizeToFit];
}

@end
2 changes: 2 additions & 0 deletions XLPagerTabStrip/Demo/SegmentedExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ -(NSArray *)childViewControllersForPagerTabStripViewController:(XLPagerTabStripV

- (IBAction)reloadTapped:(id)sender {
_isReload = YES;
self.isProgressiveIndicator = (rand() % 2 == 0);
self.isElasticIndicatorLimit = (rand() % 2 == 0);
[self reloadPagerTabStripView];
}

Expand Down
33 changes: 25 additions & 8 deletions XLPagerTabStrip/Demo/Storyboard.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="ptL-BW-nEP">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="ptL-BW-nEP">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
Expand Down Expand Up @@ -77,12 +77,6 @@
<segue destination="MOL-Zx-vbf" kind="embed" id="i47-4L-xIB"/>
</connections>
</containerView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Storyboard Demo" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cZN-qT-VUq">
<rect key="frame" x="207" y="52" width="187" height="27.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="23"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jSE-G2-qe6">
<rect key="frame" x="527" y="83" width="57" height="34"/>
<state key="normal" title="Reload">
Expand All @@ -92,25 +86,48 @@
<action selector="reloadTapped:" destination="uba-Iz-2L2" eventType="touchUpInside" id="KNI-Zr-Zz0"/>
</connections>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Storyboard Demo" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="cZN-qT-VUq">
<rect key="frame" x="207" y="52" width="187" height="27.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="23"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.027450980390000001" green="0.72549019609999998" blue="0.60784313729999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="cZN-qT-VUq" firstAttribute="leading" secondItem="Mqm-sG-Qyv" secondAttribute="leadingMargin" id="9eC-5j-2zk"/>
<constraint firstAttribute="centerX" secondItem="cZN-qT-VUq" secondAttribute="centerX" id="AYy-gw-Ryh"/>
<constraint firstItem="NbE-e0-l2n" firstAttribute="top" secondItem="qkQ-UG-MKG" secondAttribute="bottom" id="K6Q-s5-nzV"/>
<constraint firstItem="cZN-qT-VUq" firstAttribute="trailing" secondItem="Mqm-sG-Qyv" secondAttribute="trailingMargin" id="Lma-fO-UC9"/>
<constraint firstItem="jSE-G2-qe6" firstAttribute="top" secondItem="Emc-3r-MJi" secondAttribute="bottom" constant="63" id="NWc-fy-XOc"/>
<constraint firstItem="cZN-qT-VUq" firstAttribute="top" secondItem="Emc-3r-MJi" secondAttribute="bottom" constant="32" id="RvZ-BV-1SL"/>
<constraint firstItem="qkQ-UG-MKG" firstAttribute="leading" secondItem="Mqm-sG-Qyv" secondAttribute="leading" id="Slo-zY-IGj"/>
<constraint firstItem="jSE-G2-qe6" firstAttribute="trailing" secondItem="Mqm-sG-Qyv" secondAttribute="trailingMargin" id="hbB-fi-M5S"/>
<constraint firstItem="qkQ-UG-MKG" firstAttribute="top" secondItem="Emc-3r-MJi" secondAttribute="bottom" constant="101" id="nJw-ag-ddh"/>
<constraint firstAttribute="trailing" secondItem="qkQ-UG-MKG" secondAttribute="trailing" id="pTb-BC-Duc"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="9eC-5j-2zk"/>
<exclude reference="Lma-fO-UC9"/>
</mask>
</variation>
<variation key="heightClass=regular-widthClass=compact">
<mask key="constraints">
<include reference="9eC-5j-2zk"/>
<include reference="Lma-fO-UC9"/>
</mask>
</variation>
</view>
<tabBarItem key="tabBarItem" systemItem="contacts" id="1d9-i6-g9L"/>
<navigationItem key="navigationItem" id="ni8-Kh-JRq"/>
<connections>
<outlet property="titleLabel" destination="cZN-qT-VUq" id="tRG-O0-13z"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="jkN-pv-eFH" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1340" y="139"/>
<point key="canvasLocation" x="1339.5" y="138.75"/>
</scene>
<!--Buttons Example-->
<scene sceneID="c3d-TB-Hyh">
Expand Down
4 changes: 4 additions & 0 deletions XLPagerTabStrip/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UILaunchImageFile</key>
<string>LaunchImage</string>
<key>UILaunchStoryboardName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,18 @@ -(XLBarView *)barView

-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController
{
[self.barView moveToIndex:[self.pagerTabStripChildViewControllers indexOfObject:toViewController] animated:YES];
[self.barView moveToIndex:[self.pagerTabStripChildViewControllers indexOfObject:toViewController]
animated:YES];
}

-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController
updateIndicatorFromIndex:(NSInteger)fromIndex
toIndex:(NSInteger)toIndex
withProgressPercentage:(CGFloat)progressPercentage
{
[self.barView moveFromIndex:fromIndex
toIndex:toIndex
withProgressPercentage:progressPercentage];
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ -(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStri
}
}

-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController
updateIndicatorFromIndex:(NSInteger)fromIndex
toIndex:(NSInteger)toIndex
withProgressPercentage:(CGFloat)progressPercentage
{
if (self.shouldUpdateButtonBarView){
[self.buttonBarView moveFromIndex:fromIndex
toIndex:toIndex
withProgressPercentage:progressPercentage];
}
}



#pragma merk - UICollectionViewDelegateFlowLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ typedef NS_ENUM(NSUInteger, XLPagerTabStripDirection) {

-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController;

-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController
updateIndicatorFromIndex:(NSInteger)fromIndex
toIndex:(NSInteger)toIndex
withProgressPercentage:(CGFloat)progressPercentage;

@end


Expand All @@ -82,6 +87,8 @@ typedef NS_ENUM(NSUInteger, XLPagerTabStripDirection) {

@property (readonly) NSUInteger currentIndex;
@property BOOL skipIntermediateViewControllers;
@property BOOL isProgressiveIndicator;
@property BOOL isElasticIndicatorLimit;

-(void)moveToViewControllerAtIndex:(NSUInteger)index;
-(void)moveToViewController:(UIViewController *)viewController;
Expand Down
Loading

0 comments on commit 0804156

Please sign in to comment.