From 8557d65104cbd77678f3ca4919e68d7a05f3a2a8 Mon Sep 17 00:00:00 2001 From: Vitaly Baev Date: Thu, 15 Oct 2015 13:25:12 +0300 Subject: [PATCH 1/3] ASCellNode selected/highlighted properties --- AsyncDisplayKit/ASCellNode.h | 10 ++++++++++ AsyncDisplayKit/ASTableView.mm | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/AsyncDisplayKit/ASCellNode.h b/AsyncDisplayKit/ASCellNode.h index ae061eb6ca..c8523125ad 100644 --- a/AsyncDisplayKit/ASCellNode.h +++ b/AsyncDisplayKit/ASCellNode.h @@ -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. diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index 7c36c775a6..a232007c3e 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -135,6 +135,15 @@ static BOOL _isInterceptedSelector(SEL sel) [super didTransitionToState:state]; } +- (void)setSelected:(BOOL)selected +{ + _node.selected = selected; +} + +- (void)setHighlighted:(BOOL)highlighted { + _node.highlighted = highlighted; +} + @end From 03542c5436fbe8cc548e5834e33bc8f1b6932ed8 Mon Sep 17 00:00:00 2001 From: Vitaly Baev Date: Thu, 15 Oct 2015 20:01:55 +0300 Subject: [PATCH 2/3] Bump the bracket down --- AsyncDisplayKit/ASTableView.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index a232007c3e..20c058d658 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -140,7 +140,8 @@ static BOOL _isInterceptedSelector(SEL sel) _node.selected = selected; } -- (void)setHighlighted:(BOOL)highlighted { +- (void)setHighlighted:(BOOL)highlighted +{ _node.highlighted = highlighted; } From 1a78cd2e66361750bd67dd64a756d224ded8fa42 Mon Sep 17 00:00:00 2001 From: Vitaly Baev Date: Thu, 15 Oct 2015 20:27:42 +0300 Subject: [PATCH 3/3] ASCellNode selected/highlighted properties in ASCollectionView --- AsyncDisplayKit/ASCollectionView.mm | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index b1b29335b3..3c1cc4dc18 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -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; }