mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
[Examples] Layout 2.0 updates (#2382)
[Examples] Layout 2.0 updates: Switch YES to 1.0 for flexGrow and flexShrink
This commit is contained in:
@@ -78,7 +78,7 @@
|
|||||||
// of the button node to add a touch handler.
|
// of the button node to add a touch handler.
|
||||||
[_titleNode setLayerBacked:YES];
|
[_titleNode setLayerBacked:YES];
|
||||||
#endif
|
#endif
|
||||||
_titleNode.style.flexShrink = 1;
|
_titleNode.style.flexShrink = 1.0;
|
||||||
}
|
}
|
||||||
return _titleNode;
|
return _titleNode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
|||||||
{
|
{
|
||||||
if (_controlFlexGrowSpacerSpec == nil) {
|
if (_controlFlexGrowSpacerSpec == nil) {
|
||||||
_controlFlexGrowSpacerSpec = [[ASStackLayoutSpec alloc] init];
|
_controlFlexGrowSpacerSpec = [[ASStackLayoutSpec alloc] init];
|
||||||
_controlFlexGrowSpacerSpec.style.flexGrow = 1;
|
_controlFlexGrowSpacerSpec.style.flexGrow = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[_cachedControls setObject:_controlFlexGrowSpacerSpec forKey:@(ASVideoPlayerNodeControlTypeFlexGrowSpacer)];
|
[_cachedControls setObject:_controlFlexGrowSpacerSpec forKey:@(ASVideoPlayerNodeControlTypeFlexGrowSpacer)];
|
||||||
@@ -733,7 +733,7 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
|||||||
_scrubberNode.style.preferredSize = CGSizeMake(maxSize.width, 44.0);
|
_scrubberNode.style.preferredSize = CGSizeMake(maxSize.width, 44.0);
|
||||||
|
|
||||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||||
spacer.style.flexGrow = 1;
|
spacer.style.flexGrow = 1.0;
|
||||||
|
|
||||||
ASStackLayoutSpec *controlbarSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
ASStackLayoutSpec *controlbarSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
||||||
spacing:10.0
|
spacing:10.0
|
||||||
|
|||||||
@@ -98,8 +98,8 @@
|
|||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
ASTextNode *nextTextNode = self.enabled ? self.textNodeTwo : self.textNodeOne;
|
ASTextNode *nextTextNode = self.enabled ? self.textNodeTwo : self.textNodeOne;
|
||||||
nextTextNode.style.flexGrow = YES;
|
nextTextNode.style.flexGrow = 1.0;
|
||||||
nextTextNode.style.flexShrink = YES;
|
nextTextNode.style.flexShrink = 1.0;
|
||||||
|
|
||||||
ASStackLayoutSpec *horizontalStackLayout = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
ASStackLayoutSpec *horizontalStackLayout = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||||
horizontalStackLayout.children = @[nextTextNode];
|
horizontalStackLayout.children = @[nextTextNode];
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
_titleNode = [[ASTextNode alloc] init];
|
_titleNode = [[ASTextNode alloc] init];
|
||||||
_titleNode.attributedText = [[NSAttributedString alloc] initWithString:_videoModel.title attributes:[self titleNodeStringOptions]];
|
_titleNode.attributedText = [[NSAttributedString alloc] initWithString:_videoModel.title attributes:[self titleNodeStringOptions]];
|
||||||
_titleNode.style.flexGrow = YES;
|
_titleNode.style.flexGrow = 1.0;
|
||||||
[self addSubnode:_titleNode];
|
[self addSubnode:_titleNode];
|
||||||
|
|
||||||
_avatarNode = [[ASNetworkImageNode alloc] init];
|
_avatarNode = [[ASNetworkImageNode alloc] init];
|
||||||
@@ -184,7 +184,7 @@
|
|||||||
- (ASLayoutSpec*)videoPlayerNodeLayoutSpec:(ASVideoPlayerNode *)videoPlayer forControls:(NSDictionary *)controls forMaximumSize:(CGSize)maxSize
|
- (ASLayoutSpec*)videoPlayerNodeLayoutSpec:(ASVideoPlayerNode *)videoPlayer forControls:(NSDictionary *)controls forMaximumSize:(CGSize)maxSize
|
||||||
{
|
{
|
||||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||||
spacer.style.flexGrow = YES;
|
spacer.style.flexGrow = 1.0;
|
||||||
|
|
||||||
UIEdgeInsets insets = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0);
|
UIEdgeInsets insets = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0);
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@
|
|||||||
scrubber.style.height = ASDimensionMakeWithPoints(44.0);
|
scrubber.style.height = ASDimensionMakeWithPoints(44.0);
|
||||||
scrubber.style.minWidth = ASDimensionMakeWithPoints(0.0);
|
scrubber.style.minWidth = ASDimensionMakeWithPoints(0.0);
|
||||||
scrubber.style.maxWidth = ASDimensionMakeWithPoints(maxSize.width);
|
scrubber.style.maxWidth = ASDimensionMakeWithPoints(maxSize.width);
|
||||||
scrubber.style.flexGrow = YES;
|
scrubber.style.flexGrow = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray *controlBarControls = [self controlsForControlBar:controls];
|
NSArray *controlBarControls = [self controlsForControlBar:controls];
|
||||||
|
|||||||
@@ -176,7 +176,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||||
spacer.flexGrow = YES;
|
spacer.flexGrow = 1.0;
|
||||||
|
|
||||||
ASStackLayoutSpec *topBarSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
ASStackLayoutSpec *topBarSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
||||||
spacing:10.0
|
spacing:10.0
|
||||||
|
|||||||
@@ -113,11 +113,11 @@
|
|||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
// username / photo location header vertical stack
|
// username / photo location header vertical stack
|
||||||
_photoLocationLabel.style.flexShrink = YES;
|
_photoLocationLabel.style.flexShrink = 1.0;
|
||||||
_userNameLabel.style.flexShrink = YES;
|
_userNameLabel.style.flexShrink = 1.0;
|
||||||
|
|
||||||
ASStackLayoutSpec *headerSubStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
ASStackLayoutSpec *headerSubStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||||
headerSubStack.style.flexShrink = YES;
|
headerSubStack.style.flexShrink = 1.0;
|
||||||
if (_photoLocationLabel.attributedText) {
|
if (_photoLocationLabel.attributedText) {
|
||||||
[headerSubStack setChildren:@[_userNameLabel, _photoLocationLabel]];
|
[headerSubStack setChildren:@[_userNameLabel, _photoLocationLabel]];
|
||||||
} else {
|
} else {
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
_photoTimeIntervalSincePostLabel.style.spacingBefore = HORIZONTAL_BUFFER; // to remove double spaces around spacer
|
_photoTimeIntervalSincePostLabel.style.spacingBefore = HORIZONTAL_BUFFER; // to remove double spaces around spacer
|
||||||
|
|
||||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init]; // FIXME: long locations overflow post time - set max size?
|
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init]; // FIXME: long locations overflow post time - set max size?
|
||||||
spacer.style.flexGrow = YES;
|
spacer.style.flexGrow = 1.0;
|
||||||
|
|
||||||
UIEdgeInsets avatarInsets = UIEdgeInsetsMake(HORIZONTAL_BUFFER, 0, HORIZONTAL_BUFFER, HORIZONTAL_BUFFER);
|
UIEdgeInsets avatarInsets = UIEdgeInsetsMake(HORIZONTAL_BUFFER, 0, HORIZONTAL_BUFFER, HORIZONTAL_BUFFER);
|
||||||
ASInsetLayoutSpec *avatarInset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:avatarInsets child:_userAvatarImageView];
|
ASInsetLayoutSpec *avatarInset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:avatarInsets child:_userAvatarImageView];
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
|
|
||||||
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath
|
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
return ASSizeRangeMakeExactSize(CGSizeMake(100, 100));
|
return ASSizeRangeMake(CGSizeMake(100, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -387,8 +387,8 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
// If we just would add the childrent to the stack layout the layout would be to tall and run out of the edge of
|
// If we just would add the childrent to the stack layout the layout would be to tall and run out of the edge of
|
||||||
// the node as 50+50+50 = 150 but the parent node is only 100 height. To prevent that we set flexShrink on 2 of the
|
// the node as 50+50+50 = 150 but the parent node is only 100 height. To prevent that we set flexShrink on 2 of the
|
||||||
// children to let the stack layout know it should shrink these children in case the layout will run over the edge
|
// children to let the stack layout know it should shrink these children in case the layout will run over the edge
|
||||||
childNode2.style.flexShrink = YES;
|
childNode2.style.flexShrink = 1.0;
|
||||||
childNode3.style.flexShrink = YES;
|
childNode3.style.flexShrink = 1.0;
|
||||||
|
|
||||||
parentNode = [self parentNodeWithChild:childNode];
|
parentNode = [self parentNodeWithChild:childNode];
|
||||||
parentNode.entryTitle = @"Vertical ASStackLayoutSpec";
|
parentNode.entryTitle = @"Vertical ASStackLayoutSpec";
|
||||||
@@ -407,7 +407,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
#pragma mark Horizontal ASStackLayoutSpec
|
#pragma mark Horizontal ASStackLayoutSpec
|
||||||
childNode1 = [ASDisplayNode new];
|
childNode1 = [ASDisplayNode new];
|
||||||
childNode1.style.preferredSize = CGSizeMake(10.0, 20.0);
|
childNode1.style.preferredSize = CGSizeMake(10.0, 20.0);
|
||||||
childNode1.style.flexGrow = YES;
|
childNode1.style.flexGrow = 1.0;
|
||||||
childNode1.backgroundColor = [UIColor greenColor];
|
childNode1.backgroundColor = [UIColor greenColor];
|
||||||
|
|
||||||
childNode2 = [ASDisplayNode new];
|
childNode2 = [ASDisplayNode new];
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ const CGFloat kSoldOutGBHeight = 50.0;
|
|||||||
self.titleLabel = [[ASTextNode alloc] init];
|
self.titleLabel = [[ASTextNode alloc] init];
|
||||||
self.titleLabel.maximumNumberOfLines = 2;
|
self.titleLabel.maximumNumberOfLines = 2;
|
||||||
self.titleLabel.style.alignSelf = ASStackLayoutAlignSelfStart;
|
self.titleLabel.style.alignSelf = ASStackLayoutAlignSelfStart;
|
||||||
self.titleLabel.style.flexGrow = YES;
|
self.titleLabel.style.flexGrow = 1.0;
|
||||||
self.titleLabel.layerBacked = YES;
|
self.titleLabel.layerBacked = YES;
|
||||||
|
|
||||||
self.firstInfoLabel = [[ASTextNode alloc] init];
|
self.firstInfoLabel = [[ASTextNode alloc] init];
|
||||||
@@ -110,11 +110,11 @@ const CGFloat kSoldOutGBHeight = 50.0;
|
|||||||
self.soldOutLabelBackground.style.width = ASDimensionMakeWithFraction(1.0);
|
self.soldOutLabelBackground.style.width = ASDimensionMakeWithFraction(1.0);
|
||||||
self.soldOutLabelBackground.style.height = ASDimensionMakeWithPoints(kSoldOutGBHeight);
|
self.soldOutLabelBackground.style.height = ASDimensionMakeWithPoints(kSoldOutGBHeight);
|
||||||
self.soldOutLabelBackground.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.9];
|
self.soldOutLabelBackground.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.9];
|
||||||
self.soldOutLabelBackground.style.flexGrow = YES;
|
self.soldOutLabelBackground.style.flexGrow = 1.0;
|
||||||
self.soldOutLabelBackground.layerBacked = YES;
|
self.soldOutLabelBackground.layerBacked = YES;
|
||||||
|
|
||||||
self.soldOutOverlay = [[ASDisplayNode alloc] init];
|
self.soldOutOverlay = [[ASDisplayNode alloc] init];
|
||||||
self.soldOutOverlay.style.flexGrow = YES;
|
self.soldOutOverlay.style.flexGrow = 1.0;
|
||||||
self.soldOutOverlay.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
|
self.soldOutOverlay.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
|
||||||
self.soldOutOverlay.layerBacked = YES;
|
self.soldOutOverlay.layerBacked = YES;
|
||||||
|
|
||||||
@@ -257,13 +257,13 @@ const CGFloat kSoldOutGBHeight = 50.0;
|
|||||||
UIEdgeInsets textInsets = UIEdgeInsetsMake(kInsetTop, kInsetHorizontal, kInsetBottom, kInsetHorizontal);
|
UIEdgeInsets textInsets = UIEdgeInsetsMake(kInsetTop, kInsetHorizontal, kInsetBottom, kInsetHorizontal);
|
||||||
|
|
||||||
ASLayoutSpec *verticalSpacer = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *verticalSpacer = [[ASLayoutSpec alloc] init];
|
||||||
verticalSpacer.style.flexGrow = YES;
|
verticalSpacer.style.flexGrow = 1.0;
|
||||||
|
|
||||||
ASLayoutSpec *horizontalSpacer1 = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *horizontalSpacer1 = [[ASLayoutSpec alloc] init];
|
||||||
horizontalSpacer1.style.flexGrow = YES;
|
horizontalSpacer1.style.flexGrow = 1.0;
|
||||||
|
|
||||||
ASLayoutSpec *horizontalSpacer2 = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *horizontalSpacer2 = [[ASLayoutSpec alloc] init];
|
||||||
horizontalSpacer2.style.flexGrow = YES;
|
horizontalSpacer2.style.flexGrow = 1.0;
|
||||||
|
|
||||||
NSArray *info1Children = @[self.firstInfoLabel, self.distanceLabel, horizontalSpacer1, self.originalPriceLabel];
|
NSArray *info1Children = @[self.firstInfoLabel, self.distanceLabel, horizontalSpacer1, self.originalPriceLabel];
|
||||||
NSArray *info2Children = @[self.secondInfoLabel, horizontalSpacer2, self.finalPriceLabel];
|
NSArray *info2Children = @[self.secondInfoLabel, horizontalSpacer2, self.finalPriceLabel];
|
||||||
@@ -279,7 +279,7 @@ const CGFloat kSoldOutGBHeight = 50.0;
|
|||||||
ASStackLayoutSpec *textStack = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0.0 justifyContent:ASStackLayoutJustifyContentEnd alignItems:ASStackLayoutAlignItemsStretch children:@[self.titleLabel, verticalSpacer, info1Stack, info2Stack]];
|
ASStackLayoutSpec *textStack = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0.0 justifyContent:ASStackLayoutJustifyContentEnd alignItems:ASStackLayoutAlignItemsStretch children:@[self.titleLabel, verticalSpacer, info1Stack, info2Stack]];
|
||||||
|
|
||||||
ASInsetLayoutSpec *textWrapper = [ASInsetLayoutSpec insetLayoutSpecWithInsets:textInsets child:textStack];
|
ASInsetLayoutSpec *textWrapper = [ASInsetLayoutSpec insetLayoutSpecWithInsets:textInsets child:textStack];
|
||||||
textWrapper.style.flexGrow = YES;
|
textWrapper.style.flexGrow = 1.0;
|
||||||
|
|
||||||
return textWrapper;
|
return textWrapper;
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ const CGFloat kSoldOutGBHeight = 50.0;
|
|||||||
ASAbsoluteLayoutSpec *badgePosition = [ASAbsoluteLayoutSpec absoluteLayoutSpecWithChildren:@[self.badge]];
|
ASAbsoluteLayoutSpec *badgePosition = [ASAbsoluteLayoutSpec absoluteLayoutSpecWithChildren:@[self.badge]];
|
||||||
|
|
||||||
ASOverlayLayoutSpec *badgeOverImage = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:imagePlace overlay:badgePosition];
|
ASOverlayLayoutSpec *badgeOverImage = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:imagePlace overlay:badgePosition];
|
||||||
badgeOverImage.style.flexGrow = YES;
|
badgeOverImage.style.flexGrow = 1.0;
|
||||||
|
|
||||||
return badgeOverImage;
|
return badgeOverImage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ static const CGFloat kInnerPadding = 10.0f;
|
|||||||
_imageNode.style.preferredSize = imageSize;
|
_imageNode.style.preferredSize = imageSize;
|
||||||
|
|
||||||
// Shrink the text node in case the image + text gonna be too wide
|
// Shrink the text node in case the image + text gonna be too wide
|
||||||
_textNode.style.flexShrink = YES;
|
_textNode.style.flexShrink = 1.0;
|
||||||
|
|
||||||
// Configure stack
|
// Configure stack
|
||||||
ASStackLayoutSpec *stackLayoutSpec =
|
ASStackLayoutSpec *stackLayoutSpec =
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
// Username node
|
// Username node
|
||||||
_usernameNode = [[ASTextNode alloc] init];
|
_usernameNode = [[ASTextNode alloc] init];
|
||||||
_usernameNode.attributedText = [[NSAttributedString alloc] initWithString:_post.username attributes:[TextStyles usernameStyle]];
|
_usernameNode.attributedText = [[NSAttributedString alloc] initWithString:_post.username attributes:[TextStyles usernameStyle]];
|
||||||
_usernameNode.style.flexShrink = YES; //if name and username don't fit to cell width, allow username shrink
|
_usernameNode.style.flexShrink = 1.0; //if name and username don't fit to cell width, allow username shrink
|
||||||
_usernameNode.truncationMode = NSLineBreakByTruncatingTail;
|
_usernameNode.truncationMode = NSLineBreakByTruncatingTail;
|
||||||
_usernameNode.maximumNumberOfLines = 1;
|
_usernameNode.maximumNumberOfLines = 1;
|
||||||
[self addSubnode:_usernameNode];
|
[self addSubnode:_usernameNode];
|
||||||
@@ -210,11 +210,11 @@
|
|||||||
{
|
{
|
||||||
// Flexible spacer between username and time
|
// Flexible spacer between username and time
|
||||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||||
spacer.style.flexGrow = YES;
|
spacer.style.flexGrow = 1.0;
|
||||||
|
|
||||||
// NOTE: This inset is not actually required by the layout, but is an example of the upward propogation of layoutable
|
// NOTE: This inset is not actually required by the layout, but is an example of the upward propogation of layoutable
|
||||||
// properties. Specifically, .flexGrow from the child is transferred to the inset spec so they can expand together.
|
// properties. Specifically, .flexGrow from the child is transferred to the inset spec so they can expand together.
|
||||||
// Without this capability, it would be required to set insetSpacer.flexGrow = YES;
|
// Without this capability, it would be required to set insetSpacer.flexGrow = 1.0;
|
||||||
ASInsetLayoutSpec *insetSpacer =
|
ASInsetLayoutSpec *insetSpacer =
|
||||||
[ASInsetLayoutSpec
|
[ASInsetLayoutSpec
|
||||||
insetLayoutSpecWithInsets:UIEdgeInsetsMake(0, 0, 0, 0)
|
insetLayoutSpecWithInsets:UIEdgeInsetsMake(0, 0, 0, 0)
|
||||||
@@ -279,7 +279,7 @@
|
|||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsStretch
|
alignItems:ASStackLayoutAlignItemsStretch
|
||||||
children:mainStackContent];
|
children:mainStackContent];
|
||||||
contentSpec.style.flexShrink = YES;
|
contentSpec.style.flexShrink = 1.0;
|
||||||
|
|
||||||
// Horizontal spec for avatar
|
// Horizontal spec for avatar
|
||||||
ASStackLayoutSpec *avatarContentSpec =
|
ASStackLayoutSpec *avatarContentSpec =
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ static const CGFloat kInnerPadding = 10.0f;
|
|||||||
_textNode = [[ASTextNode alloc] init];
|
_textNode = [[ASTextNode alloc] init];
|
||||||
_textNode.attributedText = [[NSAttributedString alloc] initWithString:[self kittyIpsum]
|
_textNode.attributedText = [[NSAttributedString alloc] initWithString:[self kittyIpsum]
|
||||||
attributes:[self textStyle]];
|
attributes:[self textStyle]];
|
||||||
_textNode.style.flexShrink = YES;
|
_textNode.style.flexShrink = 1.0;
|
||||||
_textNode.style.flexGrow = YES;
|
_textNode.style.flexGrow = 1.0;
|
||||||
[self addSubnode:_textNode];
|
[self addSubnode:_textNode];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ static NSString *kLinkAttributeName = @"PlaceKittenNodeLinkAttributeName";
|
|||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
_textNode = [[ASTextNode alloc] init];
|
_textNode = [[ASTextNode alloc] init];
|
||||||
_textNode.style.flexGrow = YES;
|
_textNode.style.flexGrow = 1.0;
|
||||||
_textNode.style.flexShrink = YES;
|
_textNode.style.flexShrink = 1.0;
|
||||||
_textNode.maximumNumberOfLines = 3;
|
_textNode.maximumNumberOfLines = 3;
|
||||||
[self addSubnode:_textNode];
|
[self addSubnode:_textNode];
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ final class DemoCellNode: ASCellNode {
|
|||||||
override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {
|
override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {
|
||||||
let specA = ASRatioLayoutSpec(ratio: 1, child: childA)
|
let specA = ASRatioLayoutSpec(ratio: 1, child: childA)
|
||||||
specA.style.flexBasis = ASDimensionMakeWithPoints(1)
|
specA.style.flexBasis = ASDimensionMakeWithPoints(1)
|
||||||
specA.style.flexGrow = 1
|
specA.style.flexGrow = 1.0
|
||||||
let specB = ASRatioLayoutSpec(ratio: 1, child: childB)
|
let specB = ASRatioLayoutSpec(ratio: 1, child: childB)
|
||||||
specB.style.flexBasis = ASDimensionMakeWithPoints(1)
|
specB.style.flexBasis = ASDimensionMakeWithPoints(1)
|
||||||
specB.style.flexGrow = 1
|
specB.style.flexGrow = 1.0
|
||||||
let children = state.isReverse ? [ specB, specA ] : [ specA, specB ]
|
let children = state.isReverse ? [ specB, specA ] : [ specA, specB ]
|
||||||
let direction: ASStackLayoutDirection = state.isVertical ? .Vertical : .Horizontal
|
let direction: ASStackLayoutDirection = state.isVertical ? .Vertical : .Horizontal
|
||||||
return ASStackLayoutSpec(direction: direction,
|
return ASStackLayoutSpec(direction: direction,
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ static const CGFloat kInnerPadding = 10.0f;
|
|||||||
CGSize imageSize = _isImageEnlarged ? CGSizeMake(2.0 * kImageSize, 2.0 * kImageSize)
|
CGSize imageSize = _isImageEnlarged ? CGSizeMake(2.0 * kImageSize, 2.0 * kImageSize)
|
||||||
: CGSizeMake(kImageSize, kImageSize);
|
: CGSizeMake(kImageSize, kImageSize);
|
||||||
_imageNode.size = ASRelativeSizeRangeMakeWithExactCGSize(imageSize);
|
_imageNode.size = ASRelativeSizeRangeMakeWithExactCGSize(imageSize);
|
||||||
_textNode.flexShrink = YES;
|
_textNode.flexShrink = 1.0;
|
||||||
|
|
||||||
ASStackLayoutSpec *stackSpec = [[ASStackLayoutSpec alloc] init];
|
ASStackLayoutSpec *stackSpec = [[ASStackLayoutSpec alloc] init];
|
||||||
stackSpec.direction = ASStackLayoutDirectionHorizontal;
|
stackSpec.direction = ASStackLayoutDirectionHorizontal;
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ static const CGFloat kInnerPadding = 10.0f;
|
|||||||
CGSize videoNodeSize = _isImageEnlarged ? CGSizeMake(2.0 * kImageSize, 2.0 * kImageSize)
|
CGSize videoNodeSize = _isImageEnlarged ? CGSizeMake(2.0 * kImageSize, 2.0 * kImageSize)
|
||||||
: CGSizeMake(kImageSize, kImageSize);
|
: CGSizeMake(kImageSize, kImageSize);
|
||||||
_videoNode.size = ASRelativeSizeRangeMakeWithExactCGSize(videoNodeSize);
|
_videoNode.size = ASRelativeSizeRangeMakeWithExactCGSize(videoNodeSize);
|
||||||
_textNode.flexShrink = YES;
|
_textNode.flexShrink = 1.0;
|
||||||
|
|
||||||
ASStackLayoutSpec *stackSpec = [[ASStackLayoutSpec alloc] init];
|
ASStackLayoutSpec *stackSpec = [[ASStackLayoutSpec alloc] init];
|
||||||
stackSpec.direction = ASStackLayoutDirectionHorizontal;
|
stackSpec.direction = ASStackLayoutDirectionHorizontal;
|
||||||
|
|||||||
Reference in New Issue
Block a user