mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-04-27 17:30:48 +08:00
Remove stack children type:
- ASLayoutable requires mutable properties that are used when attached to a stack layout. - Thus, ASLayoutable objects (including ASDisplayNode) can be injected into stack layout directly. - ASStackLayoutNodeChild no longer needed. - Tests and Kitten sample updated.
This commit is contained in:
@@ -129,6 +129,11 @@ static const CGFloat kInnerPadding = 10.0f;
|
||||
|
||||
- (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
ASRatioLayoutNode *imagePlaceholder = [ASRatioLayoutNode newWithRatio:1.0 child:_imageNode];
|
||||
imagePlaceholder.flexBasis = ASRelativeDimensionMakeWithPoints(kImageSize);
|
||||
|
||||
_textNode.flexShrink = YES;
|
||||
|
||||
id<ASLayoutable> layoutSpec =
|
||||
[ASInsetLayoutNode
|
||||
newWithInsets:UIEdgeInsetsMake(kOuterPadding, kOuterPadding, kOuterPadding, kOuterPadding)
|
||||
@@ -138,17 +143,8 @@ static const CGFloat kInnerPadding = 10.0f;
|
||||
.direction = ASStackLayoutDirectionHorizontal,
|
||||
.spacing = kInnerPadding
|
||||
}
|
||||
children:
|
||||
@[
|
||||
[ASStackLayoutNodeChild newWithInitializer:^(ASMutableStackLayoutNodeChild *mutableCopy) {
|
||||
mutableCopy.node = [ASRatioLayoutNode newWithRatio:1.0 child:_imageNode];
|
||||
mutableCopy.flexBasis = ASRelativeDimensionMakeWithPoints(kImageSize);
|
||||
}],
|
||||
[ASStackLayoutNodeChild newWithInitializer:^(ASMutableStackLayoutNodeChild *mutableCopy) {
|
||||
mutableCopy.node = _textNode;
|
||||
mutableCopy.flexShrink = true;
|
||||
}]
|
||||
]]];
|
||||
children:@[imagePlaceholder, _textNode]]];
|
||||
|
||||
return [layoutSpec calculateLayoutThatFits:constrainedSize];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user