From b18e1bc071f17df264278bae610f035486d5a30c Mon Sep 17 00:00:00 2001 From: Hannah Troisi Date: Fri, 23 Sep 2016 16:24:21 -0700 Subject: [PATCH] Fix example projects to use Layout API 2.0 style object (#2285) * fix examples/ASDKLayoutTransition * fix examples/ASMapNode to use new Layout API 2.0 * fix examples/SocialAppLayout to use Layout API 2.0 * fix CatDealsCollectionView to use Layout API 2.0 * fix examples/AsyncDisplayKitOverview to use Layout API 2.0 * Kittens Layout API 2.0 fixes * HorizontalWithinVerticalScrolling * VerticalWithinHorizontalScrolling * ASDKTube * fix ASViewController * fix layout * fix layout * fix size --- .../Sample/ViewController.m | 6 +-- .../ASDKTube/Sample/Nodes/VideoContentCell.m | 32 ++++++------- examples/ASMapNode/Sample/MapHandlerNode.m | 30 ++++++------ .../ASViewController/Sample/DetailCellNode.m | 2 +- .../ASViewController/Sample/DetailRootNode.m | 2 +- .../OverviewASCollectionNode.m | 4 +- .../Node Containers/OverviewASPagerNode.m | 4 +- .../Node Containers/OverviewASTableNode.m | 4 +- .../Sample/OverviewComponentsViewController.m | 34 ++++++------- .../CatDealsCollectionView/Sample/ItemNode.m | 48 +++++++++---------- .../Sample/LoadingNode.m | 4 +- .../Sample/HorizontalScrollCellNode.mm | 4 +- examples/Kittens/Sample/KittenNode.mm | 4 +- .../SocialAppLayout/Sample/CommentsNode.m | 4 +- examples/SocialAppLayout/Sample/LikesNode.m | 4 +- examples/SocialAppLayout/Sample/PostNode.m | 20 ++++---- .../Sample/GradientTableNode.mm | 2 +- .../Sample/ViewController.m | 2 +- 18 files changed, 105 insertions(+), 105 deletions(-) diff --git a/examples/ASDKLayoutTransition/Sample/ViewController.m b/examples/ASDKLayoutTransition/Sample/ViewController.m index 8b7465067e..e3addd46cb 100644 --- a/examples/ASDKLayoutTransition/Sample/ViewController.m +++ b/examples/ASDKLayoutTransition/Sample/ViewController.m @@ -98,13 +98,13 @@ - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { ASTextNode *nextTextNode = self.enabled ? self.textNodeTwo : self.textNodeOne; - nextTextNode.flexGrow = YES; - nextTextNode.flexShrink = YES; + nextTextNode.style.flexGrow = YES; + nextTextNode.style.flexShrink = YES; ASStackLayoutSpec *horizontalStackLayout = [ASStackLayoutSpec horizontalStackLayoutSpec]; horizontalStackLayout.children = @[nextTextNode]; - self.buttonNode.alignSelf = ASStackLayoutAlignSelfCenter; + self.buttonNode.style.alignSelf = ASStackLayoutAlignSelfCenter; ASStackLayoutSpec *verticalStackLayout = [ASStackLayoutSpec verticalStackLayoutSpec]; verticalStackLayout.spacing = 10.0; diff --git a/examples/ASDKTube/Sample/Nodes/VideoContentCell.m b/examples/ASDKTube/Sample/Nodes/VideoContentCell.m index 3850275a95..3459c9a391 100644 --- a/examples/ASDKTube/Sample/Nodes/VideoContentCell.m +++ b/examples/ASDKTube/Sample/Nodes/VideoContentCell.m @@ -47,7 +47,7 @@ _titleNode = [[ASTextNode alloc] init]; _titleNode.attributedText = [[NSAttributedString alloc] initWithString:_videoModel.title attributes:[self titleNodeStringOptions]]; - _titleNode.flexGrow = YES; + _titleNode.style.flexGrow = YES; [self addSubnode:_titleNode]; _avatarNode = [[ASNetworkImageNode alloc] init]; @@ -65,8 +65,8 @@ [self addSubnode:_likeButtonNode]; _muteButtonNode = [[ASButtonNode alloc] init]; - _muteButtonNode.width = ASDimensionMakeWithPoints(16.0); - _muteButtonNode.height = ASDimensionMakeWithPoints(22.0); + _muteButtonNode.style.width = ASDimensionMakeWithPoints(16.0); + _muteButtonNode.style.height = ASDimensionMakeWithPoints(22.0); [_muteButtonNode addTarget:self action:@selector(didTapMuteButton) forControlEvents:ASControlNodeEventTouchUpInside]; _videoPlayerNode = [[ASVideoPlayerNode alloc] initWithUrl:_videoModel.url loadAssetWhenNodeBecomesVisible:YES]; @@ -91,14 +91,14 @@ { CGFloat fullWidth = [UIScreen mainScreen].bounds.size.width; - _videoPlayerNode.width = ASDimensionMakeWithPoints(fullWidth); - _videoPlayerNode.height = ASDimensionMakeWithPoints(fullWidth * 9 / 16); + _videoPlayerNode.style.width = ASDimensionMakeWithPoints(fullWidth); + _videoPlayerNode.style.height = ASDimensionMakeWithPoints(fullWidth * 9 / 16); - _avatarNode.width = ASDimensionMakeWithPoints(AVATAR_IMAGE_HEIGHT); - _avatarNode.height = ASDimensionMakeWithPoints(AVATAR_IMAGE_HEIGHT); + _avatarNode.style.width = ASDimensionMakeWithPoints(AVATAR_IMAGE_HEIGHT); + _avatarNode.style.height = ASDimensionMakeWithPoints(AVATAR_IMAGE_HEIGHT); - _likeButtonNode.width = ASDimensionMakeWithPoints(50.0); - _likeButtonNode.height = ASDimensionMakeWithPoints(26.0); + _likeButtonNode.style.width = ASDimensionMakeWithPoints(50.0); + _likeButtonNode.style.height = ASDimensionMakeWithPoints(26.0); ASStackLayoutSpec *headerStack = [ASStackLayoutSpec horizontalStackLayoutSpec]; headerStack.spacing = HORIZONTAL_BUFFER; @@ -184,16 +184,16 @@ - (ASLayoutSpec*)videoPlayerNodeLayoutSpec:(ASVideoPlayerNode *)videoPlayer forControls:(NSDictionary *)controls forMaximumSize:(CGSize)maxSize { ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init]; - spacer.flexGrow = YES; + spacer.style.flexGrow = YES; UIEdgeInsets insets = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0); if (controls[ @(ASVideoPlayerNodeControlTypeScrubber) ]) { ASDisplayNode *scrubber = controls[ @(ASVideoPlayerNodeControlTypeScrubber) ]; - scrubber.height = ASDimensionMakeWithPoints(44.0); - scrubber.minWidth = ASDimensionMakeWithPoints(0.0); - scrubber.maxWidth = ASDimensionMakeWithPoints(maxSize.width); - scrubber.flexGrow = YES; + scrubber.style.height = ASDimensionMakeWithPoints(44.0); + scrubber.style.minWidth = ASDimensionMakeWithPoints(0.0); + scrubber.style.maxWidth = ASDimensionMakeWithPoints(maxSize.width); + scrubber.style.flexGrow = YES; } NSArray *controlBarControls = [self controlsForControlBar:controls]; @@ -218,13 +218,13 @@ justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsCenter children: controlBarControls ]; - controlbarSpec.alignSelf = ASStackLayoutAlignSelfStretch; + controlbarSpec.style.alignSelf = ASStackLayoutAlignSelfStretch; ASInsetLayoutSpec *controlbarInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:controlbarSpec]; - controlbarInsetSpec.alignSelf = ASStackLayoutAlignSelfStretch; + controlbarInsetSpec.style.alignSelf = ASStackLayoutAlignSelfStretch; ASStackLayoutSpec *mainVerticalStack = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0.0 diff --git a/examples/ASMapNode/Sample/MapHandlerNode.m b/examples/ASMapNode/Sample/MapHandlerNode.m index 593f5ff231..45c871bb49 100644 --- a/examples/ASMapNode/Sample/MapHandlerNode.m +++ b/examples/ASMapNode/Sample/MapHandlerNode.m @@ -117,20 +117,20 @@ #define HEIGHT 30 CGSize nodeSize = CGSizeMake(constrainedSize.max.width * 0.3, HEIGHT); - [_latEditableNode setSizeWithCGSize:nodeSize]; - [_lonEditableNode setSizeWithCGSize:nodeSize]; + [_latEditableNode.style setSizeWithCGSize:nodeSize]; + [_lonEditableNode.style setSizeWithCGSize:nodeSize]; - [_deltaLatEditableNode setSizeWithCGSize:nodeSize]; - [_deltaLonEditableNode setSizeWithCGSize:nodeSize]; + [_deltaLatEditableNode.style setSizeWithCGSize:nodeSize]; + [_deltaLonEditableNode.style setSizeWithCGSize:nodeSize]; - [_updateRegionButton setSizeWithCGSize:nodeSize]; - [_liveMapToggleButton setSizeWithCGSize:nodeSize]; + [_updateRegionButton.style setSizeWithCGSize:nodeSize]; + [_liveMapToggleButton.style setSizeWithCGSize:nodeSize]; - _latEditableNode.flexGrow = _lonEditableNode.flexGrow = YES; - _deltaLatEditableNode.flexGrow = _deltaLonEditableNode.flexGrow = YES; - _updateRegionButton.flexGrow = _liveMapToggleButton.flexGrow = YES; + _latEditableNode.style.flexGrow = _lonEditableNode.style.flexGrow = YES; + _deltaLatEditableNode.style.flexGrow = _deltaLonEditableNode.style.flexGrow = YES; + _updateRegionButton.style.flexGrow = _liveMapToggleButton.style.flexGrow = YES; - _mapNode.flexGrow = YES; + _mapNode.style.flexGrow = YES; ASStackLayoutSpec *lonlatSpec = [ASStackLayoutSpec @@ -139,7 +139,7 @@ justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsCenter children:@[_latEditableNode, _lonEditableNode]]; - lonlatSpec.flexGrow = true; + lonlatSpec.style.flexGrow = true; ASStackLayoutSpec *deltaLonlatSpec = [ASStackLayoutSpec @@ -148,7 +148,7 @@ justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsCenter children:@[_deltaLatEditableNode, _deltaLonEditableNode]]; - deltaLonlatSpec.flexGrow = true; + deltaLonlatSpec.style.flexGrow = true; ASStackLayoutSpec *lonlatConfigSpec = [ASStackLayoutSpec @@ -157,7 +157,7 @@ justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStretch children:@[lonlatSpec, deltaLonlatSpec]]; - lonlatConfigSpec.flexGrow = true; + lonlatConfigSpec.style.flexGrow = true; ASStackLayoutSpec *buttonsSpec = [ASStackLayoutSpec @@ -166,7 +166,7 @@ justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStretch children:@[_updateRegionButton, _liveMapToggleButton]]; - buttonsSpec.flexGrow = true; + buttonsSpec.style.flexGrow = true; ASStackLayoutSpec *dashboardSpec = [ASStackLayoutSpec @@ -175,7 +175,7 @@ justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStretch children:@[lonlatConfigSpec, buttonsSpec]]; - dashboardSpec.flexGrow = true; + dashboardSpec.style.flexGrow = true; ASInsetLayoutSpec *insetSpec = [ASInsetLayoutSpec diff --git a/examples/ASViewController/Sample/DetailCellNode.m b/examples/ASViewController/Sample/DetailCellNode.m index c8448557a0..27705cdc8f 100644 --- a/examples/ASViewController/Sample/DetailCellNode.m +++ b/examples/ASViewController/Sample/DetailCellNode.m @@ -39,7 +39,7 @@ - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { self.imageNode.position = CGPointZero; - [self.imageNode setSizeWithCGSize:constrainedSize.max]; + [self.imageNode.style setSizeWithCGSize:constrainedSize.max]; return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[self.imageNode]]; } diff --git a/examples/ASViewController/Sample/DetailRootNode.m b/examples/ASViewController/Sample/DetailRootNode.m index 426797048d..ad907986db 100644 --- a/examples/ASViewController/Sample/DetailRootNode.m +++ b/examples/ASViewController/Sample/DetailRootNode.m @@ -63,7 +63,7 @@ static const NSInteger kImageHeight = 200; - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { self.collectionNode.position = CGPointZero; - [self.collectionNode setSizeWithCGSize:constrainedSize.max]; + [self.collectionNode.style setSizeWithCGSize:constrainedSize.max]; return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[self.collectionNode]]; } diff --git a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASCollectionNode.m b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASCollectionNode.m index 42d3b9a08b..b18b0bc3be 100644 --- a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASCollectionNode.m +++ b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASCollectionNode.m @@ -46,8 +46,8 @@ - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { // 100% of container - _node.width = ASDimensionMakeWithFraction(1.0); - _node.height = ASDimensionMakeWithFraction(1.0); + _node.style.width = ASDimensionMakeWithFraction(1.0); + _node.style.height = ASDimensionMakeWithFraction(1.0); return [ASWrapperLayoutSpec wrapperWithLayoutable:_node]; } diff --git a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASPagerNode.m b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASPagerNode.m index 7b06ef543b..3c3e9e52e8 100644 --- a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASPagerNode.m +++ b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASPagerNode.m @@ -68,8 +68,8 @@ static UIColor *OverViewASPagerNodeRandomColor() { - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { // 100% of container - _node.width = ASDimensionMakeWithFraction(1.0); - _node.height = ASDimensionMakeWithFraction(1.0); + _node.style.width = ASDimensionMakeWithFraction(1.0); + _node.style.height = ASDimensionMakeWithFraction(1.0); return [ASWrapperLayoutSpec wrapperWithLayoutable:_node]; } diff --git a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASTableNode.m b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASTableNode.m index 25cd559dc7..fcccc49341 100644 --- a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASTableNode.m +++ b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASTableNode.m @@ -43,8 +43,8 @@ - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { // 100% of container - _node.width = ASDimensionMakeWithFraction(1.0); - _node.height = ASDimensionMakeWithFraction(1.0); + _node.style.width = ASDimensionMakeWithFraction(1.0); + _node.style.height = ASDimensionMakeWithFraction(1.0); return [ASWrapperLayoutSpec wrapperWithLayoutable:_node]; } diff --git a/examples/AsyncDisplayKitOverview/Sample/OverviewComponentsViewController.m b/examples/AsyncDisplayKitOverview/Sample/OverviewComponentsViewController.m index 1cfacbb5fd..da63c86cec 100644 --- a/examples/AsyncDisplayKitOverview/Sample/OverviewComponentsViewController.m +++ b/examples/AsyncDisplayKitOverview/Sample/OverviewComponentsViewController.m @@ -208,7 +208,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr CGSize imageNetworkImageNodeSize = (CGSize){imageNode.image.size.width / 7, imageNode.image.size.height / 7}; - [imageNode setSizeWithCGSize:imageNetworkImageNodeSize]; + [imageNode.style setSizeWithCGSize:imageNetworkImageNodeSize]; parentNode = [self centeringParentNodeWithChild:imageNode]; parentNode.entryTitle = @"ASImageNode"; @@ -218,7 +218,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr #pragma mark ASNetworkImageNode ASNetworkImageNode *networkImageNode = [ASNetworkImageNode new]; networkImageNode.URL = [NSURL URLWithString:@"http://i.imgur.com/FjOR9kX.jpg"]; - [networkImageNode setSizeWithCGSize:imageNetworkImageNodeSize]; + [networkImageNode.style setSizeWithCGSize:imageNetworkImageNodeSize]; parentNode = [self centeringParentNodeWithChild:networkImageNode]; parentNode.entryTitle = @"ASNetworkImageNode"; @@ -227,7 +227,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr #pragma mark ASMapNode ASMapNode *mapNode = [ASMapNode new]; - [mapNode setSizeWithCGSize:(CGSize){300.0, 300.0}]; + [mapNode.style setSizeWithCGSize:CGSizeMake(300.0, 300.0)]; // San Francisco CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(37.7749, -122.4194); @@ -240,7 +240,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr #pragma mark ASVideoNode ASVideoNode *videoNode = [ASVideoNode new]; - [videoNode setSizeWithCGSize:(CGSize){300.0, 400.0}]; + [videoNode.style setSizeWithCGSize:CGSizeMake(300.0, 400.0)]; AVAsset *asset = [AVAsset assetWithURL:[NSURL URLWithString:@"http://www.w3schools.com/html/mov_bbb.mp4"]]; videoNode.asset = asset; @@ -254,7 +254,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr UIImage *scrollNodeImage = [UIImage imageNamed:@"image"]; ASScrollNode *scrollNode = [ASScrollNode new]; - [scrollNode setSizeWithCGSize:(CGSize){300.0, 400.0}]; + [scrollNode.style setSizeWithCGSize:CGSizeMake(300.0, 400.0)]; UIScrollView *scrollNodeView = scrollNode.view; [scrollNodeView addSubview:[[UIImageView alloc] initWithImage:scrollNodeImage]]; @@ -362,7 +362,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr #pragma mark ASStaticLayoutSpec childNode = [self childNode]; // Add a layout position to the child node that the static layout spec will pick up and place it on that position - childNode.layoutPosition = CGPointMake(10.0, 10.0); + childNode.style.layoutPosition = CGPointMake(10.0, 10.0); parentNode = [self parentNodeWithChild:childNode]; parentNode.entryTitle = @"ASStaticLayoutSpec"; @@ -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 // 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 - childNode2.flexShrink = YES; - childNode3.flexShrink = YES; + childNode2.style.flexShrink = YES; + childNode3.style.flexShrink = YES; parentNode = [self parentNodeWithChild:childNode]; parentNode.entryTitle = @"Vertical ASStackLayoutSpec"; @@ -406,17 +406,17 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr #pragma mark Horizontal ASStackLayoutSpec childNode1 = [ASDisplayNode new]; - [childNode1 setSizeWithCGSize:(CGSize){10.0, 20.0}]; - childNode1.flexGrow = YES; + [childNode1.style setSizeWithCGSize:CGSizeMake(10.0, 20.0)]; + childNode1.style.flexGrow = YES; childNode1.backgroundColor = [UIColor greenColor]; childNode2 = [ASDisplayNode new]; - [childNode2 setSizeWithCGSize:(CGSize){10.0, 20.0}]; - childNode2.alignSelf = ASStackLayoutAlignSelfStretch; + [childNode2.style setSizeWithCGSize:CGSizeMake(10.0, 20.0)]; + childNode2.style.alignSelf = ASStackLayoutAlignSelfStretch; childNode2.backgroundColor = [UIColor blueColor]; childNode3 = [ASDisplayNode new]; - [childNode3 setSizeWithCGSize:(CGSize){10.0, 20.0}]; + [childNode3.style setSizeWithCGSize:CGSizeMake(10.0, 20.0)]; childNode3.backgroundColor = [UIColor yellowColor]; parentNode = [self parentNodeWithChild:childNode]; @@ -431,8 +431,8 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr horizontalStackSpec.spacing = 5.0; // Spacing between children // Layout the stack layout with 100% width and 100% height of the parent node - horizontalStackSpec.height = ASDimensionMakeWithFraction(1.0); - horizontalStackSpec.width = ASDimensionMakeWithFraction(1.0); + horizontalStackSpec.style.height = ASDimensionMakeWithFraction(1.0); + horizontalStackSpec.style.width = ASDimensionMakeWithFraction(1.0); // Add a bit of inset return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(0.0, 5.0, 0.0, 5.0) child:horizontalStackSpec]; @@ -467,7 +467,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr - (OverviewDisplayNodeWithSizeBlock *)parentNodeWithChild:(ASDisplayNode *)child { OverviewDisplayNodeWithSizeBlock *parentNode = [OverviewDisplayNodeWithSizeBlock new]; - [parentNode setSizeWithCGSize:(CGSize){100, 100}]; + [parentNode.style setSizeWithCGSize:CGSizeMake(100, 100)]; parentNode.backgroundColor = [UIColor redColor]; return parentNode; } @@ -491,7 +491,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr - (ASDisplayNode *)childNode { ASDisplayNode *childNode = [ASDisplayNode new]; - [childNode setSizeWithCGSize:(CGSize){50, 50}]; + [childNode.style setSizeWithCGSize:CGSizeMake(50, 50)]; childNode.backgroundColor = [UIColor blueColor]; return childNode; } diff --git a/examples/CatDealsCollectionView/Sample/ItemNode.m b/examples/CatDealsCollectionView/Sample/ItemNode.m index 4874f338d8..2e18c65494 100644 --- a/examples/CatDealsCollectionView/Sample/ItemNode.m +++ b/examples/CatDealsCollectionView/Sample/ItemNode.m @@ -75,8 +75,8 @@ const CGFloat kSoldOutGBHeight = 50.0; self.titleLabel = [[ASTextNode alloc] init]; self.titleLabel.maximumNumberOfLines = 2; - self.titleLabel.alignSelf = ASStackLayoutAlignSelfStart; - self.titleLabel.flexGrow = YES; + self.titleLabel.style.alignSelf = ASStackLayoutAlignSelfStart; + self.titleLabel.style.flexGrow = YES; self.titleLabel.layerBacked = YES; self.firstInfoLabel = [[ASTextNode alloc] init]; @@ -107,14 +107,14 @@ const CGFloat kSoldOutGBHeight = 50.0; self.soldOutLabelFlat.layerBacked = YES; self.soldOutLabelBackground = [[ASDisplayNode alloc] init]; - self.soldOutLabelBackground.width = ASDimensionMakeWithFraction(1.0); - self.soldOutLabelBackground.height = ASDimensionMakeWithPoints(kSoldOutGBHeight); + self.soldOutLabelBackground.style.width = ASDimensionMakeWithFraction(1.0); + self.soldOutLabelBackground.style.height = ASDimensionMakeWithPoints(kSoldOutGBHeight); self.soldOutLabelBackground.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.9]; - self.soldOutLabelBackground.flexGrow = YES; + self.soldOutLabelBackground.style.flexGrow = YES; self.soldOutLabelBackground.layerBacked = YES; self.soldOutOverlay = [[ASDisplayNode alloc] init]; - self.soldOutOverlay.flexGrow = YES; + self.soldOutOverlay.style.flexGrow = YES; self.soldOutOverlay.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5]; self.soldOutOverlay.layerBacked = YES; @@ -135,18 +135,18 @@ const CGFloat kSoldOutGBHeight = 50.0; self.soldOutLabelFlat.hidden = YES; if ([ItemNode isRTL]) { - self.titleLabel.alignSelf = ASStackLayoutAlignSelfEnd; - self.firstInfoLabel.alignSelf = ASStackLayoutAlignSelfEnd; - self.distanceLabel.alignSelf = ASStackLayoutAlignSelfEnd; - self.secondInfoLabel.alignSelf = ASStackLayoutAlignSelfEnd; - self.originalPriceLabel.alignSelf = ASStackLayoutAlignSelfStart; - self.finalPriceLabel.alignSelf = ASStackLayoutAlignSelfStart; + self.titleLabel.style.alignSelf = ASStackLayoutAlignSelfEnd; + self.firstInfoLabel.style.alignSelf = ASStackLayoutAlignSelfEnd; + self.distanceLabel.style.alignSelf = ASStackLayoutAlignSelfEnd; + self.secondInfoLabel.style.alignSelf = ASStackLayoutAlignSelfEnd; + self.originalPriceLabel.style.alignSelf = ASStackLayoutAlignSelfStart; + self.finalPriceLabel.style.alignSelf = ASStackLayoutAlignSelfStart; } else { - self.firstInfoLabel.alignSelf = ASStackLayoutAlignSelfStart; - self.distanceLabel.alignSelf = ASStackLayoutAlignSelfStart; - self.secondInfoLabel.alignSelf = ASStackLayoutAlignSelfStart; - self.originalPriceLabel.alignSelf = ASStackLayoutAlignSelfEnd; - self.finalPriceLabel.alignSelf = ASStackLayoutAlignSelfEnd; + self.firstInfoLabel.style.alignSelf = ASStackLayoutAlignSelfStart; + self.distanceLabel.style.alignSelf = ASStackLayoutAlignSelfStart; + self.secondInfoLabel.style.alignSelf = ASStackLayoutAlignSelfStart; + self.originalPriceLabel.style.alignSelf = ASStackLayoutAlignSelfEnd; + self.finalPriceLabel.style.alignSelf = ASStackLayoutAlignSelfEnd; } } @@ -257,13 +257,13 @@ const CGFloat kSoldOutGBHeight = 50.0; UIEdgeInsets textInsets = UIEdgeInsetsMake(kInsetTop, kInsetHorizontal, kInsetBottom, kInsetHorizontal); ASLayoutSpec *verticalSpacer = [[ASLayoutSpec alloc] init]; - verticalSpacer.flexGrow = YES; + verticalSpacer.style.flexGrow = YES; ASLayoutSpec *horizontalSpacer1 = [[ASLayoutSpec alloc] init]; - horizontalSpacer1.flexGrow = YES; + horizontalSpacer1.style.flexGrow = YES; ASLayoutSpec *horizontalSpacer2 = [[ASLayoutSpec alloc] init]; - horizontalSpacer2.flexGrow = YES; + horizontalSpacer2.style.flexGrow = YES; NSArray *info1Children = @[self.firstInfoLabel, self.distanceLabel, horizontalSpacer1, self.originalPriceLabel]; 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]]; ASInsetLayoutSpec *textWrapper = [ASInsetLayoutSpec insetLayoutSpecWithInsets:textInsets child:textStack]; - textWrapper.flexGrow = YES; + textWrapper.style.flexGrow = YES; return textWrapper; } @@ -289,12 +289,12 @@ const CGFloat kSoldOutGBHeight = 50.0; ASRatioLayoutSpec *imagePlace = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:imageRatio child:self.dealImageView]; - self.badge.layoutPosition = CGPointMake(0, constrainedSize.max.height - kFixedLabelsAreaHeight - kBadgeHeight); - self.badge.height = ASDimensionMakeWithPoints(kBadgeHeight); + self.badge.style.layoutPosition = CGPointMake(0, constrainedSize.max.height - kFixedLabelsAreaHeight - kBadgeHeight); + self.badge.style.height = ASDimensionMakeWithPoints(kBadgeHeight); ASStaticLayoutSpec *badgePosition = [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[self.badge]]; ASOverlayLayoutSpec *badgeOverImage = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:imagePlace overlay:badgePosition]; - badgeOverImage.flexGrow = YES; + badgeOverImage.style.flexGrow = YES; return badgeOverImage; } diff --git a/examples/CatDealsCollectionView/Sample/LoadingNode.m b/examples/CatDealsCollectionView/Sample/LoadingNode.m index dafc883d1f..408546418b 100644 --- a/examples/CatDealsCollectionView/Sample/LoadingNode.m +++ b/examples/CatDealsCollectionView/Sample/LoadingNode.m @@ -53,7 +53,7 @@ static CGFloat kFixedHeight = 200.0f; [spinner startAnimating]; return spinner; }]; - [_loadingSpinner setSizeWithCGSize:CGSizeMake(50, 50)]; + [_loadingSpinner.style setSizeWithCGSize:CGSizeMake(50, 50)]; // add it as a subnode, and we're done [self addSubnode:_loadingSpinner]; @@ -75,4 +75,4 @@ static CGFloat kFixedHeight = 200.0f; return centerSpec; } -@end \ No newline at end of file +@end diff --git a/examples/HorizontalWithinVerticalScrolling/Sample/HorizontalScrollCellNode.mm b/examples/HorizontalWithinVerticalScrolling/Sample/HorizontalScrollCellNode.mm index b5ba08889b..7716001b40 100644 --- a/examples/HorizontalWithinVerticalScrolling/Sample/HorizontalScrollCellNode.mm +++ b/examples/HorizontalWithinVerticalScrolling/Sample/HorizontalScrollCellNode.mm @@ -79,7 +79,7 @@ static const CGFloat kInnerPadding = 10.0f; CGSize elementSize = _elementSize; return ^{ RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init]; - [elementNode setSizeWithCGSize:elementSize]; + [elementNode.style setSizeWithCGSize:elementSize]; return elementNode; }; } @@ -87,7 +87,7 @@ static const CGFloat kInnerPadding = 10.0f; - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize { CGSize collectionNodeSize = CGSizeMake(constrainedSize.max.width, _elementSize.height); - [_collectionNode setSizeWithCGSize:collectionNodeSize]; + [_collectionNode.style setSizeWithCGSize:collectionNodeSize]; ASInsetLayoutSpec *insetSpec = [[ASInsetLayoutSpec alloc] init]; insetSpec.insets = UIEdgeInsetsMake(kOuterPadding, 0.0, kOuterPadding, 0.0); diff --git a/examples/Kittens/Sample/KittenNode.mm b/examples/Kittens/Sample/KittenNode.mm index f75fc101f8..6a92e0f1f0 100644 --- a/examples/Kittens/Sample/KittenNode.mm +++ b/examples/Kittens/Sample/KittenNode.mm @@ -145,10 +145,10 @@ static const CGFloat kInnerPadding = 10.0f; { // Set an intrinsic size for the image node CGSize imageSize = _isImageEnlarged ? CGSizeMake(2.0 * kImageSize, 2.0 * kImageSize) : CGSizeMake(kImageSize, kImageSize); - [_imageNode setSizeWithCGSize:imageSize]; + [_imageNode.style setSizeWithCGSize:imageSize]; // Shrink the text node in case the image + text gonna be too wide - _textNode.flexShrink = YES; + _textNode.style.flexShrink = YES; // Configure stack ASStackLayoutSpec *stackLayoutSpec = diff --git a/examples/SocialAppLayout/Sample/CommentsNode.m b/examples/SocialAppLayout/Sample/CommentsNode.m index 33ad608f45..48d1d457ad 100644 --- a/examples/SocialAppLayout/Sample/CommentsNode.m +++ b/examples/SocialAppLayout/Sample/CommentsNode.m @@ -61,8 +61,8 @@ children:@[_iconNode, _countNode]]; // Adjust size - mainStack.minWidth = ASDimensionMakeWithPoints(60.0); - mainStack.maxHeight = ASDimensionMakeWithPoints(40.0); + mainStack.style.minWidth = ASDimensionMakeWithPoints(60.0); + mainStack.style.maxHeight = ASDimensionMakeWithPoints(40.0); return mainStack; } diff --git a/examples/SocialAppLayout/Sample/LikesNode.m b/examples/SocialAppLayout/Sample/LikesNode.m index 041775e562..593d5ae5de 100644 --- a/examples/SocialAppLayout/Sample/LikesNode.m +++ b/examples/SocialAppLayout/Sample/LikesNode.m @@ -74,8 +74,8 @@ alignItems:ASStackLayoutAlignItemsCenter children:@[_iconNode, _countNode]]; - mainStack.minWidth = ASDimensionMakeWithPoints(60.0); - mainStack.maxHeight = ASDimensionMakeWithPoints(40.0); + mainStack.style.minWidth = ASDimensionMakeWithPoints(60.0); + mainStack.style.maxHeight = ASDimensionMakeWithPoints(40.0); return mainStack; } diff --git a/examples/SocialAppLayout/Sample/PostNode.m b/examples/SocialAppLayout/Sample/PostNode.m index 6b45f2f2b1..bf4f57c7a1 100644 --- a/examples/SocialAppLayout/Sample/PostNode.m +++ b/examples/SocialAppLayout/Sample/PostNode.m @@ -60,7 +60,7 @@ // Username node _usernameNode = [[ASTextNode alloc] init]; _usernameNode.attributedText = [[NSAttributedString alloc] initWithString:_post.username attributes:[TextStyles usernameStyle]]; - _usernameNode.flexShrink = YES; //if name and username don't fit to cell width, allow username shrink + _usernameNode.style.flexShrink = YES; //if name and username don't fit to cell width, allow username shrink _usernameNode.truncationMode = NSLineBreakByTruncatingTail; _usernameNode.maximumNumberOfLines = 1; [self addSubnode:_usernameNode]; @@ -137,8 +137,8 @@ // User pic _avatarNode = [[ASNetworkImageNode alloc] init]; _avatarNode.backgroundColor = ASDisplayNodeDefaultPlaceholderColor(); - _avatarNode.width = ASDimensionMakeWithPoints(44); - _avatarNode.height = ASDimensionMakeWithPoints(44); + _avatarNode.style.width = ASDimensionMakeWithPoints(44); + _avatarNode.style.height = ASDimensionMakeWithPoints(44); _avatarNode.cornerRadius = 22.0; _avatarNode.URL = [NSURL URLWithString:_post.photo]; _avatarNode.imageModificationBlock = ^UIImage *(UIImage *image) { @@ -211,7 +211,7 @@ { // Flexible spacer between username and time ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init]; - spacer.flexGrow = YES; + spacer.style.flexGrow = YES; // 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. @@ -235,7 +235,7 @@ justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsCenter children:layoutSpecChildren]; - nameStack.alignSelf = ASStackLayoutAlignSelfStretch; + nameStack.style.alignSelf = ASStackLayoutAlignSelfStretch; // bottom controls horizontal stack ASStackLayoutSpec *controlsStack = @@ -247,8 +247,8 @@ children:@[_likesNode, _commentsNode, _optionsNode]]; // Add more gaps for control line - controlsStack.spacingAfter = 3.0; - controlsStack.spacingBefore = 3.0; + controlsStack.style.spacingAfter = 3.0; + controlsStack.style.spacingBefore = 3.0; NSMutableArray *mainStackContent = [[NSMutableArray alloc] init]; [mainStackContent addObject:nameStack]; @@ -264,8 +264,8 @@ [ASRatioLayoutSpec ratioLayoutSpecWithRatio:imageRatio child:_mediaNode]; - imagePlace.spacingAfter = 3.0; - imagePlace.spacingBefore = 3.0; + imagePlace.style.spacingAfter = 3.0; + imagePlace.style.spacingBefore = 3.0; [mainStackContent addObject:imagePlace]; } @@ -280,7 +280,7 @@ justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStretch children:mainStackContent]; - contentSpec.flexShrink = YES; + contentSpec.style.flexShrink = YES; // Horizontal spec for avatar ASStackLayoutSpec *avatarContentSpec = diff --git a/examples/VerticalWithinHorizontalScrolling/Sample/GradientTableNode.mm b/examples/VerticalWithinHorizontalScrolling/Sample/GradientTableNode.mm index eaa01e7d6d..ea873564a8 100644 --- a/examples/VerticalWithinHorizontalScrolling/Sample/GradientTableNode.mm +++ b/examples/VerticalWithinHorizontalScrolling/Sample/GradientTableNode.mm @@ -68,7 +68,7 @@ - (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath { RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init]; - [elementNode setSizeWithCGSize:_elementSize]; + [elementNode.style setSizeWithCGSize:_elementSize]; elementNode.indexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:_pageNumber]; return elementNode; } diff --git a/examples/VerticalWithinHorizontalScrolling/Sample/ViewController.m b/examples/VerticalWithinHorizontalScrolling/Sample/ViewController.m index e7311a3387..fe759d4fc7 100644 --- a/examples/VerticalWithinHorizontalScrolling/Sample/ViewController.m +++ b/examples/VerticalWithinHorizontalScrolling/Sample/ViewController.m @@ -77,7 +77,7 @@ CGSize boundsSize = pagerNode.bounds.size; CGSize gradientRowSize = CGSizeMake(boundsSize.width, 100); GradientTableNode *node = [[GradientTableNode alloc] initWithElementSize:gradientRowSize]; - [node setSizeWithCGSize:boundsSize]; + [node.style setSizeWithCGSize:boundsSize]; node.pageNumber = index; return node; }