mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
[Layout] Add helper properties for setting sizes via CGSize and ASRelativeSize (#2324)
* Remove set layout style size helper * Update API to set and get a CGSize / ASRelativeSize from an ASLayoutElementStyle - Expose ASRelativeSize type - Add new helper properties to set a size / relative size to ASLayoutElementStyle - Don't expose the size in ASLayoutElementStyle anymore and move into ASLayoutElementStylePrivate * Update examples * Update comments for size helpers
This commit is contained in:
committed by
Adlai Holler
parent
f027a8be80
commit
d6e5e27c39
@@ -208,7 +208,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
||||
|
||||
CGSize imageNetworkImageNodeSize = (CGSize){imageNode.image.size.width / 7, imageNode.image.size.height / 7};
|
||||
|
||||
[imageNode.style setSizeWithCGSize:imageNetworkImageNodeSize];
|
||||
imageNode.style.preferredSize = 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.style setSizeWithCGSize:imageNetworkImageNodeSize];
|
||||
networkImageNode.style.preferredSize = 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.style setSizeWithCGSize:CGSizeMake(300.0, 300.0)];
|
||||
mapNode.style.preferredSize = 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.style setSizeWithCGSize:CGSizeMake(300.0, 400.0)];
|
||||
videoNode.style.preferredSize = 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.style setSizeWithCGSize:CGSizeMake(300.0, 400.0)];
|
||||
scrollNode.style.preferredSize = CGSizeMake(300.0, 400.0);
|
||||
|
||||
UIScrollView *scrollNodeView = scrollNode.view;
|
||||
[scrollNodeView addSubview:[[UIImageView alloc] initWithImage:scrollNodeImage]];
|
||||
@@ -406,17 +406,17 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
||||
|
||||
#pragma mark Horizontal ASStackLayoutSpec
|
||||
childNode1 = [ASDisplayNode new];
|
||||
[childNode1.style setSizeWithCGSize:CGSizeMake(10.0, 20.0)];
|
||||
childNode1.style.preferredSize = CGSizeMake(10.0, 20.0);
|
||||
childNode1.style.flexGrow = YES;
|
||||
childNode1.backgroundColor = [UIColor greenColor];
|
||||
|
||||
childNode2 = [ASDisplayNode new];
|
||||
[childNode2.style setSizeWithCGSize:CGSizeMake(10.0, 20.0)];
|
||||
childNode2.style.preferredSize = CGSizeMake(10.0, 20.0);
|
||||
childNode2.style.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||
childNode2.backgroundColor = [UIColor blueColor];
|
||||
|
||||
childNode3 = [ASDisplayNode new];
|
||||
[childNode3.style setSizeWithCGSize:CGSizeMake(10.0, 20.0)];
|
||||
childNode3.style.preferredSize = CGSizeMake(10.0, 20.0);
|
||||
childNode3.backgroundColor = [UIColor yellowColor];
|
||||
|
||||
parentNode = [self parentNodeWithChild:childNode];
|
||||
@@ -467,7 +467,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
||||
- (OverviewDisplayNodeWithSizeBlock *)parentNodeWithChild:(ASDisplayNode *)child
|
||||
{
|
||||
OverviewDisplayNodeWithSizeBlock *parentNode = [OverviewDisplayNodeWithSizeBlock new];
|
||||
[parentNode.style setSizeWithCGSize:CGSizeMake(100, 100)];
|
||||
parentNode.style.preferredSize = 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.style setSizeWithCGSize:CGSizeMake(50, 50)];
|
||||
childNode.style.preferredSize = CGSizeMake(50, 50);
|
||||
childNode.backgroundColor = [UIColor blueColor];
|
||||
return childNode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user