mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
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
This commit is contained in:
@@ -98,13 +98,13 @@
|
|||||||
- (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.flexGrow = YES;
|
nextTextNode.style.flexGrow = YES;
|
||||||
nextTextNode.flexShrink = YES;
|
nextTextNode.style.flexShrink = YES;
|
||||||
|
|
||||||
ASStackLayoutSpec *horizontalStackLayout = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
ASStackLayoutSpec *horizontalStackLayout = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||||
horizontalStackLayout.children = @[nextTextNode];
|
horizontalStackLayout.children = @[nextTextNode];
|
||||||
|
|
||||||
self.buttonNode.alignSelf = ASStackLayoutAlignSelfCenter;
|
self.buttonNode.style.alignSelf = ASStackLayoutAlignSelfCenter;
|
||||||
|
|
||||||
ASStackLayoutSpec *verticalStackLayout = [ASStackLayoutSpec verticalStackLayoutSpec];
|
ASStackLayoutSpec *verticalStackLayout = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||||
verticalStackLayout.spacing = 10.0;
|
verticalStackLayout.spacing = 10.0;
|
||||||
|
|||||||
@@ -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.flexGrow = YES;
|
_titleNode.style.flexGrow = YES;
|
||||||
[self addSubnode:_titleNode];
|
[self addSubnode:_titleNode];
|
||||||
|
|
||||||
_avatarNode = [[ASNetworkImageNode alloc] init];
|
_avatarNode = [[ASNetworkImageNode alloc] init];
|
||||||
@@ -65,8 +65,8 @@
|
|||||||
[self addSubnode:_likeButtonNode];
|
[self addSubnode:_likeButtonNode];
|
||||||
|
|
||||||
_muteButtonNode = [[ASButtonNode alloc] init];
|
_muteButtonNode = [[ASButtonNode alloc] init];
|
||||||
_muteButtonNode.width = ASDimensionMakeWithPoints(16.0);
|
_muteButtonNode.style.width = ASDimensionMakeWithPoints(16.0);
|
||||||
_muteButtonNode.height = ASDimensionMakeWithPoints(22.0);
|
_muteButtonNode.style.height = ASDimensionMakeWithPoints(22.0);
|
||||||
[_muteButtonNode addTarget:self action:@selector(didTapMuteButton) forControlEvents:ASControlNodeEventTouchUpInside];
|
[_muteButtonNode addTarget:self action:@selector(didTapMuteButton) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||||
|
|
||||||
_videoPlayerNode = [[ASVideoPlayerNode alloc] initWithUrl:_videoModel.url loadAssetWhenNodeBecomesVisible:YES];
|
_videoPlayerNode = [[ASVideoPlayerNode alloc] initWithUrl:_videoModel.url loadAssetWhenNodeBecomesVisible:YES];
|
||||||
@@ -91,14 +91,14 @@
|
|||||||
{
|
{
|
||||||
CGFloat fullWidth = [UIScreen mainScreen].bounds.size.width;
|
CGFloat fullWidth = [UIScreen mainScreen].bounds.size.width;
|
||||||
|
|
||||||
_videoPlayerNode.width = ASDimensionMakeWithPoints(fullWidth);
|
_videoPlayerNode.style.width = ASDimensionMakeWithPoints(fullWidth);
|
||||||
_videoPlayerNode.height = ASDimensionMakeWithPoints(fullWidth * 9 / 16);
|
_videoPlayerNode.style.height = ASDimensionMakeWithPoints(fullWidth * 9 / 16);
|
||||||
|
|
||||||
_avatarNode.width = ASDimensionMakeWithPoints(AVATAR_IMAGE_HEIGHT);
|
_avatarNode.style.width = ASDimensionMakeWithPoints(AVATAR_IMAGE_HEIGHT);
|
||||||
_avatarNode.height = ASDimensionMakeWithPoints(AVATAR_IMAGE_HEIGHT);
|
_avatarNode.style.height = ASDimensionMakeWithPoints(AVATAR_IMAGE_HEIGHT);
|
||||||
|
|
||||||
_likeButtonNode.width = ASDimensionMakeWithPoints(50.0);
|
_likeButtonNode.style.width = ASDimensionMakeWithPoints(50.0);
|
||||||
_likeButtonNode.height = ASDimensionMakeWithPoints(26.0);
|
_likeButtonNode.style.height = ASDimensionMakeWithPoints(26.0);
|
||||||
|
|
||||||
ASStackLayoutSpec *headerStack = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
ASStackLayoutSpec *headerStack = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||||
headerStack.spacing = HORIZONTAL_BUFFER;
|
headerStack.spacing = HORIZONTAL_BUFFER;
|
||||||
@@ -184,16 +184,16 @@
|
|||||||
- (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.flexGrow = YES;
|
spacer.style.flexGrow = YES;
|
||||||
|
|
||||||
UIEdgeInsets insets = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0);
|
UIEdgeInsets insets = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0);
|
||||||
|
|
||||||
if (controls[ @(ASVideoPlayerNodeControlTypeScrubber) ]) {
|
if (controls[ @(ASVideoPlayerNodeControlTypeScrubber) ]) {
|
||||||
ASDisplayNode *scrubber = controls[ @(ASVideoPlayerNodeControlTypeScrubber) ];
|
ASDisplayNode *scrubber = controls[ @(ASVideoPlayerNodeControlTypeScrubber) ];
|
||||||
scrubber.height = ASDimensionMakeWithPoints(44.0);
|
scrubber.style.height = ASDimensionMakeWithPoints(44.0);
|
||||||
scrubber.minWidth = ASDimensionMakeWithPoints(0.0);
|
scrubber.style.minWidth = ASDimensionMakeWithPoints(0.0);
|
||||||
scrubber.maxWidth = ASDimensionMakeWithPoints(maxSize.width);
|
scrubber.style.maxWidth = ASDimensionMakeWithPoints(maxSize.width);
|
||||||
scrubber.flexGrow = YES;
|
scrubber.style.flexGrow = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray *controlBarControls = [self controlsForControlBar:controls];
|
NSArray *controlBarControls = [self controlsForControlBar:controls];
|
||||||
@@ -218,13 +218,13 @@
|
|||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsCenter
|
alignItems:ASStackLayoutAlignItemsCenter
|
||||||
children: controlBarControls ];
|
children: controlBarControls ];
|
||||||
controlbarSpec.alignSelf = ASStackLayoutAlignSelfStretch;
|
controlbarSpec.style.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ASInsetLayoutSpec *controlbarInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:controlbarSpec];
|
ASInsetLayoutSpec *controlbarInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:controlbarSpec];
|
||||||
|
|
||||||
controlbarInsetSpec.alignSelf = ASStackLayoutAlignSelfStretch;
|
controlbarInsetSpec.style.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||||
|
|
||||||
ASStackLayoutSpec *mainVerticalStack = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical
|
ASStackLayoutSpec *mainVerticalStack = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical
|
||||||
spacing:0.0
|
spacing:0.0
|
||||||
|
|||||||
@@ -117,20 +117,20 @@
|
|||||||
#define HEIGHT 30
|
#define HEIGHT 30
|
||||||
CGSize nodeSize = CGSizeMake(constrainedSize.max.width * 0.3, HEIGHT);
|
CGSize nodeSize = CGSizeMake(constrainedSize.max.width * 0.3, HEIGHT);
|
||||||
|
|
||||||
[_latEditableNode setSizeWithCGSize:nodeSize];
|
[_latEditableNode.style setSizeWithCGSize:nodeSize];
|
||||||
[_lonEditableNode setSizeWithCGSize:nodeSize];
|
[_lonEditableNode.style setSizeWithCGSize:nodeSize];
|
||||||
|
|
||||||
[_deltaLatEditableNode setSizeWithCGSize:nodeSize];
|
[_deltaLatEditableNode.style setSizeWithCGSize:nodeSize];
|
||||||
[_deltaLonEditableNode setSizeWithCGSize:nodeSize];
|
[_deltaLonEditableNode.style setSizeWithCGSize:nodeSize];
|
||||||
|
|
||||||
[_updateRegionButton setSizeWithCGSize:nodeSize];
|
[_updateRegionButton.style setSizeWithCGSize:nodeSize];
|
||||||
[_liveMapToggleButton setSizeWithCGSize:nodeSize];
|
[_liveMapToggleButton.style setSizeWithCGSize:nodeSize];
|
||||||
|
|
||||||
_latEditableNode.flexGrow = _lonEditableNode.flexGrow = YES;
|
_latEditableNode.style.flexGrow = _lonEditableNode.style.flexGrow = YES;
|
||||||
_deltaLatEditableNode.flexGrow = _deltaLonEditableNode.flexGrow = YES;
|
_deltaLatEditableNode.style.flexGrow = _deltaLonEditableNode.style.flexGrow = YES;
|
||||||
_updateRegionButton.flexGrow = _liveMapToggleButton.flexGrow = YES;
|
_updateRegionButton.style.flexGrow = _liveMapToggleButton.style.flexGrow = YES;
|
||||||
|
|
||||||
_mapNode.flexGrow = YES;
|
_mapNode.style.flexGrow = YES;
|
||||||
|
|
||||||
ASStackLayoutSpec *lonlatSpec =
|
ASStackLayoutSpec *lonlatSpec =
|
||||||
[ASStackLayoutSpec
|
[ASStackLayoutSpec
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsCenter
|
alignItems:ASStackLayoutAlignItemsCenter
|
||||||
children:@[_latEditableNode, _lonEditableNode]];
|
children:@[_latEditableNode, _lonEditableNode]];
|
||||||
lonlatSpec.flexGrow = true;
|
lonlatSpec.style.flexGrow = true;
|
||||||
|
|
||||||
ASStackLayoutSpec *deltaLonlatSpec =
|
ASStackLayoutSpec *deltaLonlatSpec =
|
||||||
[ASStackLayoutSpec
|
[ASStackLayoutSpec
|
||||||
@@ -148,7 +148,7 @@
|
|||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsCenter
|
alignItems:ASStackLayoutAlignItemsCenter
|
||||||
children:@[_deltaLatEditableNode, _deltaLonEditableNode]];
|
children:@[_deltaLatEditableNode, _deltaLonEditableNode]];
|
||||||
deltaLonlatSpec.flexGrow = true;
|
deltaLonlatSpec.style.flexGrow = true;
|
||||||
|
|
||||||
ASStackLayoutSpec *lonlatConfigSpec =
|
ASStackLayoutSpec *lonlatConfigSpec =
|
||||||
[ASStackLayoutSpec
|
[ASStackLayoutSpec
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsStretch
|
alignItems:ASStackLayoutAlignItemsStretch
|
||||||
children:@[lonlatSpec, deltaLonlatSpec]];
|
children:@[lonlatSpec, deltaLonlatSpec]];
|
||||||
lonlatConfigSpec.flexGrow = true;
|
lonlatConfigSpec.style.flexGrow = true;
|
||||||
|
|
||||||
ASStackLayoutSpec *buttonsSpec =
|
ASStackLayoutSpec *buttonsSpec =
|
||||||
[ASStackLayoutSpec
|
[ASStackLayoutSpec
|
||||||
@@ -166,7 +166,7 @@
|
|||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsStretch
|
alignItems:ASStackLayoutAlignItemsStretch
|
||||||
children:@[_updateRegionButton, _liveMapToggleButton]];
|
children:@[_updateRegionButton, _liveMapToggleButton]];
|
||||||
buttonsSpec.flexGrow = true;
|
buttonsSpec.style.flexGrow = true;
|
||||||
|
|
||||||
ASStackLayoutSpec *dashboardSpec =
|
ASStackLayoutSpec *dashboardSpec =
|
||||||
[ASStackLayoutSpec
|
[ASStackLayoutSpec
|
||||||
@@ -175,7 +175,7 @@
|
|||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsStretch
|
alignItems:ASStackLayoutAlignItemsStretch
|
||||||
children:@[lonlatConfigSpec, buttonsSpec]];
|
children:@[lonlatConfigSpec, buttonsSpec]];
|
||||||
dashboardSpec.flexGrow = true;
|
dashboardSpec.style.flexGrow = true;
|
||||||
|
|
||||||
ASInsetLayoutSpec *insetSpec =
|
ASInsetLayoutSpec *insetSpec =
|
||||||
[ASInsetLayoutSpec
|
[ASInsetLayoutSpec
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
self.imageNode.position = CGPointZero;
|
self.imageNode.position = CGPointZero;
|
||||||
[self.imageNode setSizeWithCGSize:constrainedSize.max];
|
[self.imageNode.style setSizeWithCGSize:constrainedSize.max];
|
||||||
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[self.imageNode]];
|
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[self.imageNode]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ static const NSInteger kImageHeight = 200;
|
|||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
self.collectionNode.position = CGPointZero;
|
self.collectionNode.position = CGPointZero;
|
||||||
[self.collectionNode setSizeWithCGSize:constrainedSize.max];
|
[self.collectionNode.style setSizeWithCGSize:constrainedSize.max];
|
||||||
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[self.collectionNode]];
|
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[self.collectionNode]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
// 100% of container
|
// 100% of container
|
||||||
_node.width = ASDimensionMakeWithFraction(1.0);
|
_node.style.width = ASDimensionMakeWithFraction(1.0);
|
||||||
_node.height = ASDimensionMakeWithFraction(1.0);
|
_node.style.height = ASDimensionMakeWithFraction(1.0);
|
||||||
return [ASWrapperLayoutSpec wrapperWithLayoutable:_node];
|
return [ASWrapperLayoutSpec wrapperWithLayoutable:_node];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ static UIColor *OverViewASPagerNodeRandomColor() {
|
|||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
// 100% of container
|
// 100% of container
|
||||||
_node.width = ASDimensionMakeWithFraction(1.0);
|
_node.style.width = ASDimensionMakeWithFraction(1.0);
|
||||||
_node.height = ASDimensionMakeWithFraction(1.0);
|
_node.style.height = ASDimensionMakeWithFraction(1.0);
|
||||||
return [ASWrapperLayoutSpec wrapperWithLayoutable:_node];
|
return [ASWrapperLayoutSpec wrapperWithLayoutable:_node];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,8 @@
|
|||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
// 100% of container
|
// 100% of container
|
||||||
_node.width = ASDimensionMakeWithFraction(1.0);
|
_node.style.width = ASDimensionMakeWithFraction(1.0);
|
||||||
_node.height = ASDimensionMakeWithFraction(1.0);
|
_node.style.height = ASDimensionMakeWithFraction(1.0);
|
||||||
return [ASWrapperLayoutSpec wrapperWithLayoutable:_node];
|
return [ASWrapperLayoutSpec wrapperWithLayoutable:_node];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
|
|
||||||
CGSize imageNetworkImageNodeSize = (CGSize){imageNode.image.size.width / 7, imageNode.image.size.height / 7};
|
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 = [self centeringParentNodeWithChild:imageNode];
|
||||||
parentNode.entryTitle = @"ASImageNode";
|
parentNode.entryTitle = @"ASImageNode";
|
||||||
@@ -218,7 +218,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
#pragma mark ASNetworkImageNode
|
#pragma mark ASNetworkImageNode
|
||||||
ASNetworkImageNode *networkImageNode = [ASNetworkImageNode new];
|
ASNetworkImageNode *networkImageNode = [ASNetworkImageNode new];
|
||||||
networkImageNode.URL = [NSURL URLWithString:@"http://i.imgur.com/FjOR9kX.jpg"];
|
networkImageNode.URL = [NSURL URLWithString:@"http://i.imgur.com/FjOR9kX.jpg"];
|
||||||
[networkImageNode setSizeWithCGSize:imageNetworkImageNodeSize];
|
[networkImageNode.style setSizeWithCGSize:imageNetworkImageNodeSize];
|
||||||
|
|
||||||
parentNode = [self centeringParentNodeWithChild:networkImageNode];
|
parentNode = [self centeringParentNodeWithChild:networkImageNode];
|
||||||
parentNode.entryTitle = @"ASNetworkImageNode";
|
parentNode.entryTitle = @"ASNetworkImageNode";
|
||||||
@@ -227,7 +227,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
|
|
||||||
#pragma mark ASMapNode
|
#pragma mark ASMapNode
|
||||||
ASMapNode *mapNode = [ASMapNode new];
|
ASMapNode *mapNode = [ASMapNode new];
|
||||||
[mapNode setSizeWithCGSize:(CGSize){300.0, 300.0}];
|
[mapNode.style setSizeWithCGSize:CGSizeMake(300.0, 300.0)];
|
||||||
|
|
||||||
// San Francisco
|
// San Francisco
|
||||||
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(37.7749, -122.4194);
|
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(37.7749, -122.4194);
|
||||||
@@ -240,7 +240,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
|
|
||||||
#pragma mark ASVideoNode
|
#pragma mark ASVideoNode
|
||||||
ASVideoNode *videoNode = [ASVideoNode new];
|
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"]];
|
AVAsset *asset = [AVAsset assetWithURL:[NSURL URLWithString:@"http://www.w3schools.com/html/mov_bbb.mp4"]];
|
||||||
videoNode.asset = asset;
|
videoNode.asset = asset;
|
||||||
@@ -254,7 +254,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
UIImage *scrollNodeImage = [UIImage imageNamed:@"image"];
|
UIImage *scrollNodeImage = [UIImage imageNamed:@"image"];
|
||||||
|
|
||||||
ASScrollNode *scrollNode = [ASScrollNode new];
|
ASScrollNode *scrollNode = [ASScrollNode new];
|
||||||
[scrollNode setSizeWithCGSize:(CGSize){300.0, 400.0}];
|
[scrollNode.style setSizeWithCGSize:CGSizeMake(300.0, 400.0)];
|
||||||
|
|
||||||
UIScrollView *scrollNodeView = scrollNode.view;
|
UIScrollView *scrollNodeView = scrollNode.view;
|
||||||
[scrollNodeView addSubview:[[UIImageView alloc] initWithImage:scrollNodeImage]];
|
[scrollNodeView addSubview:[[UIImageView alloc] initWithImage:scrollNodeImage]];
|
||||||
@@ -362,7 +362,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
#pragma mark ASStaticLayoutSpec
|
#pragma mark ASStaticLayoutSpec
|
||||||
childNode = [self childNode];
|
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
|
// 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 = [self parentNodeWithChild:childNode];
|
||||||
parentNode.entryTitle = @"ASStaticLayoutSpec";
|
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
|
// 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.flexShrink = YES;
|
childNode2.style.flexShrink = YES;
|
||||||
childNode3.flexShrink = YES;
|
childNode3.style.flexShrink = YES;
|
||||||
|
|
||||||
parentNode = [self parentNodeWithChild:childNode];
|
parentNode = [self parentNodeWithChild:childNode];
|
||||||
parentNode.entryTitle = @"Vertical ASStackLayoutSpec";
|
parentNode.entryTitle = @"Vertical ASStackLayoutSpec";
|
||||||
@@ -406,17 +406,17 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
|
|
||||||
#pragma mark Horizontal ASStackLayoutSpec
|
#pragma mark Horizontal ASStackLayoutSpec
|
||||||
childNode1 = [ASDisplayNode new];
|
childNode1 = [ASDisplayNode new];
|
||||||
[childNode1 setSizeWithCGSize:(CGSize){10.0, 20.0}];
|
[childNode1.style setSizeWithCGSize:CGSizeMake(10.0, 20.0)];
|
||||||
childNode1.flexGrow = YES;
|
childNode1.style.flexGrow = YES;
|
||||||
childNode1.backgroundColor = [UIColor greenColor];
|
childNode1.backgroundColor = [UIColor greenColor];
|
||||||
|
|
||||||
childNode2 = [ASDisplayNode new];
|
childNode2 = [ASDisplayNode new];
|
||||||
[childNode2 setSizeWithCGSize:(CGSize){10.0, 20.0}];
|
[childNode2.style setSizeWithCGSize:CGSizeMake(10.0, 20.0)];
|
||||||
childNode2.alignSelf = ASStackLayoutAlignSelfStretch;
|
childNode2.style.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||||
childNode2.backgroundColor = [UIColor blueColor];
|
childNode2.backgroundColor = [UIColor blueColor];
|
||||||
|
|
||||||
childNode3 = [ASDisplayNode new];
|
childNode3 = [ASDisplayNode new];
|
||||||
[childNode3 setSizeWithCGSize:(CGSize){10.0, 20.0}];
|
[childNode3.style setSizeWithCGSize:CGSizeMake(10.0, 20.0)];
|
||||||
childNode3.backgroundColor = [UIColor yellowColor];
|
childNode3.backgroundColor = [UIColor yellowColor];
|
||||||
|
|
||||||
parentNode = [self parentNodeWithChild:childNode];
|
parentNode = [self parentNodeWithChild:childNode];
|
||||||
@@ -431,8 +431,8 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
horizontalStackSpec.spacing = 5.0; // Spacing between children
|
horizontalStackSpec.spacing = 5.0; // Spacing between children
|
||||||
|
|
||||||
// Layout the stack layout with 100% width and 100% height of the parent node
|
// Layout the stack layout with 100% width and 100% height of the parent node
|
||||||
horizontalStackSpec.height = ASDimensionMakeWithFraction(1.0);
|
horizontalStackSpec.style.height = ASDimensionMakeWithFraction(1.0);
|
||||||
horizontalStackSpec.width = ASDimensionMakeWithFraction(1.0);
|
horizontalStackSpec.style.width = ASDimensionMakeWithFraction(1.0);
|
||||||
|
|
||||||
// Add a bit of inset
|
// Add a bit of inset
|
||||||
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(0.0, 5.0, 0.0, 5.0) child:horizontalStackSpec];
|
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 *)parentNodeWithChild:(ASDisplayNode *)child
|
||||||
{
|
{
|
||||||
OverviewDisplayNodeWithSizeBlock *parentNode = [OverviewDisplayNodeWithSizeBlock new];
|
OverviewDisplayNodeWithSizeBlock *parentNode = [OverviewDisplayNodeWithSizeBlock new];
|
||||||
[parentNode setSizeWithCGSize:(CGSize){100, 100}];
|
[parentNode.style setSizeWithCGSize:CGSizeMake(100, 100)];
|
||||||
parentNode.backgroundColor = [UIColor redColor];
|
parentNode.backgroundColor = [UIColor redColor];
|
||||||
return parentNode;
|
return parentNode;
|
||||||
}
|
}
|
||||||
@@ -491,7 +491,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
|||||||
- (ASDisplayNode *)childNode
|
- (ASDisplayNode *)childNode
|
||||||
{
|
{
|
||||||
ASDisplayNode *childNode = [ASDisplayNode new];
|
ASDisplayNode *childNode = [ASDisplayNode new];
|
||||||
[childNode setSizeWithCGSize:(CGSize){50, 50}];
|
[childNode.style setSizeWithCGSize:CGSizeMake(50, 50)];
|
||||||
childNode.backgroundColor = [UIColor blueColor];
|
childNode.backgroundColor = [UIColor blueColor];
|
||||||
return childNode;
|
return childNode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ 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.alignSelf = ASStackLayoutAlignSelfStart;
|
self.titleLabel.style.alignSelf = ASStackLayoutAlignSelfStart;
|
||||||
self.titleLabel.flexGrow = YES;
|
self.titleLabel.style.flexGrow = YES;
|
||||||
self.titleLabel.layerBacked = YES;
|
self.titleLabel.layerBacked = YES;
|
||||||
|
|
||||||
self.firstInfoLabel = [[ASTextNode alloc] init];
|
self.firstInfoLabel = [[ASTextNode alloc] init];
|
||||||
@@ -107,14 +107,14 @@ const CGFloat kSoldOutGBHeight = 50.0;
|
|||||||
self.soldOutLabelFlat.layerBacked = YES;
|
self.soldOutLabelFlat.layerBacked = YES;
|
||||||
|
|
||||||
self.soldOutLabelBackground = [[ASDisplayNode alloc] init];
|
self.soldOutLabelBackground = [[ASDisplayNode alloc] init];
|
||||||
self.soldOutLabelBackground.width = ASDimensionMakeWithFraction(1.0);
|
self.soldOutLabelBackground.style.width = ASDimensionMakeWithFraction(1.0);
|
||||||
self.soldOutLabelBackground.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.flexGrow = YES;
|
self.soldOutLabelBackground.style.flexGrow = YES;
|
||||||
self.soldOutLabelBackground.layerBacked = YES;
|
self.soldOutLabelBackground.layerBacked = YES;
|
||||||
|
|
||||||
self.soldOutOverlay = [[ASDisplayNode alloc] init];
|
self.soldOutOverlay = [[ASDisplayNode alloc] init];
|
||||||
self.soldOutOverlay.flexGrow = YES;
|
self.soldOutOverlay.style.flexGrow = YES;
|
||||||
self.soldOutOverlay.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
|
self.soldOutOverlay.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
|
||||||
self.soldOutOverlay.layerBacked = YES;
|
self.soldOutOverlay.layerBacked = YES;
|
||||||
|
|
||||||
@@ -135,18 +135,18 @@ const CGFloat kSoldOutGBHeight = 50.0;
|
|||||||
self.soldOutLabelFlat.hidden = YES;
|
self.soldOutLabelFlat.hidden = YES;
|
||||||
|
|
||||||
if ([ItemNode isRTL]) {
|
if ([ItemNode isRTL]) {
|
||||||
self.titleLabel.alignSelf = ASStackLayoutAlignSelfEnd;
|
self.titleLabel.style.alignSelf = ASStackLayoutAlignSelfEnd;
|
||||||
self.firstInfoLabel.alignSelf = ASStackLayoutAlignSelfEnd;
|
self.firstInfoLabel.style.alignSelf = ASStackLayoutAlignSelfEnd;
|
||||||
self.distanceLabel.alignSelf = ASStackLayoutAlignSelfEnd;
|
self.distanceLabel.style.alignSelf = ASStackLayoutAlignSelfEnd;
|
||||||
self.secondInfoLabel.alignSelf = ASStackLayoutAlignSelfEnd;
|
self.secondInfoLabel.style.alignSelf = ASStackLayoutAlignSelfEnd;
|
||||||
self.originalPriceLabel.alignSelf = ASStackLayoutAlignSelfStart;
|
self.originalPriceLabel.style.alignSelf = ASStackLayoutAlignSelfStart;
|
||||||
self.finalPriceLabel.alignSelf = ASStackLayoutAlignSelfStart;
|
self.finalPriceLabel.style.alignSelf = ASStackLayoutAlignSelfStart;
|
||||||
} else {
|
} else {
|
||||||
self.firstInfoLabel.alignSelf = ASStackLayoutAlignSelfStart;
|
self.firstInfoLabel.style.alignSelf = ASStackLayoutAlignSelfStart;
|
||||||
self.distanceLabel.alignSelf = ASStackLayoutAlignSelfStart;
|
self.distanceLabel.style.alignSelf = ASStackLayoutAlignSelfStart;
|
||||||
self.secondInfoLabel.alignSelf = ASStackLayoutAlignSelfStart;
|
self.secondInfoLabel.style.alignSelf = ASStackLayoutAlignSelfStart;
|
||||||
self.originalPriceLabel.alignSelf = ASStackLayoutAlignSelfEnd;
|
self.originalPriceLabel.style.alignSelf = ASStackLayoutAlignSelfEnd;
|
||||||
self.finalPriceLabel.alignSelf = ASStackLayoutAlignSelfEnd;
|
self.finalPriceLabel.style.alignSelf = ASStackLayoutAlignSelfEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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.flexGrow = YES;
|
verticalSpacer.style.flexGrow = YES;
|
||||||
|
|
||||||
ASLayoutSpec *horizontalSpacer1 = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *horizontalSpacer1 = [[ASLayoutSpec alloc] init];
|
||||||
horizontalSpacer1.flexGrow = YES;
|
horizontalSpacer1.style.flexGrow = YES;
|
||||||
|
|
||||||
ASLayoutSpec *horizontalSpacer2 = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *horizontalSpacer2 = [[ASLayoutSpec alloc] init];
|
||||||
horizontalSpacer2.flexGrow = YES;
|
horizontalSpacer2.style.flexGrow = YES;
|
||||||
|
|
||||||
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.flexGrow = YES;
|
textWrapper.style.flexGrow = YES;
|
||||||
|
|
||||||
return textWrapper;
|
return textWrapper;
|
||||||
}
|
}
|
||||||
@@ -289,12 +289,12 @@ const CGFloat kSoldOutGBHeight = 50.0;
|
|||||||
|
|
||||||
ASRatioLayoutSpec *imagePlace = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:imageRatio child:self.dealImageView];
|
ASRatioLayoutSpec *imagePlace = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:imageRatio child:self.dealImageView];
|
||||||
|
|
||||||
self.badge.layoutPosition = CGPointMake(0, constrainedSize.max.height - kFixedLabelsAreaHeight - kBadgeHeight);
|
self.badge.style.layoutPosition = CGPointMake(0, constrainedSize.max.height - kFixedLabelsAreaHeight - kBadgeHeight);
|
||||||
self.badge.height = ASDimensionMakeWithPoints(kBadgeHeight);
|
self.badge.style.height = ASDimensionMakeWithPoints(kBadgeHeight);
|
||||||
ASStaticLayoutSpec *badgePosition = [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[self.badge]];
|
ASStaticLayoutSpec *badgePosition = [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[self.badge]];
|
||||||
|
|
||||||
ASOverlayLayoutSpec *badgeOverImage = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:imagePlace overlay:badgePosition];
|
ASOverlayLayoutSpec *badgeOverImage = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:imagePlace overlay:badgePosition];
|
||||||
badgeOverImage.flexGrow = YES;
|
badgeOverImage.style.flexGrow = YES;
|
||||||
|
|
||||||
return badgeOverImage;
|
return badgeOverImage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ static CGFloat kFixedHeight = 200.0f;
|
|||||||
[spinner startAnimating];
|
[spinner startAnimating];
|
||||||
return spinner;
|
return spinner;
|
||||||
}];
|
}];
|
||||||
[_loadingSpinner setSizeWithCGSize:CGSizeMake(50, 50)];
|
[_loadingSpinner.style setSizeWithCGSize:CGSizeMake(50, 50)];
|
||||||
|
|
||||||
// add it as a subnode, and we're done
|
// add it as a subnode, and we're done
|
||||||
[self addSubnode:_loadingSpinner];
|
[self addSubnode:_loadingSpinner];
|
||||||
@@ -75,4 +75,4 @@ static CGFloat kFixedHeight = 200.0f;
|
|||||||
return centerSpec;
|
return centerSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ static const CGFloat kInnerPadding = 10.0f;
|
|||||||
CGSize elementSize = _elementSize;
|
CGSize elementSize = _elementSize;
|
||||||
return ^{
|
return ^{
|
||||||
RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init];
|
RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init];
|
||||||
[elementNode setSizeWithCGSize:elementSize];
|
[elementNode.style setSizeWithCGSize:elementSize];
|
||||||
return elementNode;
|
return elementNode;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ static const CGFloat kInnerPadding = 10.0f;
|
|||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
CGSize collectionNodeSize = CGSizeMake(constrainedSize.max.width, _elementSize.height);
|
CGSize collectionNodeSize = CGSizeMake(constrainedSize.max.width, _elementSize.height);
|
||||||
[_collectionNode setSizeWithCGSize:collectionNodeSize];
|
[_collectionNode.style setSizeWithCGSize:collectionNodeSize];
|
||||||
|
|
||||||
ASInsetLayoutSpec *insetSpec = [[ASInsetLayoutSpec alloc] init];
|
ASInsetLayoutSpec *insetSpec = [[ASInsetLayoutSpec alloc] init];
|
||||||
insetSpec.insets = UIEdgeInsetsMake(kOuterPadding, 0.0, kOuterPadding, 0.0);
|
insetSpec.insets = UIEdgeInsetsMake(kOuterPadding, 0.0, kOuterPadding, 0.0);
|
||||||
|
|||||||
@@ -145,10 +145,10 @@ static const CGFloat kInnerPadding = 10.0f;
|
|||||||
{
|
{
|
||||||
// Set an intrinsic size for the image node
|
// Set an intrinsic size for the image node
|
||||||
CGSize imageSize = _isImageEnlarged ? CGSizeMake(2.0 * kImageSize, 2.0 * kImageSize) : CGSizeMake(kImageSize, kImageSize);
|
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
|
// Shrink the text node in case the image + text gonna be too wide
|
||||||
_textNode.flexShrink = YES;
|
_textNode.style.flexShrink = YES;
|
||||||
|
|
||||||
// Configure stack
|
// Configure stack
|
||||||
ASStackLayoutSpec *stackLayoutSpec =
|
ASStackLayoutSpec *stackLayoutSpec =
|
||||||
|
|||||||
@@ -61,8 +61,8 @@
|
|||||||
children:@[_iconNode, _countNode]];
|
children:@[_iconNode, _countNode]];
|
||||||
|
|
||||||
// Adjust size
|
// Adjust size
|
||||||
mainStack.minWidth = ASDimensionMakeWithPoints(60.0);
|
mainStack.style.minWidth = ASDimensionMakeWithPoints(60.0);
|
||||||
mainStack.maxHeight = ASDimensionMakeWithPoints(40.0);
|
mainStack.style.maxHeight = ASDimensionMakeWithPoints(40.0);
|
||||||
|
|
||||||
return mainStack;
|
return mainStack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,8 @@
|
|||||||
alignItems:ASStackLayoutAlignItemsCenter
|
alignItems:ASStackLayoutAlignItemsCenter
|
||||||
children:@[_iconNode, _countNode]];
|
children:@[_iconNode, _countNode]];
|
||||||
|
|
||||||
mainStack.minWidth = ASDimensionMakeWithPoints(60.0);
|
mainStack.style.minWidth = ASDimensionMakeWithPoints(60.0);
|
||||||
mainStack.maxHeight = ASDimensionMakeWithPoints(40.0);
|
mainStack.style.maxHeight = ASDimensionMakeWithPoints(40.0);
|
||||||
|
|
||||||
return mainStack;
|
return mainStack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,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.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.truncationMode = NSLineBreakByTruncatingTail;
|
||||||
_usernameNode.maximumNumberOfLines = 1;
|
_usernameNode.maximumNumberOfLines = 1;
|
||||||
[self addSubnode:_usernameNode];
|
[self addSubnode:_usernameNode];
|
||||||
@@ -137,8 +137,8 @@
|
|||||||
// User pic
|
// User pic
|
||||||
_avatarNode = [[ASNetworkImageNode alloc] init];
|
_avatarNode = [[ASNetworkImageNode alloc] init];
|
||||||
_avatarNode.backgroundColor = ASDisplayNodeDefaultPlaceholderColor();
|
_avatarNode.backgroundColor = ASDisplayNodeDefaultPlaceholderColor();
|
||||||
_avatarNode.width = ASDimensionMakeWithPoints(44);
|
_avatarNode.style.width = ASDimensionMakeWithPoints(44);
|
||||||
_avatarNode.height = ASDimensionMakeWithPoints(44);
|
_avatarNode.style.height = ASDimensionMakeWithPoints(44);
|
||||||
_avatarNode.cornerRadius = 22.0;
|
_avatarNode.cornerRadius = 22.0;
|
||||||
_avatarNode.URL = [NSURL URLWithString:_post.photo];
|
_avatarNode.URL = [NSURL URLWithString:_post.photo];
|
||||||
_avatarNode.imageModificationBlock = ^UIImage *(UIImage *image) {
|
_avatarNode.imageModificationBlock = ^UIImage *(UIImage *image) {
|
||||||
@@ -211,7 +211,7 @@
|
|||||||
{
|
{
|
||||||
// Flexible spacer between username and time
|
// Flexible spacer between username and time
|
||||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
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
|
// 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.
|
||||||
@@ -235,7 +235,7 @@
|
|||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsCenter
|
alignItems:ASStackLayoutAlignItemsCenter
|
||||||
children:layoutSpecChildren];
|
children:layoutSpecChildren];
|
||||||
nameStack.alignSelf = ASStackLayoutAlignSelfStretch;
|
nameStack.style.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||||
|
|
||||||
// bottom controls horizontal stack
|
// bottom controls horizontal stack
|
||||||
ASStackLayoutSpec *controlsStack =
|
ASStackLayoutSpec *controlsStack =
|
||||||
@@ -247,8 +247,8 @@
|
|||||||
children:@[_likesNode, _commentsNode, _optionsNode]];
|
children:@[_likesNode, _commentsNode, _optionsNode]];
|
||||||
|
|
||||||
// Add more gaps for control line
|
// Add more gaps for control line
|
||||||
controlsStack.spacingAfter = 3.0;
|
controlsStack.style.spacingAfter = 3.0;
|
||||||
controlsStack.spacingBefore = 3.0;
|
controlsStack.style.spacingBefore = 3.0;
|
||||||
|
|
||||||
NSMutableArray *mainStackContent = [[NSMutableArray alloc] init];
|
NSMutableArray *mainStackContent = [[NSMutableArray alloc] init];
|
||||||
[mainStackContent addObject:nameStack];
|
[mainStackContent addObject:nameStack];
|
||||||
@@ -264,8 +264,8 @@
|
|||||||
[ASRatioLayoutSpec
|
[ASRatioLayoutSpec
|
||||||
ratioLayoutSpecWithRatio:imageRatio
|
ratioLayoutSpecWithRatio:imageRatio
|
||||||
child:_mediaNode];
|
child:_mediaNode];
|
||||||
imagePlace.spacingAfter = 3.0;
|
imagePlace.style.spacingAfter = 3.0;
|
||||||
imagePlace.spacingBefore = 3.0;
|
imagePlace.style.spacingBefore = 3.0;
|
||||||
|
|
||||||
[mainStackContent addObject:imagePlace];
|
[mainStackContent addObject:imagePlace];
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@
|
|||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsStretch
|
alignItems:ASStackLayoutAlignItemsStretch
|
||||||
children:mainStackContent];
|
children:mainStackContent];
|
||||||
contentSpec.flexShrink = YES;
|
contentSpec.style.flexShrink = YES;
|
||||||
|
|
||||||
// Horizontal spec for avatar
|
// Horizontal spec for avatar
|
||||||
ASStackLayoutSpec *avatarContentSpec =
|
ASStackLayoutSpec *avatarContentSpec =
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
- (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init];
|
RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init];
|
||||||
[elementNode setSizeWithCGSize:_elementSize];
|
[elementNode.style setSizeWithCGSize:_elementSize];
|
||||||
elementNode.indexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:_pageNumber];
|
elementNode.indexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:_pageNumber];
|
||||||
return elementNode;
|
return elementNode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
CGSize boundsSize = pagerNode.bounds.size;
|
CGSize boundsSize = pagerNode.bounds.size;
|
||||||
CGSize gradientRowSize = CGSizeMake(boundsSize.width, 100);
|
CGSize gradientRowSize = CGSizeMake(boundsSize.width, 100);
|
||||||
GradientTableNode *node = [[GradientTableNode alloc] initWithElementSize:gradientRowSize];
|
GradientTableNode *node = [[GradientTableNode alloc] initWithElementSize:gradientRowSize];
|
||||||
[node setSizeWithCGSize:boundsSize];
|
[node.style setSizeWithCGSize:boundsSize];
|
||||||
node.pageNumber = index;
|
node.pageNumber = index;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user