Skip to content

Commit ec22463

Browse files
committed
- Added highlightedCellDirection in custom layout attributes
- Little refactoring
1 parent 3b17c02 commit ec22463

4 files changed

Lines changed: 15 additions & 9 deletions

File tree

RAMCollectionViewFlemishBondLayout/RAMCollectionViewFlemishBondLayout.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@
2727
//
2828

2929
#import <UIKit/UIKit.h>
30+
#import "RAMCollectionViewFlemishBondLayoutAttributes.h"
3031

3132
FOUNDATION_EXPORT NSString *const RAMCollectionViewFlemishBondHeaderKind;
3233
FOUNDATION_EXPORT NSString *const RAMCollectionViewFlemishBondFooterKind;
3334

34-
typedef NS_ENUM(NSUInteger, RAMCollectionViewFlemishBondLayoutGroupDirection) {
35-
RAMCollectionViewFlemishBondLayoutGroupDirectionLeft,
36-
RAMCollectionViewFlemishBondLayoutGroupDirectionRight
37-
};
38-
3935
@class RAMCollectionViewFlemishBondLayout;
4036

4137
@protocol RAMCollectionViewFlemishBondLayoutDelegate <NSObject>

RAMCollectionViewFlemishBondLayout/RAMCollectionViewFlemishBondLayout.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
//
2828

2929
#import "RAMCollectionViewFlemishBondLayout.h"
30-
#import "RAMCollectionViewFlemishBondLayoutAttributes.h"
3130

3231
static NSString *const RAMCollectionViewFlemishBondCellKind = @"RAMCollectionViewFlemishBondCellKind";
3332
NSString *const RAMCollectionViewFlemishBondHeaderKind = @"RAMCollectionViewFlemishBondHeaderKind";
@@ -64,7 +63,7 @@ - (id)init
6463

6564
- (id)initWithCoder:(NSCoder *)aDecoder
6665
{
67-
self = [super init];
66+
self = [super initWithCoder:aDecoder];
6867
if (self) {
6968
[self setup];
7069
}
@@ -178,7 +177,8 @@ - (void)prepareLayout
178177

179178
RAMCollectionViewFlemishBondLayoutAttributes *layoutAttributes = [RAMCollectionViewFlemishBondLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
180179
layoutAttributes.frame = [self frameForCellAtIndexPath:indexPath];
181-
layoutAttributes.highlightedCell = [self isHighLightedElementAtIndexPath:indexPath] ? YES : NO;
180+
layoutAttributes.highlightedCell = [self isHighLightedElementAtIndexPath:indexPath];
181+
layoutAttributes.highlightedCellDirection = self.highlightedCellDirection;
182182

183183
cellLayoutDictionary[indexPath] = layoutAttributes;
184184
}

RAMCollectionViewFlemishBondLayout/RAMCollectionViewFlemishBondLayoutAttributes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@
2828

2929
#import <UIKit/UIKit.h>
3030

31+
typedef NS_ENUM(NSUInteger, RAMCollectionViewFlemishBondLayoutGroupDirection) {
32+
RAMCollectionViewFlemishBondLayoutGroupDirectionLeft,
33+
RAMCollectionViewFlemishBondLayoutGroupDirectionRight
34+
};
35+
3136
@interface RAMCollectionViewFlemishBondLayoutAttributes : UICollectionViewLayoutAttributes
3237

3338
@property (nonatomic, assign, getter = isHighlightedCell) BOOL highlightedCell;
39+
@property (nonatomic, assign) RAMCollectionViewFlemishBondLayoutGroupDirection highlightedCellDirection;
3440

3541
@end

RAMCollectionViewFlemishBondLayout/RAMCollectionViewFlemishBondLayoutAttributes.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ - (id)copyWithZone:(NSZone *)zone
3434
{
3535
RAMCollectionViewFlemishBondLayoutAttributes *attributes = [super copyWithZone:zone];
3636
attributes.highlightedCell = self.highlightedCell;
37+
attributes.highlightedCellDirection = self.highlightedCellDirection;
3738

3839
return attributes;
3940
}
4041

4142
- (NSString *)debugDescription
4243
{
43-
return [self.description stringByAppendingFormat:@"highlighted cell: %@", [self isHighlightedCell] ? @"Yes" : @"No"];
44+
NSString *highlightedCellString = [NSString stringWithFormat:@"Highlighted cell: %@; ", [self isHighlightedCell] ? @"Yes" : @"No"];
45+
NSString *highlightedCellDirectionString = [NSString stringWithFormat:@"Highlighted cell direction: %@; ", (self.highlightedCellDirection == RAMCollectionViewFlemishBondLayoutGroupDirectionLeft) ? @"Left" : @"Right"];
46+
47+
return [self.description stringByAppendingFormat:@"%@%@", highlightedCellString, highlightedCellDirectionString];
4448
}
4549

4650
@end

0 commit comments

Comments
 (0)