iOS: fix blend viewModel error

This commit is contained in:
pengfei.zhou 2021-09-30 13:57:52 +08:00 committed by osborn
parent 46609aee4c
commit 9757a6e8c6

View File

@ -69,25 +69,24 @@ - (void)recursiveMixin:(NSDictionary *)srcModel to:(NSMutableDictionary *)target
NSDictionary *srcProp = srcModel[@"props"]; NSDictionary *srcProp = srcModel[@"props"];
NSMutableDictionary *targetProp = targetModel[@"props"]; NSMutableDictionary *targetProp = targetModel[@"props"];
NSMutableArray *targetOri = targetProp[@"subviews"]; NSMutableArray *targetOri = targetProp[@"subviews"];
NSArray *srcSubviews = srcProp[@"subviews"];
[srcProp enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) { if (srcSubviews && srcSubviews.count > 0) {
if ([@"subviews" isEqualToString:key]) { for (NSDictionary *subview in srcSubviews) {
NSArray *subviews = obj;
if (subviews) {
for (NSDictionary *subview in subviews) {
NSString *viewId = subview[@"id"]; NSString *viewId = subview[@"id"];
NSMutableArray *mutableTargetOri = [targetProp[@"subviews"] mutableCopy]; __block NSMutableDictionary *viewModel = nil;
[mutableTargetOri enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) { [targetOri enumerateObjectsUsingBlock:^(NSMutableDictionary *obj, NSUInteger idx, BOOL *stop) {
if ([viewId isEqualToString:obj[@"id"]]) { if ([viewId isEqualToString:obj[@"id"]]) {
NSMutableDictionary *mutableDictionary = [obj mutableCopy]; viewModel = obj;
[self recursiveMixin:subview to:mutableDictionary];
targetOri[idx] = [mutableDictionary copy];
*stop = YES; *stop = YES;
} }
}]; }];
if (viewModel) {
[self recursiveMixin:subview to:viewModel];
} }
} }
} else { }
[srcProp enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {
if (![@"subviews" isEqualToString:key]) {
targetProp[key] = obj; targetProp[key] = obj;
} }
}]; }];