iOS render
This commit is contained in:
@@ -7,16 +7,12 @@
|
||||
|
||||
#import "DoricGroupNode.h"
|
||||
|
||||
@interface DoricGroupNode ()
|
||||
@property (nonatomic,strong) NSMutableArray *indexInfo;
|
||||
@end
|
||||
|
||||
@implementation DoricGroupNode
|
||||
|
||||
- (instancetype)init {
|
||||
if(self = [super init]) {
|
||||
_children = [[NSMutableDictionary alloc] init];
|
||||
_indexInfo = [[NSMutableArray alloc] init];
|
||||
_indexedChildren = [[NSMutableArray alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -52,18 +48,20 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
|
||||
params = [self generateDefaultLayoutParams];
|
||||
}
|
||||
[node blend:[val objectForKey:@"props"]];
|
||||
if ([self.indexInfo objectAtIndex:i] == nil) {
|
||||
if ([self.indexedChildren objectAtIndex:i] == nil) {
|
||||
[self.view insertSubview:node.view atIndex:i];
|
||||
[self.indexInfo setObject:node atIndexedSubscript:i];
|
||||
[self.indexedChildren setObject:node atIndexedSubscript:i];
|
||||
}
|
||||
}
|
||||
for (; i < self.view.subviews.count; i++) {
|
||||
|
||||
while (i < self.view.subviews.count) {
|
||||
[self.view.subviews[i] removeFromSuperview];
|
||||
DoricViewNode *node = [self.indexInfo objectAtIndex:i];
|
||||
DoricViewNode *node = [self.indexedChildren objectAtIndex:i];
|
||||
if (node != nil) {
|
||||
[self.children removeObjectForKey: node.viewId];
|
||||
[self.indexInfo removeObjectAtIndex:i];
|
||||
[self.indexedChildren removeObjectAtIndex:i];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
[super blendView:view forPropName:name propValue:prop];
|
||||
@@ -78,9 +76,12 @@ - (LayoutParams *)generateDefaultLayoutParams {
|
||||
- (void)blendChild:(DoricViewNode *)child layoutConfig:(NSDictionary *)layoutconfig {
|
||||
LayoutParams *params = child.layoutParams;
|
||||
NSDictionary *margin = [layoutconfig objectForKey:@"margin"];
|
||||
params.margin.top = [(NSNumber *)[margin objectForKey:@"top"] floatValue];
|
||||
params.margin.left = [(NSNumber *)[margin objectForKey:@"left"] floatValue];
|
||||
params.margin.right = [(NSNumber *)[margin objectForKey:@"right"] floatValue];
|
||||
params.margin.bottom = [(NSNumber *)[margin objectForKey:@"bottom"] floatValue];
|
||||
if (margin) {
|
||||
params.margin.top = [(NSNumber *)[margin objectForKey:@"top"] floatValue];
|
||||
params.margin.left = [(NSNumber *)[margin objectForKey:@"left"] floatValue];
|
||||
params.margin.right = [(NSNumber *)[margin objectForKey:@"right"] floatValue];
|
||||
params.margin.bottom = [(NSNumber *)[margin objectForKey:@"bottom"] floatValue];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user