iOS run snake

This commit is contained in:
pengfei.zhou
2019-07-31 19:22:00 +08:00
parent 5c1fc624ce
commit 2e7814b499
6 changed files with 350 additions and 328 deletions

View File

@@ -28,7 +28,7 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
NSInteger i;
for (i = 0; i< array.count; i++) {
NSDictionary *val = array[i];
if (!val) {
if (!val || (NSNull *)val == [NSNull null]) {
continue;
}
NSString *type = [val objectForKey:@"type"];

View File

@@ -11,8 +11,18 @@
#import "DoricRootNode.h"
#import "DoricConstant.h"
@interface DoricViewNode()
@property (nonatomic,strong) NSMutableDictionary *callbackIds;
@end
@implementation DoricViewNode
- (instancetype)initWithContext:(DoricContext *)doricContext {
if(self = [super initWithContext:doricContext]) {
_callbackIds = [[NSMutableDictionary alloc] init];
}
return self;
}
- (UIView *)build:(NSDictionary *)props {
return [[UIView alloc] init];
}
@@ -54,11 +64,20 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
if(self.parent && [prop isKindOfClass:[NSDictionary class]]){
[self.parent blendChild:self layoutConfig:prop];
}
} else {
} else if([name isEqualToString:@"onClick"]) {
[self.callbackIds setObject:prop forKey:@"onClick"];
view.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClick:)];
[view addGestureRecognizer:tapGesturRecognizer];
}else {
DoricLog(@"Blend View error for View Type :%@, prop is %@", self.class, name);
}
}
- (void)onClick:(UIView *)view {
[self callJSResponse:[self.callbackIds objectForKey:@"onClick"],nil];
}
- (CGFloat)measuredWidth {
if ([self.layoutParams isKindOfClass: MarginLayoutParams.class]) {
MarginLayoutParams *marginParams = (MarginLayoutParams *)self.layoutParams;
@@ -91,7 +110,7 @@ - (void)layoutByParent:(DoricGroupNode *)parent {
node = node.parent;
} while (node && ![node isKindOfClass:[DoricRootNode class]]);
return ret;
return [[ret reverseObjectEnumerator] allObjects];
}
- (void)callJSResponse:(NSString *)funcId,... {