Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7ae09c2
Showing
39 changed files
with
1,924 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# OS X | ||
.DS_Store | ||
|
||
# Xcode | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
profile | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
|
||
**/Pods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# ESConveyorBelt CHANGELOG | ||
|
||
## 0.1.0 | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Created by Eduardo Scoz on 6/8/13. | ||
// Copyright (c) 2013 ESCOZ. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@class ESConveyorController; | ||
|
||
|
||
@interface ESConveyorAdapter : NSObject <UICollectionViewDelegate, UICollectionViewDataSource> | ||
|
||
@property(nonatomic) NSInteger numberOfPages; | ||
|
||
@property(nonatomic, strong) NSArray *elements; | ||
|
||
- (id)initWithCollectionView:(UICollectionView *)collectionView numberOfPages:(NSInteger)pages elements:(NSArray *)elements; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// Created by Eduardo Scoz on 6/8/13. | ||
// Copyright (c) 2013 ESCOZ. All rights reserved. | ||
// | ||
|
||
#import "ESConveyorAdapter.h" | ||
#import "ESConveyorController.h" | ||
#import "ESConveyorView.h" | ||
#import "ESConveyorFlowLayout.h" | ||
#import "ESConveyorView.h" | ||
#import "ESConveyorElement.h" | ||
#import "ESConveyorPageCell.h" | ||
|
||
|
||
static NSString *const ESConveyorElementReuseIdentifier = @"ESConveyorElementReuseIdentifier"; | ||
NSString *kESConveyorCell = @"ESConveyorCell"; | ||
|
||
@interface ESConveyorAdapter () | ||
@property(nonatomic, weak) UICollectionView *collectionView; | ||
@end | ||
|
||
@implementation ESConveyorAdapter | ||
{ | ||
|
||
} | ||
- (id)initWithCollectionView:(UICollectionView *)collectionView numberOfPages:(NSInteger)pages elements:(NSArray *)elements | ||
{ | ||
|
||
self = [super init]; | ||
if (self) | ||
{ | ||
self.collectionView = collectionView; | ||
self.numberOfPages = pages; | ||
self.elements = elements; | ||
|
||
self.collectionView.delegate = self; | ||
self.collectionView.dataSource = self; | ||
self.collectionView.pagingEnabled = YES; | ||
|
||
[self.collectionView registerClass:[ESConveyorPageCell class] forCellWithReuseIdentifier:kESConveyorCell]; | ||
[self.collectionView registerClass:[ESConveyorView class] forSupplementaryViewOfKind:NSStringFromClass(ESConveyorElement.class) withReuseIdentifier:ESConveyorElementReuseIdentifier]; | ||
|
||
} | ||
|
||
return self; | ||
} | ||
|
||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section | ||
{ | ||
return 1; | ||
} | ||
|
||
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView | ||
{ | ||
return self.numberOfPages; | ||
} | ||
|
||
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
ESConveyorView *view = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:ESConveyorElementReuseIdentifier forIndexPath:indexPath]; | ||
ESConveyorElement *obj = [self.elements objectAtIndex:(NSUInteger) indexPath.row]; | ||
[view setCarrousselObject:obj]; | ||
return view; | ||
} | ||
|
||
|
||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
return [collectionView dequeueReusableCellWithReuseIdentifier:kESConveyorCell forIndexPath:indexPath]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Created by Eduardo Scoz on 6/8/13. | ||
// Copyright (c) 2013 ESCOZ. All rights reserved. | ||
// | ||
|
||
#import "ESConveyorController.h" | ||
#import "ESConveyorPageCell.h" | ||
#import "ESConveyorElement.h" | ||
#import "ESConveyorPageControlElement.h" | ||
#import "ESConveyorController.h" | ||
|
||
|
||
typedef NS_ENUM(NSUInteger, EZEffect) { | ||
ESConveyorEffectFade, | ||
ESConveyorEffectEdgeTop, | ||
ESConveyorEffectEdgeLeft, | ||
ESConveyorEffectEdgeRight, | ||
ESConveyorEffectEdgeBottom, | ||
ESConveyorEffectParallax10, | ||
ESConveyorEffectParallax20, | ||
ESConveyorEffectParallax33, | ||
ESConveyorEffectParallax40, | ||
ESConveyorEffectParallax50, | ||
ESConveyorEffectParallax150, | ||
ESConveyorEffectParallax200 | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Created by Eduardo Scoz on 6/8/13. | ||
// Copyright (c) 2013 ESCOZ. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@class ESConveyorAdapter; | ||
|
||
|
||
@interface ESConveyorController : UICollectionViewController | ||
@property(nonatomic, strong) ESConveyorAdapter *adapter; | ||
|
||
- (id)initWithPages:(NSInteger)numberOfPages elements:(NSArray *)elements; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Created by Eduardo Scoz on 6/8/13. | ||
// Copyright (c) 2013 ESCOZ. All rights reserved. | ||
// | ||
|
||
#import "ESConveyorController.h" | ||
#import "ESConveyorFlowLayout.h" | ||
#import "ESConveyorAdapter.h" | ||
#import "ESConveyorElement.h" | ||
|
||
|
||
@implementation ESConveyorController | ||
{ | ||
|
||
} | ||
- (instancetype)initWithPages:(NSInteger)numberOfPages elements:(NSArray *)elements | ||
{ | ||
ESConveyorFlowLayout *layout = [[ESConveyorFlowLayout alloc] init]; | ||
|
||
self = [super initWithCollectionViewLayout:layout]; | ||
if (self) { | ||
|
||
self.adapter = [[ESConveyorAdapter alloc] initWithCollectionView:self.collectionView numberOfPages:numberOfPages elements:elements]; | ||
layout.adapter = self.adapter; | ||
|
||
self.collectionView.showsHorizontalScrollIndicator = NO; | ||
self.collectionView.showsVerticalScrollIndicator = NO; | ||
self.collectionView.backgroundColor = [UIColor whiteColor]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Created by Eduardo Scoz on 6/8/13. | ||
// Copyright (c) 2013 ESCOZ. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@class ESConveyorElement; | ||
|
||
|
||
@interface ESConveyorEffects : NSObject | ||
|
||
- (UICollectionViewLayoutAttributes *)getAttributesForPage:(NSUInteger)page atOffset:(CGPoint)offset pageWidth:(CGSize)pageSize index:(NSInteger)index progress:(CGFloat)progress element:(ESConveyorElement *)element; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// | ||
// Created by Eduardo Scoz on 6/8/13. | ||
// Copyright (c) 2013 ESCOZ. All rights reserved. | ||
// | ||
|
||
#import "ESConveyorEffects.h" | ||
#import "ESConveyorBelt.h" | ||
#import "ESConveyorElement.h" | ||
|
||
|
||
@implementation ESConveyorEffects | ||
{ | ||
|
||
} | ||
|
||
- (UICollectionViewLayoutAttributes *)getAttributesForPage:(NSUInteger)page atOffset:(CGPoint)offset pageWidth:(CGSize)pageSize index:(NSInteger)index progress:(CGFloat)progress element:(ESConveyorElement *)element | ||
{ | ||
UICollectionViewLayoutAttributes *attr = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:@"ESConveyorElement" withIndexPath:[NSIndexPath indexPathForItem:index inSection:0]]; | ||
attr.center = CGPointMake(offset.x + element.center.x, offset.y + element.center.y); | ||
attr.size = element.size; | ||
attr.alpha = 1; | ||
|
||
NSArray *effects; | ||
BOOL exitingPage = offset.x > page * pageSize.width; | ||
BOOL exitingPreviousPage = offset.x > page-1 * pageSize.width; | ||
|
||
BOOL exiting = NO; | ||
|
||
if (page==element.inPage && !exitingPage) | ||
effects = element.inEffects; | ||
|
||
else if (page-1==element.outPage && exitingPreviousPage) | ||
{ | ||
effects = element.outEffects; | ||
progress = 1 - progress; | ||
exiting = YES; | ||
page = page -1; | ||
} | ||
else | ||
effects = element.paginationEffects; | ||
|
||
if (effects==nil) | ||
return attr; | ||
|
||
if ([effects containsObject:@(ESConveyorEffectParallax10)]) | ||
[self doParallax:page pageSize:pageSize progress:progress attr:attr ratio:10 direction:exiting element:element]; | ||
|
||
if ([effects containsObject:@(ESConveyorEffectParallax20)]) | ||
[self doParallax:page pageSize:pageSize progress:progress attr:attr ratio:5 direction:exiting element:element]; | ||
|
||
if ([effects containsObject:@(ESConveyorEffectParallax33)]) | ||
[self doParallax:page pageSize:pageSize progress:progress attr:attr ratio:3.3 direction:exiting element:element]; | ||
|
||
if ([effects containsObject:@(ESConveyorEffectParallax40)]) | ||
[self doParallax:page pageSize:pageSize progress:progress attr:attr ratio:2.5 direction:exiting element:element]; | ||
|
||
if ([effects containsObject:@(ESConveyorEffectParallax50)]) | ||
[self doParallax:page pageSize:pageSize progress:progress attr:attr ratio:2 direction:exiting element:element]; | ||
|
||
if ([effects containsObject:@(ESConveyorEffectParallax150)]) | ||
[self doParallax:page pageSize:pageSize progress:progress attr:attr ratio:0.75 direction:exiting element:element]; | ||
|
||
if ([effects containsObject:@(ESConveyorEffectParallax200)]) | ||
[self doParallax:page pageSize:pageSize progress:progress attr:attr ratio:0.5 direction:exiting element:element]; | ||
|
||
if ([effects containsObject:@(ESConveyorEffectFade)]) | ||
{ | ||
attr.alpha = progress; | ||
} | ||
|
||
if ([effects containsObject:@(ESConveyorEffectEdgeTop)]) | ||
{ | ||
CGFloat start = - element.size.height / 2; | ||
CGFloat current = offset.y + ((element.center.y - start) * progress) + start; | ||
CGPoint newCenter = attr.center; | ||
newCenter.y = current; | ||
attr.center = newCenter; | ||
} | ||
|
||
if ([effects containsObject:@(ESConveyorEffectEdgeLeft)]) | ||
{ | ||
CGFloat start = - (element.size.width / 2); | ||
CGFloat current = ((element.center.x - start) * progress) + start; | ||
CGPoint newCenter = attr.center; | ||
newCenter.x = offset.x +current; | ||
attr.center = newCenter; | ||
} | ||
|
||
if ([effects containsObject:@(ESConveyorEffectEdgeRight)]) | ||
{ | ||
CGFloat start = pageSize.width + (element.size.width / 2); | ||
CGFloat current = ((element.center.x - start) * progress) + start; | ||
CGPoint newCenter = attr.center; | ||
newCenter.x = offset.x +current; | ||
attr.center = newCenter; | ||
} | ||
|
||
if ([effects containsObject:@(ESConveyorEffectEdgeBottom)]) | ||
{ | ||
CGFloat start = pageSize.height + (element.size.height / 2); | ||
CGFloat current = ((element.center.y - start) * progress) + start; | ||
CGPoint newCenter = attr.center; | ||
newCenter.y = offset.y + current; | ||
attr.center = newCenter; | ||
} | ||
|
||
return attr; | ||
} | ||
|
||
|
||
- (void)doParallax:(NSUInteger)page pageSize:(CGSize)pageSize progress:(CGFloat)progress attr:(UICollectionViewLayoutAttributes *)attr ratio:(CGFloat)speed direction:(BOOL)exiting element:(ESConveyorElement *)element | ||
{ | ||
CGFloat pixelsPerPage = pageSize.width / speed; | ||
CGFloat pixelsToMove = (page - element.inPage) * pixelsPerPage; | ||
pixelsToMove = pixelsToMove - ( (pixelsPerPage * (1-progress)) * (exiting ? -1 : 1 )); | ||
|
||
CGPoint newCenter = attr.center; | ||
newCenter.x = newCenter.x - pixelsToMove; | ||
attr.center = newCenter; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Created by Eduardo Scoz on 6/8/13. | ||
// Copyright (c) 2013 ESCOZ. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
@interface ESConveyorElement : NSObject | ||
|
||
@property(nonatomic) CGSize size; | ||
@property(nonatomic) CGPoint center; | ||
@property(nonatomic, strong) UIColor *color; | ||
@property(nonatomic, strong) UIView *view; | ||
|
||
@property(nonatomic, strong) NSArray *inEffects; | ||
@property(nonatomic, strong) NSArray *outEffects; | ||
|
||
@property(nonatomic) NSInteger inPage; | ||
@property(nonatomic) NSInteger outPage; | ||
|
||
|
||
@property(nonatomic, strong) NSArray *paginationEffects; | ||
|
||
+ (ESConveyorElement *)elementForImageNamed:(NSString *)string; | ||
+ (ESConveyorElement *)elementForImageNamed:(NSString *)imageName center:(CGPoint)center; | ||
|
||
+ (ESConveyorElement *)elementForButtonOfClass:(Class)pClass title:(NSString *)title target:(id)target action:(SEL)action center:(CGPoint)center; | ||
+ (ESConveyorElement *)elementForLabelOfClass:(Class)pClass text:(NSString *)text center:(CGPoint)center size:(CGSize)size; | ||
|
||
- (void)setEffects:(NSArray *)effects; | ||
|
||
- (void)setInEffects:(NSArray *)inEffects outEffects:(NSArray *)effects; | ||
- (void)setPage:(int)page; | ||
|
||
- (void)updateForPage:(NSUInteger)page totalPages:(NSInteger)pages progress:(CGFloat)progress offset:(CGPoint)offset; | ||
@end |
Oops, something went wrong.