mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Add node as parameter in ASLayoutSpecBlock
This commit is contained in:
@@ -45,7 +45,7 @@ typedef void (^ASDisplayNodeContextModifier)(_Nonnull CGContextRef context);
|
||||
/**
|
||||
* ASDisplayNode layout spec block. This block can be used instead of implementing layoutSpecThatFits: in subclass
|
||||
*/
|
||||
typedef ASLayoutSpec * _Nonnull(^ASLayoutSpecBlock)(ASSizeRange constrainedSize);
|
||||
typedef ASLayoutSpec * _Nonnull(^ASLayoutSpecBlock)(ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize);
|
||||
|
||||
/**
|
||||
Interface state is available on ASDisplayNode and ASViewController, and
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
ASDisplayNode *node5 = [[ASDisplayNode alloc] init];
|
||||
|
||||
ASSpecTestDisplayNode *node = [[ASSpecTestDisplayNode alloc] init];
|
||||
node.layoutSpecBlock = ^(ASSizeRange constrainedSize) {
|
||||
node.layoutSpecBlock = ^(ASDisplayNode *weakNode, ASSizeRange constrainedSize) {
|
||||
ASStaticLayoutSpec *staticLayout = [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[node4]];
|
||||
|
||||
ASStackLayoutSpec *stack1 = [[ASStackLayoutSpec alloc] init];
|
||||
@@ -102,9 +102,9 @@
|
||||
ASDisplayNode *node3 = [[ASDisplayNode alloc] init];
|
||||
|
||||
ASSpecTestDisplayNode *node = [[ASSpecTestDisplayNode alloc] init];
|
||||
__weak ASSpecTestDisplayNode *weakNode = node;
|
||||
node.layoutSpecBlock = ^(ASSizeRange constrainedSize){
|
||||
if ([weakNode.layoutState isEqualToNumber:@1]) {
|
||||
node.layoutSpecBlock = ^(ASDisplayNode *weakNode, ASSizeRange constrainedSize){
|
||||
ASSpecTestDisplayNode *strongNode = (ASSpecTestDisplayNode *)weakNode;
|
||||
if ([strongNode.layoutState isEqualToNumber:@1]) {
|
||||
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[node1, node2]];
|
||||
} else {
|
||||
ASStackLayoutSpec *stackLayout = [[ASStackLayoutSpec alloc] init];
|
||||
|
||||
Reference in New Issue
Block a user