feat:support alpha

This commit is contained in:
pengfei.zhou 2019-11-29 20:02:20 +08:00
parent e2df869b52
commit 7e8708a73b
3 changed files with 26 additions and 4 deletions

View File

@ -203,6 +203,17 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
prop.asObject().getProperty("color").asNumber().toInt());
}
break;
case "alpha":
if (isAnimating()) {
addAnimator(ObjectAnimator.ofFloat(
this,
name,
getAlpha(),
prop.asNumber().toFloat()));
} else {
setAlpha(prop.asNumber().toFloat());
}
break;
case "corners":
if (prop.isNumber()) {
if (isAnimating()) {
@ -518,6 +529,16 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
mView.setBackgroundColor(color);
}
@DoricMethod
public void setAlpha(float alpha) {
getNodeView().setAlpha(alpha);
}
@DoricMethod
public float getAlpha() {
return getNodeView().getAlpha();
}
@DoricMethod
public void setCorners(float corner) {
requireDoricLayer().setCornerRadius(DoricUtils.dp2px(corner));

View File

@ -150,6 +150,8 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
view.y = [(NSNumber *) prop floatValue];
} else if ([name isEqualToString:@"bgColor"]) {
view.backgroundColor = DoricColor(prop);
} else if ([name isEqualToString:@"alpha"]) {
view.alpha = [prop floatValue];
} else if ([name isEqualToString:@"layoutConfig"]) {
if (self.superNode && [prop isKindOfClass:[NSDictionary class]]) {
[self.superNode blendSubNode:self layoutConfig:prop];
@ -220,10 +222,6 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
self.pivotY = prop;
} else if ([name isEqualToString:@"rotation"]) {
self.rotation = prop;
} else if ([name isEqualToString:@"rotationX"]) {
self.rotationX = prop;
} else if ([name isEqualToString:@"rotationY"]) {
self.rotationY = prop;
} else {
DoricLog(@"Blend View error for View Type :%@, prop is %@", self.class, name);
}

View File

@ -31,6 +31,9 @@ export interface IView {
corners?: number | { leftTop?: number; rightTop?: number; leftBottom?: number; rightBottom?: number }
border?: { width: number; color: Color; }
shadow?: { color: Color; opacity: number; radius: number; offsetX: number; offsetY: number }
/**
* float [0,..1]
*/
alpha?: number
hidden?: boolean
padding?: {