Skip to content

Commit

Permalink
add experimental support for PSUICollectionView * classes that use ei…
Browse files Browse the repository at this point in the history
…ther PSTCollectionView or UICollectionView
  • Loading branch information
steipete committed Sep 27, 2012
1 parent 69e2d78 commit c5594ff
Show file tree
Hide file tree
Showing 106 changed files with 1,745 additions and 80 deletions.
2 changes: 1 addition & 1 deletion Examples/Basic/AppDelegate.m
Expand Up @@ -17,7 +17,7 @@ @implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithCollectionViewLayout:[UICollectionViewFlowLayout new]];
self.viewController = [[ViewController alloc] initWithCollectionViewLayout:[PSUICollectionViewFlowLayout new]];

self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
Expand Down
2 changes: 1 addition & 1 deletion Examples/Basic/Cell.h
Expand Up @@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
#import "PSTCollectionViewCell.h"

@interface Cell : UICollectionViewCell
@interface Cell : PSUICollectionViewCell

@property (strong, nonatomic) UILabel* label;

Expand Down
4 changes: 2 additions & 2 deletions Examples/Basic/ViewController.h
Expand Up @@ -6,8 +6,8 @@
//

#import <UIKit/UIKit.h>
#import "PSTCollectionViewController.h"
#import "PSTCollectionView.h"

@interface ViewController : UICollectionViewController
@interface ViewController : PSUICollectionViewController

@end
8 changes: 4 additions & 4 deletions Examples/Basic/ViewController.m
Expand Up @@ -26,23 +26,23 @@ - (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSI
///////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - PSTCollectionViewDelegate

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- (PSUICollectionViewCell *)collectionView:(PSUICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];
return cell;
}

///////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - PSTCollectionViewDelegateFlowLayout

- (CGSize)collectionView:(PSTCollectionView *)collectionView layout:(PSTCollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
- (CGSize)collectionView:(PSUICollectionView *)collectionView layout:(PSUICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(200, 200);
}

- (CGFloat)collectionView:(PSTCollectionView *)collectionView layout:(PSTCollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
- (CGFloat)collectionView:(PSUICollectionView *)collectionView layout:(PSUICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
return 10;
}

- (CGFloat)collectionView:(PSTCollectionView *)collectionView layout:(PSTCollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
- (CGFloat)collectionView:(PSUICollectionView *)collectionView layout:(PSUICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
return 50;
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/CircleLayout/CircleLayout/Cell.h
Expand Up @@ -94,7 +94,7 @@

#import <UIKit/UIKit.h>

@interface Cell : PSTCollectionViewCell
@interface Cell : PSUICollectionViewCell

@property (strong, nonatomic) UILabel* label;

Expand Down
2 changes: 1 addition & 1 deletion Examples/CircleLayout/CircleLayout/CircleLayout.h
Expand Up @@ -94,7 +94,7 @@

#import <UIKit/UIKit.h>

@interface CircleLayout : PSTCollectionViewLayout
@interface CircleLayout : PSUICollectionViewLayout

@property (nonatomic, assign) CGPoint center;
@property (nonatomic, assign) CGFloat radius;
Expand Down
12 changes: 6 additions & 6 deletions Examples/CircleLayout/CircleLayout/CircleLayout.m
Expand Up @@ -113,9 +113,9 @@ -(CGSize)collectionViewContentSize
return [self collectionView].frame.size;
}

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)path
- (PSUICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)path
{
UICollectionViewLayoutAttributes* attributes = (UICollectionViewLayoutAttributes*)[PSTCollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:path];
PSUICollectionViewLayoutAttributes* attributes = [PSUICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:path];
attributes.size = CGSizeMake(ITEM_SIZE, ITEM_SIZE);
attributes.center = CGPointMake(_center.x + _radius * cosf(2 * path.item * M_PI / _cellCount),
_center.y + _radius * sinf(2 * path.item * M_PI / _cellCount));
Expand All @@ -132,17 +132,17 @@ -(NSArray*)layoutAttributesForElementsInRect:(CGRect)rect
return attributes;
}

- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForInsertedItemAtIndexPath:(NSIndexPath *)itemIndexPath
- (PSUICollectionViewLayoutAttributes *)initialLayoutAttributesForInsertedItemAtIndexPath:(NSIndexPath *)itemIndexPath
{
UICollectionViewLayoutAttributes* attributes = (UICollectionViewLayoutAttributes *)[self layoutAttributesForItemAtIndexPath:itemIndexPath];
PSUICollectionViewLayoutAttributes* attributes = (PSUICollectionViewLayoutAttributes *)[self layoutAttributesForItemAtIndexPath:itemIndexPath];
attributes.alpha = 0.0;
attributes.center = CGPointMake(_center.x, _center.y);
return attributes;
}

- (UICollectionViewLayoutAttributes *)finalLayoutAttributesForDeletedItemAtIndexPath:(NSIndexPath *)itemIndexPath
- (PSUICollectionViewLayoutAttributes *)finalLayoutAttributesForDeletedItemAtIndexPath:(NSIndexPath *)itemIndexPath
{
UICollectionViewLayoutAttributes* attributes = (UICollectionViewLayoutAttributes *)[self layoutAttributesForItemAtIndexPath:itemIndexPath];
PSUICollectionViewLayoutAttributes* attributes = (PSUICollectionViewLayoutAttributes *)[self layoutAttributesForItemAtIndexPath:itemIndexPath];
attributes.alpha = 0.0;
attributes.center = CGPointMake(_center.x, _center.y);
attributes.transform3D = CATransform3DMakeScale(0.1, 0.1, 1.0);
Expand Down
2 changes: 1 addition & 1 deletion Examples/CircleLayout/CircleLayout/ViewController.h
Expand Up @@ -94,7 +94,7 @@

#import <UIKit/UIKit.h>

@interface ViewController : PSTCollectionViewController
@interface ViewController : PSUICollectionViewController

@property (nonatomic, assign) NSInteger cellCount;

Expand Down
4 changes: 2 additions & 2 deletions Examples/CircleLayout/CircleLayout/ViewController.m
Expand Up @@ -112,10 +112,10 @@ - (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSI
return self.cellCount;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
- (PSUICollectionViewCell *)collectionView:(PSUICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];
return (UICollectionViewCell *)cell;
return (PSUICollectionViewCell *)cell;
}

- (void)handleTapGesture:(UITapGestureRecognizer *)sender {
Expand Down

0 comments on commit c5594ff

Please sign in to comment.