Merge pull request #745 from vitalybaev/ASCellNodeSelectedHighlighted

ASCellNode selected/highlighted properties
This commit is contained in:
appleguy
2015-10-15 11:09:36 -07:00
3 changed files with 46 additions and 3 deletions

View File

@@ -43,6 +43,16 @@
//@property (atomic, retain) UIColor *backgroundColor;
@property (nonatomic) UITableViewCellSelectionStyle selectionStyle;
/*
* A Boolean value that indicates whether the node is selected.
*/
@property (nonatomic, assign) BOOL selected;
/*
* A Boolean value that indicates whether the node is highlighted.
*/
@property (nonatomic, assign) BOOL highlighted;
/*
* ASCellNode must forward touch events in order for UITableView and UICollectionView tap handling to work. Overriding
* these methods (e.g. for highlighting) requires the super method be called.

View File

@@ -106,6 +106,28 @@ static BOOL _isInterceptedSelector(SEL sel)
@end
#pragma mark -
#pragma mark ASCellNode<->UICollectionViewCell bridging.
@class _ASCollectionViewCell;
@interface _ASCollectionViewCell : UICollectionViewCell
@property (nonatomic, weak) ASCellNode *node;
@end
@implementation _ASCollectionViewCell
- (void)setSelected:(BOOL)selected
{
_node.selected = selected;
}
- (void)setHighlighted:(BOOL)highlighted
{
_node.highlighted = highlighted;
}
@end
#pragma mark -
#pragma mark ASCollectionView.
@@ -204,7 +226,7 @@ static BOOL _isInterceptedSelector(SEL sel)
self.backgroundColor = [UIColor whiteColor];
[self registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"_ASCollectionViewCell"];
[self registerClass:[_ASCollectionViewCell class] forCellWithReuseIdentifier:@"_ASCollectionViewCell"];
return self;
}
@@ -412,12 +434,13 @@ static BOOL _isInterceptedSelector(SEL sel)
{
static NSString *reuseIdentifier = @"_ASCollectionViewCell";
UICollectionViewCell *cell = [self dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
_ASCollectionViewCell *cell = [self dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
ASCellNode *node = [_dataController nodeAtIndexPath:indexPath];
[_rangeController configureContentView:cell.contentView forCellNode:node];
cell.node = node;
return cell;
}

View File

@@ -135,6 +135,16 @@ static BOOL _isInterceptedSelector(SEL sel)
[super didTransitionToState:state];
}
- (void)setSelected:(BOOL)selected
{
_node.selected = selected;
}
- (void)setHighlighted:(BOOL)highlighted
{
_node.highlighted = highlighted;
}
@end