iOS:refact requestLayout logic
This commit is contained in:
@@ -161,4 +161,9 @@ - (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)requestLayout {
|
||||
for (DoricViewNode *node in self.childNodes) {
|
||||
[node requestLayout];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
@@ -92,6 +92,8 @@ typedef NS_ENUM(NSInteger, DoricGravity) {
|
||||
|
||||
@property(nonatomic, assign) CGFloat maxHeight;
|
||||
|
||||
@property(nonatomic, assign) BOOL resolved;
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
- (void)apply;
|
||||
|
@@ -55,7 +55,6 @@ @interface DoricLayout ()
|
||||
@property(nonatomic, assign) CGFloat measuredHeight;
|
||||
@property(nonatomic, assign) CGFloat measuredX;
|
||||
@property(nonatomic, assign) CGFloat measuredY;
|
||||
@property(nonatomic, assign) BOOL resolved;
|
||||
@end
|
||||
|
||||
@implementation DoricLayout
|
||||
|
@@ -141,6 +141,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
|
||||
DoricListItemNode *node = cell.doricListItemNode;
|
||||
node.viewId = model[@"id"];
|
||||
[node blend:props];
|
||||
[node requestLayout];
|
||||
[self callItem:position height:node.view.height];
|
||||
return cell;
|
||||
}
|
||||
|
@@ -61,5 +61,6 @@ - (void)setupRootView:(UIView *)view {
|
||||
|
||||
- (void)requestLayout {
|
||||
[self.view.doricLayout apply];
|
||||
[super requestLayout];
|
||||
}
|
||||
@end
|
||||
|
@@ -37,7 +37,9 @@ - (void)setContentView:(UIView *)contentView {
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size {
|
||||
if (self.contentView) {
|
||||
[self.contentView.doricLayout apply:self.frame.size];
|
||||
if (!self.contentView.doricLayout.resolved) {
|
||||
[self.contentView.doricLayout apply:self.frame.size];
|
||||
}
|
||||
return self.contentView.frame.size;
|
||||
}
|
||||
return CGSizeZero;
|
||||
@@ -117,6 +119,10 @@ - (void)afterBlended:(NSDictionary *)props {
|
||||
}
|
||||
}
|
||||
|
||||
- (void)requestLayout {
|
||||
[self.view.contentView.doricLayout apply:self.view.frame.size];
|
||||
}
|
||||
|
||||
- (void)blendView:(DoricScrollView *)view forPropName:(NSString *)name propValue:(id)prop {
|
||||
if ([@"content" isEqualToString:name]) {
|
||||
self.childViewId = prop;
|
||||
|
@@ -127,8 +127,4 @@ - (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
|
||||
NSStringFromSelector(_cmd));
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)requestLayout {
|
||||
[self.view setNeedsLayout];
|
||||
}
|
||||
@end
|
||||
|
@@ -139,8 +139,7 @@ - (void)blend:(NSDictionary *)props {
|
||||
}
|
||||
[self afterBlended:props];
|
||||
[self transformProperties];
|
||||
[self requestLayout];
|
||||
[self.gradientLayer also:^(CAGradientLayer* it) {
|
||||
[self.gradientLayer also:^(CAGradientLayer *it) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
it.frame = CGRectMake(0, 0, self.view.width, self.view.height);
|
||||
});
|
||||
@@ -349,7 +348,6 @@ + (__kindof DoricViewNode *)create:(DoricContext *)context withType:(NSString *)
|
||||
}
|
||||
|
||||
- (void)requestLayout {
|
||||
[self.superNode requestLayout];
|
||||
}
|
||||
|
||||
- (NSNumber *)getWidth {
|
||||
|
Reference in New Issue
Block a user