mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Remove ASLayoutChild. ASLayout now has a position property defaults to (NAN, NAN).
This commit is contained in:
@@ -9,39 +9,53 @@
|
||||
*/
|
||||
|
||||
#import "ASLayout.h"
|
||||
#import "ASAssert.h"
|
||||
|
||||
CGPoint const CGPointNull = {NAN, NAN};
|
||||
|
||||
extern BOOL CGPointIsNull(CGPoint point)
|
||||
{
|
||||
return isnan(point.x) && isnan(point.y);
|
||||
}
|
||||
|
||||
@implementation ASLayout
|
||||
|
||||
+ (instancetype)newWithLayoutableObject:(id<ASLayoutable>)layoutableObject
|
||||
size:(CGSize)size
|
||||
position:(CGPoint)position
|
||||
children:(NSArray *)children
|
||||
{
|
||||
for (ASLayout *child in children) {
|
||||
ASDisplayNodeAssert(!CGPointIsNull(child.position), @"Invalid position is not allowed in children.");
|
||||
}
|
||||
|
||||
ASLayout *l = [super new];
|
||||
if (l) {
|
||||
l->_layoutableObject = layoutableObject;
|
||||
l->_size = size;
|
||||
l->_position = position;
|
||||
l->_children = [children copy];
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
+ (instancetype)newWithLayoutableObject:(id<ASLayoutable>)layoutableObject
|
||||
size:(CGSize)size
|
||||
children:(NSArray *)children
|
||||
{
|
||||
return [self newWithLayoutableObject:layoutableObject size:size position:CGPointNull children:children];
|
||||
}
|
||||
|
||||
+ (instancetype)newWithLayoutableObject:(id<ASLayoutable>)layoutableObject size:(CGSize)size
|
||||
{
|
||||
return [self newWithLayoutableObject:layoutableObject size:size children:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation ASLayoutChild
|
||||
|
||||
+ (instancetype)newWithPosition:(CGPoint)position layout:(ASLayout *)layout
|
||||
- (void)setPosition:(CGPoint)position
|
||||
{
|
||||
ASLayoutChild *c = [super new];
|
||||
if (c) {
|
||||
c->_position = position;
|
||||
c->_layout = layout;
|
||||
}
|
||||
return c;
|
||||
ASDisplayNodeAssert(CGPointIsNull(_position), @"Position can be set once and only once.");
|
||||
ASDisplayNodeAssert(!CGPointIsNull(position), @"Position must not be set to null.");
|
||||
_position = position;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user