mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-07 05:02:56 +00:00
addressed comments and fixed tests
This commit is contained in:
parent
c06a6be188
commit
680305704a
@ -25,12 +25,13 @@
|
|||||||
|
|
||||||
- (instancetype)initWithChild:(id<ASLayoutable>)child background:(id<ASLayoutable>)background
|
- (instancetype)initWithChild:(id<ASLayoutable>)child background:(id<ASLayoutable>)background
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (!(self = [super init])) {
|
||||||
if (self) {
|
return nil;
|
||||||
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
|
|
||||||
_child = child;
|
|
||||||
_background = background;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
|
||||||
|
_child = child;
|
||||||
|
_background = background;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,13 +24,13 @@
|
|||||||
sizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions
|
sizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions
|
||||||
child:(id<ASLayoutable>)child;
|
child:(id<ASLayoutable>)child;
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (!(self = [super init])) {
|
||||||
if (self) {
|
return nil;
|
||||||
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
|
|
||||||
_centeringOptions = centeringOptions;
|
|
||||||
_sizingOptions = sizingOptions;
|
|
||||||
_child = child;
|
|
||||||
}
|
}
|
||||||
|
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
|
||||||
|
_centeringOptions = centeringOptions;
|
||||||
|
_sizingOptions = sizingOptions;
|
||||||
|
_child = child;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner)
|
|||||||
|
|
||||||
- (instancetype)initWithInsets:(UIEdgeInsets)insets child:(id<ASLayoutable>)child;
|
- (instancetype)initWithInsets:(UIEdgeInsets)insets child:(id<ASLayoutable>)child;
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (!(self = [super init])) {
|
||||||
if (self) {
|
return nil;
|
||||||
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
|
|
||||||
_insets = insets;
|
|
||||||
_child = child;
|
|
||||||
}
|
}
|
||||||
|
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
|
||||||
|
_insets = insets;
|
||||||
|
_child = child;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@
|
|||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (!(self = [super init])) {
|
||||||
if (self) {
|
return nil;
|
||||||
_flexBasis = ASRelativeDimensionUnconstrained;
|
|
||||||
_isMutable = YES;
|
|
||||||
}
|
}
|
||||||
|
_flexBasis = ASRelativeDimensionUnconstrained;
|
||||||
|
_isMutable = YES;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,6 @@
|
|||||||
@property (nonatomic, strong) id<ASLayoutable> child;
|
@property (nonatomic, strong) id<ASLayoutable> child;
|
||||||
@property (nonatomic, strong) id<ASLayoutable> overlay;
|
@property (nonatomic, strong) id<ASLayoutable> overlay;
|
||||||
|
|
||||||
+ (instancetype)overlayLayoutWithChild:(id<ASLayoutable>)child overlay:(id<ASLayoutable>)overlay;
|
+ (instancetype)overlayLayoutSpecWithChild:(id<ASLayoutable>)child overlay:(id<ASLayoutable>)overlay;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -22,16 +22,16 @@
|
|||||||
|
|
||||||
- (instancetype)initWithChild:(id<ASLayoutable>)child overlay:(id<ASLayoutable>)overlay
|
- (instancetype)initWithChild:(id<ASLayoutable>)child overlay:(id<ASLayoutable>)overlay
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (!(self = [super init])) {
|
||||||
if (self) {
|
return nil;
|
||||||
ASDisplayNodeAssertNotNil(child, @"Child that will be overlayed on shouldn't be nil");
|
|
||||||
_overlay = overlay;
|
|
||||||
_child = child;
|
|
||||||
}
|
}
|
||||||
|
ASDisplayNodeAssertNotNil(child, @"Child that will be overlayed on shouldn't be nil");
|
||||||
|
_overlay = overlay;
|
||||||
|
_child = child;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (instancetype)overlayLayoutWithChild:(id<ASLayoutable>)child overlay:(id<ASLayoutable>)overlay
|
+ (instancetype)overlayLayoutSpecWithChild:(id<ASLayoutable>)child overlay:(id<ASLayoutable>)overlay
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithChild:child overlay:overlay];
|
return [[self alloc] initWithChild:child overlay:overlay];
|
||||||
}
|
}
|
||||||
|
@ -32,13 +32,13 @@
|
|||||||
|
|
||||||
- (instancetype)initWithRatio:(CGFloat)ratio child:(id<ASLayoutable>)child;
|
- (instancetype)initWithRatio:(CGFloat)ratio child:(id<ASLayoutable>)child;
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (!(self = [super init])) {
|
||||||
if (self) {
|
return nil;
|
||||||
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
|
|
||||||
ASDisplayNodeAssert(ratio > 0, @"Ratio should be strictly positive, but received %f", ratio);
|
|
||||||
_ratio = ratio;
|
|
||||||
_child = child;
|
|
||||||
}
|
}
|
||||||
|
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
|
||||||
|
ASDisplayNodeAssert(ratio > 0, @"Ratio should be strictly positive, but received %f", ratio);
|
||||||
|
_ratio = ratio;
|
||||||
|
_child = child;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,15 +85,13 @@ typedef NS_ENUM(NSUInteger, ASStackLayoutAlignItems) {
|
|||||||
- (instancetype)init;
|
- (instancetype)init;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param style Specifies how children are laid out.
|
@param direction The direction of the stack view (horizontal or vertical)
|
||||||
|
@param spacing The spacing between the children
|
||||||
|
@param justifyContent If no children are flexible, this describes how to fill any extra space
|
||||||
|
@param alignItems Orientation of the children along the cross axis
|
||||||
@param children ASLayoutable children to be positioned.
|
@param children ASLayoutable children to be positioned.
|
||||||
*/
|
*/
|
||||||
+ (instancetype)satckLayoutSpecWithDirection:(ASStackLayoutDirection)direction
|
+ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray *)children;
|
||||||
spacing:(CGFloat)spacing
|
|
||||||
contentJustification:(ASStackLayoutJustifyContent)justifyContent
|
|
||||||
itemAlignment:(ASStackLayoutAlignItems)alignItems
|
|
||||||
children:(NSArray *)children;
|
|
||||||
|
|
||||||
|
|
||||||
- (void)addChild:(id<ASLayoutable>)child;
|
- (void)addChild:(id<ASLayoutable>)child;
|
||||||
- (void)addChildren:(NSArray *)children;
|
- (void)addChildren:(NSArray *)children;
|
||||||
|
@ -28,43 +28,27 @@
|
|||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
return [self initWithDirection:ASStackLayoutDirectionHorizontal
|
return [self initWithDirection:ASStackLayoutDirectionHorizontal spacing:0.0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:nil];
|
||||||
spacing:0.0
|
|
||||||
contentJustification:ASStackLayoutJustifyContentStart
|
|
||||||
itemAlignment:ASStackLayoutAlignItemsStart
|
|
||||||
children:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (instancetype)satckLayoutSpecWithDirection:(ASStackLayoutDirection)direction
|
+ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray *)children
|
||||||
spacing:(CGFloat)spacing
|
|
||||||
contentJustification:(ASStackLayoutJustifyContent)justifyContent
|
|
||||||
itemAlignment:(ASStackLayoutAlignItems)alignItems
|
|
||||||
children:(NSArray *)children
|
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithDirection:direction
|
return [[self alloc] initWithDirection:direction spacing:spacing justifyContent:justifyContent alignItems:alignItems children:children];
|
||||||
spacing:spacing
|
|
||||||
contentJustification:justifyContent
|
|
||||||
itemAlignment:alignItems
|
|
||||||
children:children];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithDirection:(ASStackLayoutDirection)direction
|
- (instancetype)initWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray *)children
|
||||||
spacing:(CGFloat)spacing
|
|
||||||
contentJustification:(ASStackLayoutJustifyContent)justifyContent
|
|
||||||
itemAlignment:(ASStackLayoutAlignItems)alignItems
|
|
||||||
children:(NSArray *)children;
|
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (!(self = [super init])) {
|
||||||
if (self) {
|
return nil;
|
||||||
_direction = direction;
|
}
|
||||||
_alignItems = alignItems;
|
_direction = direction;
|
||||||
_spacing = spacing;
|
_alignItems = alignItems;
|
||||||
_justifyContent = justifyContent;
|
_spacing = spacing;
|
||||||
|
_justifyContent = justifyContent;
|
||||||
_children = std::vector<id<ASLayoutable>>();
|
|
||||||
for (id<ASLayoutable> child in children) {
|
_children = std::vector<id<ASLayoutable>>();
|
||||||
_children.push_back(child);
|
for (id<ASLayoutable> child in children) {
|
||||||
}
|
_children.push_back(child);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -82,7 +66,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)setDirection:(ASStackLayoutDirection)direction
|
- (void)setDirection:(ASStackLayoutDirection)direction
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
|
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
|
||||||
@ -109,11 +92,7 @@
|
|||||||
|
|
||||||
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
|
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
ASStackLayoutSpecStyle style = {.direction = _direction,
|
ASStackLayoutSpecStyle style = {.direction = _direction, .spacing = _spacing, .justifyContent = _justifyContent, .alignItems = _alignItems};
|
||||||
.spacing = _spacing,
|
|
||||||
.justifyContent = _justifyContent,
|
|
||||||
.alignItems = _alignItems
|
|
||||||
};
|
|
||||||
const auto unpositionedLayout = ASStackUnpositionedLayout::compute(_children, style, constrainedSize);
|
const auto unpositionedLayout = ASStackUnpositionedLayout::compute(_children, style, constrainedSize);
|
||||||
const auto positionedLayout = ASStackPositionedLayout::compute(unpositionedLayout, style, constrainedSize);
|
const auto positionedLayout = ASStackPositionedLayout::compute(unpositionedLayout, style, constrainedSize);
|
||||||
const CGSize finalSize = directionSize(style.direction, unpositionedLayout.stackDimensionSum, positionedLayout.crossSize);
|
const CGSize finalSize = directionSize(style.direction, unpositionedLayout.stackDimensionSum, positionedLayout.crossSize);
|
||||||
|
@ -46,10 +46,10 @@
|
|||||||
|
|
||||||
- (instancetype)initWithChildren:(NSArray *)children
|
- (instancetype)initWithChildren:(NSArray *)children
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (!(self = [super init])) {
|
||||||
if (self) {
|
return nil;
|
||||||
_children = children;
|
|
||||||
}
|
}
|
||||||
|
_children = children;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ static const ASSizeRange kSize = {{100, 120}, {320, 160}};
|
|||||||
|
|
||||||
ASLayoutSpec *layoutSpec =
|
ASLayoutSpec *layoutSpec =
|
||||||
[ASBackgroundLayoutSpec
|
[ASBackgroundLayoutSpec
|
||||||
newWithChild:
|
backgroundLayoutSpecWithChild:
|
||||||
[ASCenterLayoutSpec
|
[ASCenterLayoutSpec
|
||||||
newWithCenteringOptions:options
|
centerLayoutSpecWithCenteringOptions:options
|
||||||
sizingOptions:sizingOptions
|
sizingOptions:sizingOptions
|
||||||
child:foregroundNode]
|
child:foregroundNode]
|
||||||
background:backgroundNode];
|
background:backgroundNode];
|
||||||
@ -98,11 +98,11 @@ static NSString *suffixForCenteringOptions(ASCenterLayoutSpecCenteringOptions ce
|
|||||||
|
|
||||||
ASCenterLayoutSpec *layoutSpec =
|
ASCenterLayoutSpec *layoutSpec =
|
||||||
[ASCenterLayoutSpec
|
[ASCenterLayoutSpec
|
||||||
newWithCenteringOptions:ASCenterLayoutSpecCenteringNone
|
centerLayoutSpecWithCenteringOptions:ASCenterLayoutSpecCenteringNone
|
||||||
sizingOptions:{}
|
sizingOptions:{}
|
||||||
child:
|
child:
|
||||||
[ASBackgroundLayoutSpec
|
[ASBackgroundLayoutSpec
|
||||||
newWithChild:[ASStackLayoutSpec newWithStyle:{} children:@[foregroundNode]]
|
backgroundLayoutSpecWithChild:[ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:@[foregroundNode]]
|
||||||
background:backgroundNode]];
|
background:backgroundNode]];
|
||||||
|
|
||||||
[self testLayoutSpec:layoutSpec sizeRange:kSize subnodes:@[backgroundNode, foregroundNode] identifier:nil];
|
[self testLayoutSpec:layoutSpec sizeRange:kSize subnodes:@[backgroundNode, foregroundNode] identifier:nil];
|
||||||
|
@ -61,7 +61,7 @@ static NSString *nameForInsets(UIEdgeInsets insets)
|
|||||||
|
|
||||||
ASLayoutSpec *layoutSpec =
|
ASLayoutSpec *layoutSpec =
|
||||||
[ASBackgroundLayoutSpec
|
[ASBackgroundLayoutSpec
|
||||||
newWithChild:[ASInsetLayoutSpec newWithInsets:insets child:foregroundNode]
|
backgroundLayoutSpecWithChild:[ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:foregroundNode]
|
||||||
background:backgroundNode];
|
background:backgroundNode];
|
||||||
|
|
||||||
static ASSizeRange kVariableSize = {{0, 0}, {300, 300}};
|
static ASSizeRange kVariableSize = {{0, 0}, {300, 300}};
|
||||||
@ -82,7 +82,7 @@ static NSString *nameForInsets(UIEdgeInsets insets)
|
|||||||
|
|
||||||
ASLayoutSpec *layoutSpec =
|
ASLayoutSpec *layoutSpec =
|
||||||
[ASBackgroundLayoutSpec
|
[ASBackgroundLayoutSpec
|
||||||
newWithChild:[ASInsetLayoutSpec newWithInsets:insets child:foregroundNode]
|
backgroundLayoutSpecWithChild:[ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:foregroundNode]
|
||||||
background:backgroundNode];
|
background:backgroundNode];
|
||||||
|
|
||||||
static ASSizeRange kFixedSize = {{300, 300}, {300, 300}};
|
static ASSizeRange kFixedSize = {{300, 300}, {300, 300}};
|
||||||
@ -104,7 +104,7 @@ static NSString *nameForInsets(UIEdgeInsets insets)
|
|||||||
|
|
||||||
ASLayoutSpec *layoutSpec =
|
ASLayoutSpec *layoutSpec =
|
||||||
[ASBackgroundLayoutSpec
|
[ASBackgroundLayoutSpec
|
||||||
newWithChild:[ASInsetLayoutSpec newWithInsets:insets child:foregroundNode]
|
backgroundLayoutSpecWithChild:[ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:foregroundNode]
|
||||||
background:backgroundNode];
|
background:backgroundNode];
|
||||||
|
|
||||||
static ASSizeRange kFixedSize = {{300, 300}, {300, 300}};
|
static ASSizeRange kFixedSize = {{300, 300}, {300, 300}};
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
{
|
{
|
||||||
ASLayout *layout = [layoutSpecUnderTest measureWithSizeRange:sizeRange];
|
ASLayout *layout = [layoutSpecUnderTest measureWithSizeRange:sizeRange];
|
||||||
layout.position = CGPointZero;
|
layout.position = CGPointZero;
|
||||||
layout = [ASLayout newWithLayoutableObject:self size:layout.size sublayouts:@[layout]];
|
layout = [ASLayout layoutWithLayoutableObject:self size:layout.size sublayouts:@[layout]];
|
||||||
_layoutUnderTest = [layout flattenedLayoutUsingPredicateBlock:^BOOL(ASLayout *evaluatedLayout) {
|
_layoutUnderTest = [layout flattenedLayoutUsingPredicateBlock:^BOOL(ASLayout *evaluatedLayout) {
|
||||||
return [self.subnodes containsObject:evaluatedLayout.layoutableObject];
|
return [self.subnodes containsObject:evaluatedLayout.layoutableObject];
|
||||||
}];
|
}];
|
||||||
|
@ -34,10 +34,10 @@ static const ASSizeRange kSize = {{320, 320}, {320, 320}};
|
|||||||
|
|
||||||
ASLayoutSpec *layoutSpec =
|
ASLayoutSpec *layoutSpec =
|
||||||
[ASOverlayLayoutSpec
|
[ASOverlayLayoutSpec
|
||||||
newWithChild:backgroundNode
|
overlayLayoutSpecWithChild:backgroundNode
|
||||||
overlay:
|
overlay:
|
||||||
[ASCenterLayoutSpec
|
[ASCenterLayoutSpec
|
||||||
newWithCenteringOptions:ASCenterLayoutSpecCenteringXY
|
centerLayoutSpecWithCenteringOptions:ASCenterLayoutSpecCenteringXY
|
||||||
sizingOptions:{}
|
sizingOptions:{}
|
||||||
child:foregroundNode]];
|
child:foregroundNode]];
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ static const ASSizeRange kFixedSize = {{0, 0}, {100, 100}};
|
|||||||
ASStaticSizeDisplayNode *subnode = ASDisplayNodeWithBackgroundColor([UIColor greenColor]);
|
ASStaticSizeDisplayNode *subnode = ASDisplayNodeWithBackgroundColor([UIColor greenColor]);
|
||||||
subnode.staticSize = childSize;
|
subnode.staticSize = childSize;
|
||||||
|
|
||||||
ASLayoutSpec *layoutSpec = [ASRatioLayoutSpec newWithRatio:ratio child:subnode];
|
ASLayoutSpec *layoutSpec = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:ratio child:subnode];
|
||||||
|
|
||||||
[self testLayoutSpec:layoutSpec sizeRange:kFixedSize subnodes:@[subnode] identifier:identifier];
|
[self testLayoutSpec:layoutSpec sizeRange:kFixedSize subnodes:@[subnode] identifier:identifier];
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#import "ASLayoutSpecSnapshotTestsHelper.h"
|
#import "ASLayoutSpecSnapshotTestsHelper.h"
|
||||||
|
|
||||||
#import "ASStackLayoutSpec.h"
|
#import "ASStackLayoutSpec.h"
|
||||||
|
#import "ASStackLayoutSpecUtilities.h"
|
||||||
#import "ASBackgroundLayoutSpec.h"
|
#import "ASBackgroundLayoutSpec.h"
|
||||||
#import "ASRatioLayoutSpec.h"
|
#import "ASRatioLayoutSpec.h"
|
||||||
#import "ASInsetLayoutSpec.h"
|
#import "ASInsetLayoutSpec.h"
|
||||||
@ -79,7 +80,7 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
|
|||||||
|
|
||||||
ASLayoutSpec *layoutSpec =
|
ASLayoutSpec *layoutSpec =
|
||||||
[ASBackgroundLayoutSpec
|
[ASBackgroundLayoutSpec
|
||||||
newWithChild:[ASStackLayoutSpec newWithStyle:style children:children]
|
backgroundLayoutSpecWithChild:[ASStackLayoutSpec stackLayoutSpecWithDirection:style.direction spacing:style.spacing justifyContent:style.justifyContent alignItems:style.alignItems children:children]
|
||||||
background:backgroundNode];
|
background:backgroundNode];
|
||||||
|
|
||||||
NSMutableArray *newSubnodes = [NSMutableArray arrayWithObject:backgroundNode];
|
NSMutableArray *newSubnodes = [NSMutableArray arrayWithObject:backgroundNode];
|
||||||
@ -179,17 +180,12 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
|
|||||||
|
|
||||||
ASLayoutSpec *layoutSpec =
|
ASLayoutSpec *layoutSpec =
|
||||||
[ASInsetLayoutSpec
|
[ASInsetLayoutSpec
|
||||||
newWithInsets:{10, 10, 10 ,10}
|
insetLayoutSpecWithInsets:{10, 10, 10 ,10}
|
||||||
child:
|
child:
|
||||||
[ASBackgroundLayoutSpec
|
[ASBackgroundLayoutSpec
|
||||||
newWithChild:
|
backgroundLayoutSpecWithChild:
|
||||||
[ASStackLayoutSpec
|
[ASStackLayoutSpec
|
||||||
newWithStyle:{
|
stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:10 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStretch children:@[]]
|
||||||
.direction = ASStackLayoutDirectionVertical,
|
|
||||||
.spacing = 10,
|
|
||||||
.alignItems = ASStackLayoutAlignItemsStretch
|
|
||||||
}
|
|
||||||
children:@[]]
|
|
||||||
background:backgroundNode]];
|
background:backgroundNode]];
|
||||||
|
|
||||||
// width 300px; height 0-300px
|
// width 300px; height 0-300px
|
||||||
@ -257,7 +253,7 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
|
|||||||
ASStaticSizeDisplayNode * subnode2 = ASDisplayNodeWithBackgroundColor([UIColor redColor]);
|
ASStaticSizeDisplayNode * subnode2 = ASDisplayNodeWithBackgroundColor([UIColor redColor]);
|
||||||
subnode2.staticSize = {50, 50};
|
subnode2.staticSize = {50, 50};
|
||||||
|
|
||||||
ASRatioLayoutSpec *child1 = [ASRatioLayoutSpec newWithRatio:1.5 child:subnode1];
|
ASRatioLayoutSpec *child1 = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:1.5 child:subnode1];
|
||||||
child1.flexBasis = ASRelativeDimensionMakeWithPercent(1);
|
child1.flexBasis = ASRelativeDimensionMakeWithPercent(1);
|
||||||
child1.flexGrow = YES;
|
child1.flexGrow = YES;
|
||||||
child1.flexShrink = YES;
|
child1.flexShrink = YES;
|
||||||
@ -481,7 +477,7 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
|
|||||||
((ASStaticSizeDisplayNode *)subnodes[1]).staticSize = {10, 0};
|
((ASStaticSizeDisplayNode *)subnodes[1]).staticSize = {10, 0};
|
||||||
((ASStaticSizeDisplayNode *)subnodes[2]).staticSize = {3000, 3000};
|
((ASStaticSizeDisplayNode *)subnodes[2]).staticSize = {3000, 3000};
|
||||||
|
|
||||||
ASRatioLayoutSpec *child2 = [ASRatioLayoutSpec newWithRatio:1.0 child:subnodes[2]];
|
ASRatioLayoutSpec *child2 = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:1.0 child:subnodes[2]];
|
||||||
child2.flexGrow = YES;
|
child2.flexGrow = YES;
|
||||||
child2.flexShrink = YES;
|
child2.flexShrink = YES;
|
||||||
|
|
||||||
@ -489,16 +485,12 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
|
|||||||
// Instead it should be stretched to 300 points tall, matching the red child and not overlapping the green inset.
|
// Instead it should be stretched to 300 points tall, matching the red child and not overlapping the green inset.
|
||||||
ASLayoutSpec *layoutSpec =
|
ASLayoutSpec *layoutSpec =
|
||||||
[ASBackgroundLayoutSpec
|
[ASBackgroundLayoutSpec
|
||||||
newWithChild:
|
backgroundLayoutSpecWithChild:
|
||||||
[ASInsetLayoutSpec
|
[ASInsetLayoutSpec
|
||||||
newWithInsets:UIEdgeInsetsMake(10, 10, 10, 10)
|
insetLayoutSpecWithInsets:UIEdgeInsetsMake(10, 10, 10, 10)
|
||||||
child:
|
child:
|
||||||
[ASStackLayoutSpec
|
[ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStretch children:@[subnodes[1], child2,]]
|
||||||
newWithStyle:{
|
]
|
||||||
.direction = ASStackLayoutDirectionHorizontal,
|
|
||||||
.alignItems = ASStackLayoutAlignItemsStretch,
|
|
||||||
}
|
|
||||||
children:@[subnodes[1], child2,]]]
|
|
||||||
background:subnodes[0]];
|
background:subnodes[0]];
|
||||||
|
|
||||||
static ASSizeRange kSize = {{300, 0}, {300, INFINITY}};
|
static ASSizeRange kSize = {{300, 0}, {300, INFINITY}};
|
||||||
|
@ -81,9 +81,8 @@ static NSString *kLinkAttributeName = @"PlaceKittenNodeLinkAttributeName";
|
|||||||
centerSpec.sizingOptions = ASCenterLayoutSpecSizingOptionMinimumY;
|
centerSpec.sizingOptions = ASCenterLayoutSpecSizingOptionMinimumY;
|
||||||
centerSpec.child = _textNode;
|
centerSpec.child = _textNode;
|
||||||
|
|
||||||
|
UIEdgeInsets padding =UIEdgeInsetsMake(kTextPadding, kTextPadding, kTextPadding, kTextPadding);
|
||||||
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(kTextPadding, kTextPadding, kTextPadding, kTextPadding)
|
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:padding child:centerSpec];
|
||||||
child:centerSpec];
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
- (CGSize)calculateSizeThatFits:(CGSize)constrainedSize
|
- (CGSize)calculateSizeThatFits:(CGSize)constrainedSize
|
||||||
|
Loading…
x
Reference in New Issue
Block a user