Skip to content

Commit

Permalink
Wrap supplementary node blocks to enable resizing them.
Browse files Browse the repository at this point in the history
Most ASCellNodeBlocks are wrapped by ASCollectionView.mm to add an `interactionDelegate` as well as calling `enterHierarchyState` on the node and setting its transform to a reflection if `inverted` is set on the collectionView.

This PR adds this behavior to supplementary nodes as well.
  • Loading branch information
wiseoldduck authored and wiseoldduck committed Dec 7, 2018
1 parent fb844c3 commit 58edce9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,22 @@ - (ASCellNodeBlock)dataController:(ASDataController *)dataController supplementa
block = ^{ return cell; };
}

return block;
// Wrap the node block
__weak __typeof__(self) weakSelf = self;
return ^{
__typeof__(self) strongSelf = weakSelf;
ASCellNode *node = (block ? block() : cell);
ASDisplayNodeAssert([node isKindOfClass:[ASCellNode class]],
@"ASCollectionNode provided a non-ASCellNode! %@, %@", node, strongSelf);

if (node.interactionDelegate == nil) {
node.interactionDelegate = strongSelf;
}
if (strongSelf.inverted) {
node.transform = CATransform3DMakeScale(1, -1, 1);
}
return node;
};
}

- (NSArray<NSString *> *)dataController:(ASDataController *)dataController supplementaryNodeKindsInSections:(NSIndexSet *)sections
Expand Down

0 comments on commit 58edce9

Please sign in to comment.