Skip to content

Commit

Permalink
Wrap supplementary node blocks to enable resizing them. (TextureGroup…
Browse files Browse the repository at this point in the history
…#1265)

* Wrap supplementary node blocks to enable resizing them.

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.

* Simplify code / block will never be nil
  • Loading branch information
wiseoldduck authored and wsdwsd0829 committed Mar 15, 2019
1 parent fbe6f21 commit 26326d6
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 @@ -2049,7 +2049,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();
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 26326d6

Please sign in to comment.