feat:fix iOS render weight prop

This commit is contained in:
pengfei.zhou 2019-11-16 16:49:42 +08:00
parent 3f4b336205
commit 1b08c227ef
4 changed files with 16 additions and 30 deletions

View File

@ -530,23 +530,3 @@ - (UIView *)viewWithTagString:(NSString *)tagString {
layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent]; layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent];
return layout; return layout;
} }
DoricVLayoutView *vLayoutWithBlock(NSArray <UIView *(^)()> *blocks) {
DoricVLayoutView *layout = [[DoricVLayoutView alloc] initWithFrame:CGRectZero];
UIView *(^block)();
for (block in blocks) {
[layout addSubview:block()];
}
layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent];
return layout;
}
DoricHLayoutView *hLayoutWithBlock(NSArray <UIView *(^)()> *blocks) {
DoricHLayoutView *layout = [[DoricHLayoutView alloc] initWithFrame:CGRectZero];
UIView *(^block)();
for (block in blocks) {
[layout addSubview:block()];
}
layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent];
return layout;
}

View File

@ -93,7 +93,10 @@ - (void)blendSubNode:(DoricViewNode *)subNode layoutConfig:(NSDictionary *)layou
if (alignment) { if (alignment) {
params.alignment = (DoricGravity) [alignment integerValue]; params.alignment = (DoricGravity) [alignment integerValue];
} }
NSNumber *weight = layoutConfig[@"weight"];
if (weight) {
params.weight = (DoricGravity) [weight integerValue];
}
} }
- (void)blendSubNode:(NSDictionary *)subModel { - (void)blendSubNode:(NSDictionary *)subModel {

View File

@ -39,15 +39,10 @@ - (void)blendView:(UILabel *)view forPropName:(NSString *)name propValue:(id)pro
} else if ([name isEqualToString:@"textAlignment"]) { } else if ([name isEqualToString:@"textAlignment"]) {
DoricGravity gravity = (DoricGravity) [(NSNumber *) prop integerValue]; DoricGravity gravity = (DoricGravity) [(NSNumber *) prop integerValue];
NSTextAlignment alignment = NSTextAlignmentCenter; NSTextAlignment alignment = NSTextAlignmentCenter;
switch (gravity) { if ((gravity & LEFT) == LEFT) {
case LEFT: alignment = NSTextAlignmentLeft;
alignment = NSTextAlignmentLeft; } else if ((gravity & RIGHT) == RIGHT) {
break; alignment = NSTextAlignmentRight;
case RIGHT:
alignment = NSTextAlignmentRight;
break;
default:
break;
} }
view.textAlignment = alignment; view.textAlignment = alignment;
} else { } else {

View File

@ -20,6 +20,10 @@ import { IList, List } from './listview'
export function text(config: IText) { export function text(config: IText) {
const ret = new Text const ret = new Text
ret.layoutConfig = {
widthSpec: LayoutSpec.WRAP_CONTENT,
heightSpec: LayoutSpec.WRAP_CONTENT,
}
for (let key in config) { for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret) Reflect.set(ret, key, Reflect.get(config, key, config), ret)
} }
@ -28,6 +32,10 @@ export function text(config: IText) {
export function image(config: IImage) { export function image(config: IImage) {
const ret = new Image const ret = new Image
ret.layoutConfig = {
widthSpec: LayoutSpec.WRAP_CONTENT,
heightSpec: LayoutSpec.WRAP_CONTENT,
}
for (let key in config) { for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret) Reflect.set(ret, key, Reflect.get(config, key, config), ret)
} }