feat:add Popover demo

This commit is contained in:
pengfei.zhou
2019-11-28 21:04:27 +08:00
parent 38a06c9658
commit a79e288679
9 changed files with 132 additions and 22 deletions

View File

@@ -24,7 +24,6 @@
#import "DoricLayouts.h"
#import "UIView+Doric.h"
NS_ASSUME_NONNULL_BEGIN
@class DoricSuperNode;
@interface DoricViewNode <V:UIView *> : DoricContextHolder
@@ -55,5 +54,3 @@ NS_ASSUME_NONNULL_BEGIN
- (void)requestLayout;
@end
NS_ASSUME_NONNULL_END

View File

@@ -126,6 +126,8 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
} else if ([name isEqualToString:@"layoutConfig"]) {
if (self.superNode && [prop isKindOfClass:[NSDictionary class]]) {
[self.superNode blendSubNode:self layoutConfig:prop];
} else {
[self blendLayoutConfig:prop];
}
} else if ([name isEqualToString:@"onClick"]) {
self.callbackIds[@"onClick"] = prop;
@@ -246,4 +248,36 @@ - (NSNumber *)getRotation {
return @(degree);
}
- (void)blendLayoutConfig:(NSDictionary *)params {
[params[@"widthSpec"] also:^(NSNumber *it) {
if (it) {
self.layoutConfig.widthSpec = (DoricLayoutSpec) [it integerValue];
}
}];
[params[@"heightSpec"] also:^(NSNumber *it) {
if (it) {
self.layoutConfig.heightSpec = (DoricLayoutSpec) [it integerValue];
}
}];
NSDictionary *margin = params[@"margin"];
if (margin) {
self.layoutConfig.margin = DoricMarginMake(
[(NSNumber *) margin[@"left"] floatValue],
[(NSNumber *) margin[@"top"] floatValue],
[(NSNumber *) margin[@"right"] floatValue],
[(NSNumber *) margin[@"bottom"] floatValue]);
}
NSNumber *alignment = params[@"alignment"];
if (alignment) {
self.layoutConfig.alignment = (DoricGravity) [alignment integerValue];
}
NSNumber *weight = params[@"weight"];
if (weight) {
self.layoutConfig.weight = (DoricGravity) [weight integerValue];
}
}
@end