feat:Aero add style property
This commit is contained in:
parent
cc014a6061
commit
f302592d11
@ -25,7 +25,7 @@ android {
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
buildJSBundle.exec()
|
||||
//buildJSBundle.exec()
|
||||
}
|
||||
|
||||
task buildJSBundle(type: Exec) {
|
||||
|
@ -19,7 +19,6 @@ import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
@ -44,6 +43,8 @@ public class AeroEffectView extends DoricLayer {
|
||||
private Bitmap mScaledBitmap = null;
|
||||
private Canvas mScaledCanvas = null;
|
||||
|
||||
private String mStyle = null;
|
||||
|
||||
public AeroEffectView(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
@ -54,6 +55,11 @@ public class AeroEffectView extends DoricLayer {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setStyle(String style) {
|
||||
this.mStyle = style;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
if (mFullBitmap == null
|
||||
@ -97,6 +103,11 @@ public class AeroEffectView extends DoricLayer {
|
||||
new Rect(0, 0, scaledWidth, scaledHeight),
|
||||
paint);
|
||||
blurredBitmap = DoricUtils.blur(getContext(), mScaledBitmap, radius);
|
||||
if ("dark".equals(mStyle)) {
|
||||
mScaledCanvas.drawColor(0x66000000, PorterDuff.Mode.SRC_OVER);
|
||||
} else if ("extraLight".equals(mStyle)) {
|
||||
mScaledCanvas.drawColor(0x99ffffff, PorterDuff.Mode.SRC_OVER);
|
||||
}
|
||||
if (mEffectiveRect != null) {
|
||||
mFullCanvas.save();
|
||||
mFullCanvas.clipRect(mEffectiveRect);
|
||||
|
@ -51,6 +51,12 @@ public class AeroEffectViewNode extends StackNode {
|
||||
int height = DoricUtils.dp2px(prop.asObject().getProperty("height").asNumber().toFloat());
|
||||
((AeroEffectView) view).setEffectiveRect(new Rect(x, y, x + width, y + height));
|
||||
}
|
||||
} else if ("style".equals(name)) {
|
||||
if(prop.isString()){
|
||||
((AeroEffectView) view).setStyle(prop.asString().value());
|
||||
}else{
|
||||
((AeroEffectView) view).setStyle(null);
|
||||
}
|
||||
} else {
|
||||
super.blend(view, name, prop);
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ @implementation DoricAeroEffectViewNode
|
||||
|
||||
- (UIView *)build {
|
||||
UIView *ret = [super build];
|
||||
UIVisualEffect *endEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
|
||||
self.visualEffectView = [[UIVisualEffectView alloc] initWithEffect:endEffect];
|
||||
UIVisualEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
|
||||
self.visualEffectView = [[UIVisualEffectView alloc] initWithEffect:effect];
|
||||
[ret addSubview:self.visualEffectView];
|
||||
self.visualEffectView.doricLayout.widthSpec = DoricLayoutMost;
|
||||
self.visualEffectView.doricLayout.heightSpec = DoricLayoutMost;
|
||||
@ -47,6 +47,15 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
|
||||
self.visualEffectView.doricLayout.height = height;
|
||||
self.visualEffectView.doricLayout.marginLeft = x;
|
||||
self.visualEffectView.doricLayout.marginTop = y;
|
||||
} else if ([name isEqualToString:@"style"]) {
|
||||
UIBlurEffectStyle style = UIBlurEffectStyleLight;
|
||||
if ([prop isEqualToString:@"dark"]) {
|
||||
style = UIBlurEffectStyleDark;
|
||||
} else if ([prop isEqualToString:@"extraLight"]) {
|
||||
style = UIBlurEffectStyleExtraLight;
|
||||
}
|
||||
UIVisualEffect *effect = [UIBlurEffect effectWithStyle:style];
|
||||
self.visualEffectView.effect = effect;
|
||||
} else {
|
||||
[super blendView:view forPropName:name propValue:prop];
|
||||
}
|
||||
|
@ -3643,6 +3643,10 @@ var AeroEffect = /** @class */ (function (_super) {
|
||||
Property,
|
||||
__metadata("design:type", Object)
|
||||
], AeroEffect.prototype, "effectiveRect", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", String)
|
||||
], AeroEffect.prototype, "style", void 0);
|
||||
return AeroEffect;
|
||||
}(Stack));
|
||||
function blurEffect(views, config) {
|
||||
|
@ -2748,6 +2748,10 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", Object)
|
||||
], AeroEffect.prototype, "effectiveRect", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", String)
|
||||
], AeroEffect.prototype, "style", void 0);
|
||||
function blurEffect(views, config) {
|
||||
const ret = new BlurEffect;
|
||||
ret.layoutConfig = layoutConfig().fit();
|
||||
|
@ -4269,6 +4269,10 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", Object)
|
||||
], AeroEffect.prototype, "effectiveRect", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", String)
|
||||
], AeroEffect.prototype, "style", void 0);
|
||||
function blurEffect(views, config) {
|
||||
const ret = new BlurEffect;
|
||||
ret.layoutConfig = layoutConfig().fit();
|
||||
|
5
doric-js/index.d.ts
vendored
5
doric-js/index.d.ts
vendored
@ -1121,6 +1121,11 @@ declare module 'doric/lib/src/widget/effect' {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
/**
|
||||
* Specify the area of the view is lighter or darker than the underlying view.
|
||||
* If not set, the default is light.
|
||||
*/
|
||||
style?: "light" | "dark" | "extraLight";
|
||||
}
|
||||
export function blurEffect(views: View | View[], config?: Partial<BlurEffect>): BlurEffect;
|
||||
export function aeroEffect(views: View | View[], config?: Partial<AeroEffect>): AeroEffect;
|
||||
|
5
doric-js/lib/src/widget/effect.d.ts
vendored
5
doric-js/lib/src/widget/effect.d.ts
vendored
@ -29,6 +29,11 @@ export declare class AeroEffect extends Stack {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
/**
|
||||
* Specify the area of the view is lighter or darker than the underlying view.
|
||||
* If not set, the default is light.
|
||||
*/
|
||||
style?: "light" | "dark" | "extraLight";
|
||||
}
|
||||
export declare function blurEffect(views: View | View[], config?: Partial<BlurEffect>): BlurEffect;
|
||||
export declare function aeroEffect(views: View | View[], config?: Partial<AeroEffect>): AeroEffect;
|
||||
|
@ -41,6 +41,10 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", Object)
|
||||
], AeroEffect.prototype, "effectiveRect", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", String)
|
||||
], AeroEffect.prototype, "style", void 0);
|
||||
export function blurEffect(views, config) {
|
||||
const ret = new BlurEffect;
|
||||
ret.layoutConfig = layoutConfig().fit();
|
||||
|
@ -51,6 +51,12 @@ export class AeroEffect extends Stack {
|
||||
width: number,
|
||||
height: number,
|
||||
}
|
||||
/**
|
||||
* Specify the area of the view is lighter or darker than the underlying view.
|
||||
* If not set, the default is light.
|
||||
*/
|
||||
@Property
|
||||
style?: "light" | "dark" | "extraLight"
|
||||
}
|
||||
|
||||
|
||||
|
4
doric-web/dist/index.js
vendored
4
doric-web/dist/index.js
vendored
@ -4323,6 +4323,10 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", Object)
|
||||
], AeroEffect.prototype, "effectiveRect", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", String)
|
||||
], AeroEffect.prototype, "style", void 0);
|
||||
function blurEffect(views, config) {
|
||||
const ret = new BlurEffect;
|
||||
ret.layoutConfig = layoutConfig().fit();
|
||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user