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:
Huy Nguyen
2015-06-26 11:38:29 +07:00
parent f588bceb4d
commit 95e787b226
14 changed files with 252 additions and 503 deletions

View File

@@ -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];
}