remove _child from ASLayoutSpec.mm. Store all children in the children array.

This commit is contained in:
ricky
2016-05-25 13:30:35 -07:00
parent c42b0dd33a
commit bebc4c604c
8 changed files with 3 additions and 50 deletions

View File

@@ -68,9 +68,4 @@ static NSString * const kBackgroundChildKey = @"kBackgroundChildKey";
return [super childForIdentifier:kBackgroundChildKey];
}
- (void)setChildren:(NSArray *)children
{
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
}
@end

View File

@@ -115,9 +115,4 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner)
return [ASLayout layoutWithLayoutableObject:self size:computedSize sublayouts:@[sublayout]];
}
- (void)setChildren:(NSArray *)children
{
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
}
@end

View File

@@ -26,7 +26,6 @@
ASEnvironmentState _environmentState;
ASDN::RecursiveMutex _propertyLock;
id<ASLayoutable> _child;
NSArray *_children;
NSMutableDictionary *_childrenWithIdentifier;
}
@@ -118,7 +117,7 @@
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
id<ASLayoutable> finalLayoutable = [self layoutableToAddFromLayoutable:child];
_child = finalLayoutable;
_children = @[finalLayoutable];
[self propagateUpLayoutable:finalLayoutable];
}
@@ -128,6 +127,7 @@
id<ASLayoutable> finalLayoutable = [self layoutableToAddFromLayoutable:child];
self.childrenWithIdentifier[identifier] = finalLayoutable;
self.children = [self.children arrayByAddingObject:finalLayoutable];
// TODO: Should we propagate up the layoutable at it could happen that multiple children will propagated up their
// layout options and one child will overwrite values from another child
@@ -156,7 +156,7 @@
- (id<ASLayoutable>)child
{
return _child;
return [_children firstObject];
}
- (NSArray *)children

View File

@@ -61,11 +61,6 @@ static NSString * const kOverlayChildKey = @"kOverlayChildKey";
return [ASLayout layoutWithLayoutableObject:self size:contentsLayout.size sublayouts:sublayouts];
}
- (void)setChildren:(NSArray *)children
{
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
}
@end
@implementation ASOverlayLayoutSpec (Debugging)

View File

@@ -75,11 +75,6 @@
return [ASLayout layoutWithLayoutableObject:self size:sublayout.size sublayouts:@[sublayout]];
}
- (void)setChildren:(NSArray *)children
{
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
}
@end
@implementation ASRatioLayoutSpec (Debugging)

View File

@@ -92,11 +92,6 @@
return [ASLayout layoutWithLayoutableObject:self size:size sublayouts:@[sublayout]];
}
- (void)setChildren:(NSArray *)children
{
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
}
- (CGFloat)proportionOfAxisForAxisPosition:(ASRelativeLayoutSpecPosition)position
{
if ((position & ASRelativeLayoutSpecPositionCenter) != 0) {

View File

@@ -121,17 +121,6 @@
_baselineRelativeArrangement = baselineRelativeArrangement;
}
- (void)setChild:(id<ASLayoutable>)child forIdentifier:(NSString *)identifier
{
ASDisplayNodeAssert(NO, @"ASStackLayoutSpec only supports setChildren");
}
- (id<ASLayoutable>)childForIdentifier:(NSString *)identifier
{
ASDisplayNodeAssert(NO, @"ASStackLayoutSpec only supports children");
return nil;
}
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
{
if (self.children.count == 0) {

View File

@@ -72,17 +72,6 @@
sublayouts:sublayouts];
}
- (void)setChild:(id<ASLayoutable>)child forIdentifier:(NSString *)identifier
{
ASDisplayNodeAssert(NO, @"ASStaticLayoutSpec only supports setChildren");
}
- (id<ASLayoutable>)childForIdentifier:(NSString *)identifier
{
ASDisplayNodeAssert(NO, @"ASStaticLayoutSpec only supports children");
return nil;
}
@end
@implementation ASStaticLayoutSpec (ASEnvironment)