feat: fix typo

This commit is contained in:
pengfei.zhou 2021-11-25 12:00:58 +08:00 committed by osborn
parent 3b901cae90
commit 62a8357d77
13 changed files with 257 additions and 8 deletions

View File

@ -0,0 +1,68 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package pub.doric.shader;
import android.graphics.Rect;
import android.widget.FrameLayout;
import com.github.pengfeizhou.jscore.JSObject;
import com.github.pengfeizhou.jscore.JSValue;
import pub.doric.DoricContext;
import pub.doric.extension.bridge.DoricPlugin;
import pub.doric.utils.DoricUtils;
/**
* @Description: Describe the effect view
* @Author: pengfei.zhou
* @CreateDate: 2021/11/24
*/
@DoricPlugin(name = "AeroEffect")
public class AeroEffectViewNode extends StackNode {
public AeroEffectViewNode(DoricContext doricContext) {
super(doricContext);
}
@Override
protected FrameLayout build() {
return new BlurEffectView(getContext());
}
@Override
protected void blend(FrameLayout view, String name, JSValue prop) {
if ("radius".equals(name)) {
if (prop.isNumber()) {
((BlurEffectView) view).setRadius(prop.asNumber().toInt());
}
} else if ("effectiveRect".equals(name)) {
if (prop.isObject()) {
int x = DoricUtils.dp2px(prop.asObject().getProperty("x").asNumber().toFloat());
int y = DoricUtils.dp2px(prop.asObject().getProperty("x").asNumber().toFloat());
int width = DoricUtils.dp2px(prop.asObject().getProperty("width").asNumber().toFloat());
int height = DoricUtils.dp2px(prop.asObject().getProperty("height").asNumber().toFloat());
((BlurEffectView) view).setEffectiveRect(new Rect(x, y, x + width, y + height));
}
} else {
super.blend(view, name, prop);
}
}
@Override
protected void blendSubNode(JSObject subProp) {
super.blendSubNode(subProp);
mView.invalidate();
}
}

View File

@ -62,7 +62,7 @@
#import "DoricRemoteResourceLoader.h" #import "DoricRemoteResourceLoader.h"
#import "DoricCommonBundleResourceLoader.h" #import "DoricCommonBundleResourceLoader.h"
#import "DoricBlurEffectViewNode.h" #import "DoricBlurEffectViewNode.h"
#import "DoricAreoEffectViewNode.h" #import "DoricAeroEffectViewNode.h"
@interface DoricRegistry () @interface DoricRegistry ()
@ -136,7 +136,7 @@ - (void)innerRegister {
[self registerViewNode:DoricFlexNode.class withName:@"FlexLayout"]; [self registerViewNode:DoricFlexNode.class withName:@"FlexLayout"];
[self registerViewNode:DoricGestureContainerNode.class withName:@"GestureContainer"]; [self registerViewNode:DoricGestureContainerNode.class withName:@"GestureContainer"];
[self registerViewNode:DoricBlurEffectViewNode.class withName:@"BlurEffect"]; [self registerViewNode:DoricBlurEffectViewNode.class withName:@"BlurEffect"];
[self registerViewNode:DoricAreoEffectViewNode.class withName:@"AreoEffect"]; [self registerViewNode:DoricAeroEffectViewNode.class withName:@"AeroEffect"];
[self.loaderManager registerLoader:[[DoricBundleResourceLoader alloc] [self.loaderManager registerLoader:[[DoricBundleResourceLoader alloc]
initWithResourceType:@"mainBundle" initWithResourceType:@"mainBundle"

View File

@ -20,5 +20,5 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "DoricStackNode.h" #import "DoricStackNode.h"
@interface DoricAreoEffectViewNode : DoricStackNode @interface DoricAeroEffectViewNode : DoricStackNode
@end @end

View File

@ -17,13 +17,13 @@
// Created by pengfei.zhou on 2021/11/24. // Created by pengfei.zhou on 2021/11/24.
// //
#import "DoricAreoEffectViewNode.h" #import "DoricAeroEffectViewNode.h"
@interface DoricAreoEffectViewNode () @interface DoricAeroEffectViewNode ()
@property(nonatomic, strong) UIVisualEffectView *visualEffectView; @property(nonatomic, strong) UIVisualEffectView *visualEffectView;
@end @end
@implementation DoricAreoEffectViewNode @implementation DoricAeroEffectViewNode
- (UIView *)build { - (UIView *)build {
UIView *ret = [super build]; UIView *ret = [super build];

View File

@ -3634,6 +3634,17 @@ var BlurEffect = /** @class */ (function (_super) {
], BlurEffect.prototype, "radius", void 0); ], BlurEffect.prototype, "radius", void 0);
return BlurEffect; return BlurEffect;
}(Stack)); }(Stack));
var AeroEffect = /** @class */ (function (_super) {
__extends$2(AeroEffect, _super);
function AeroEffect() {
return _super !== null && _super.apply(this, arguments) || this;
}
__decorate([
Property,
__metadata("design:type", Object)
], AeroEffect.prototype, "effectiveRect", void 0);
return AeroEffect;
}(Stack));
function blurEffect(views, config) { function blurEffect(views, config) {
var ret = new BlurEffect; var ret = new BlurEffect;
ret.layoutConfig = layoutConfig().fit(); ret.layoutConfig = layoutConfig().fit();
@ -3650,6 +3661,22 @@ function blurEffect(views, config) {
} }
return ret; return ret;
} }
function aeroEffect(views, config) {
var ret = new AeroEffect;
ret.layoutConfig = layoutConfig().fit();
if (views instanceof View) {
ret.addChild(views);
}
else {
views.forEach(function (e) {
ret.addChild(e);
});
}
if (config) {
ret.apply(config);
}
return ret;
}
function modal(context) { function modal(context) {
return { return {
@ -4459,6 +4486,7 @@ var ModularPanel = /** @class */ (function (_super) {
return ModularPanel; return ModularPanel;
}(Module)); }(Module));
exports.AeroEffect = AeroEffect;
exports.AlphaAnimation = AlphaAnimation; exports.AlphaAnimation = AlphaAnimation;
exports.AnimationSet = AnimationSet; exports.AnimationSet = AnimationSet;
exports.AssetResource = AssetResource; exports.AssetResource = AssetResource;
@ -4526,6 +4554,7 @@ exports.View = View;
exports.ViewComponent = ViewComponent; exports.ViewComponent = ViewComponent;
exports.ViewHolder = ViewHolder; exports.ViewHolder = ViewHolder;
exports.ViewModel = ViewModel; exports.ViewModel = ViewModel;
exports.aeroEffect = aeroEffect;
exports.animate = animate; exports.animate = animate;
exports.blurEffect = blurEffect; exports.blurEffect = blurEffect;
exports.coordinator = coordinator; exports.coordinator = coordinator;

View File

@ -2742,6 +2742,12 @@ __decorate([
Property, Property,
__metadata("design:type", Number) __metadata("design:type", Number)
], BlurEffect.prototype, "radius", void 0); ], BlurEffect.prototype, "radius", void 0);
class AeroEffect extends Stack {
}
__decorate([
Property,
__metadata("design:type", Object)
], AeroEffect.prototype, "effectiveRect", void 0);
function blurEffect(views, config) { function blurEffect(views, config) {
const ret = new BlurEffect; const ret = new BlurEffect;
ret.layoutConfig = layoutConfig().fit(); ret.layoutConfig = layoutConfig().fit();
@ -2758,6 +2764,22 @@ function blurEffect(views, config) {
} }
return ret; return ret;
} }
function aeroEffect(views, config) {
const ret = new AeroEffect;
ret.layoutConfig = layoutConfig().fit();
if (views instanceof View) {
ret.addChild(views);
}
else {
views.forEach(e => {
ret.addChild(e);
});
}
if (config) {
ret.apply(config);
}
return ret;
}
function modal(context) { function modal(context) {
return { return {
@ -3407,6 +3429,7 @@ class ModularPanel extends Module {
} }
} }
exports.AeroEffect = AeroEffect;
exports.AlphaAnimation = AlphaAnimation; exports.AlphaAnimation = AlphaAnimation;
exports.AnimationSet = AnimationSet; exports.AnimationSet = AnimationSet;
exports.AssetResource = AssetResource; exports.AssetResource = AssetResource;
@ -3474,6 +3497,7 @@ exports.View = View;
exports.ViewComponent = ViewComponent; exports.ViewComponent = ViewComponent;
exports.ViewHolder = ViewHolder; exports.ViewHolder = ViewHolder;
exports.ViewModel = ViewModel; exports.ViewModel = ViewModel;
exports.aeroEffect = aeroEffect;
exports.animate = animate; exports.animate = animate;
exports.blurEffect = blurEffect; exports.blurEffect = blurEffect;
exports.coordinator = coordinator; exports.coordinator = coordinator;

View File

@ -4263,6 +4263,12 @@ __decorate([
Property, Property,
__metadata("design:type", Number) __metadata("design:type", Number)
], BlurEffect.prototype, "radius", void 0); ], BlurEffect.prototype, "radius", void 0);
class AeroEffect extends Stack {
}
__decorate([
Property,
__metadata("design:type", Object)
], AeroEffect.prototype, "effectiveRect", void 0);
function blurEffect(views, config) { function blurEffect(views, config) {
const ret = new BlurEffect; const ret = new BlurEffect;
ret.layoutConfig = layoutConfig().fit(); ret.layoutConfig = layoutConfig().fit();
@ -4279,6 +4285,22 @@ function blurEffect(views, config) {
} }
return ret; return ret;
} }
function aeroEffect(views, config) {
const ret = new AeroEffect;
ret.layoutConfig = layoutConfig().fit();
if (views instanceof View) {
ret.addChild(views);
}
else {
views.forEach(e => {
ret.addChild(e);
});
}
if (config) {
ret.apply(config);
}
return ret;
}
function modal(context) { function modal(context) {
return { return {
@ -5169,6 +5191,7 @@ global$1.nativeEmpty = () => {
}, 0); }, 0);
}; };
exports.AeroEffect = AeroEffect;
exports.AlphaAnimation = AlphaAnimation; exports.AlphaAnimation = AlphaAnimation;
exports.AnimationSet = AnimationSet; exports.AnimationSet = AnimationSet;
exports.AssetResource = AssetResource; exports.AssetResource = AssetResource;
@ -5236,6 +5259,7 @@ exports.View = View;
exports.ViewComponent = ViewComponent; exports.ViewComponent = ViewComponent;
exports.ViewHolder = ViewHolder; exports.ViewHolder = ViewHolder;
exports.ViewModel = ViewModel; exports.ViewModel = ViewModel;
exports.aeroEffect = aeroEffect;
exports.animate = animate; exports.animate = animate;
exports.blurEffect = blurEffect; exports.blurEffect = blurEffect;
exports.coordinator = coordinator; exports.coordinator = coordinator;

13
doric-js/index.d.ts vendored
View File

@ -1110,7 +1110,20 @@ declare module 'doric/lib/src/widget/effect' {
*/ */
radius?: number; radius?: number;
} }
export class AeroEffect extends Stack {
/**
* Specify the effective rectangle.
* If not set, the default is the entire area.
*/
effectiveRect?: {
x: number;
y: number;
width: number;
height: number;
};
}
export function blurEffect(views: View | View[], config?: Partial<BlurEffect>): BlurEffect; export function blurEffect(views: View | View[], config?: Partial<BlurEffect>): BlurEffect;
export function aeroEffect(views: View | View[], config?: Partial<AeroEffect>): AeroEffect;
} }
declare module 'doric/lib/src/native/modal' { declare module 'doric/lib/src/native/modal' {

View File

@ -18,4 +18,17 @@ export declare class BlurEffect extends Stack {
*/ */
radius?: number; radius?: number;
} }
export declare class AeroEffect extends Stack {
/**
* Specify the effective rectangle.
* If not set, the default is the entire area.
*/
effectiveRect?: {
x: number;
y: number;
width: number;
height: number;
};
}
export declare function blurEffect(views: View | View[], config?: Partial<BlurEffect>): BlurEffect; export declare function blurEffect(views: View | View[], config?: Partial<BlurEffect>): BlurEffect;
export declare function aeroEffect(views: View | View[], config?: Partial<AeroEffect>): AeroEffect;

View File

@ -35,6 +35,12 @@ __decorate([
Property, Property,
__metadata("design:type", Number) __metadata("design:type", Number)
], BlurEffect.prototype, "radius", void 0); ], BlurEffect.prototype, "radius", void 0);
export class AeroEffect extends Stack {
}
__decorate([
Property,
__metadata("design:type", Object)
], AeroEffect.prototype, "effectiveRect", void 0);
export function blurEffect(views, config) { export function blurEffect(views, config) {
const ret = new BlurEffect; const ret = new BlurEffect;
ret.layoutConfig = layoutConfig().fit(); ret.layoutConfig = layoutConfig().fit();
@ -51,3 +57,19 @@ export function blurEffect(views, config) {
} }
return ret; return ret;
} }
export function aeroEffect(views, config) {
const ret = new AeroEffect;
ret.layoutConfig = layoutConfig().fit();
if (views instanceof View) {
ret.addChild(views);
}
else {
views.forEach(e => {
ret.addChild(e);
});
}
if (config) {
ret.apply(config);
}
return ret;
}

View File

@ -38,6 +38,22 @@ export class BlurEffect extends Stack {
radius?: number radius?: number
} }
export class AeroEffect extends Stack {
/**
* Specify the effective rectangle.
* If not set, the default is the entire area.
*/
@Property
effectiveRect?: {
x: number,
y: number,
width: number,
height: number,
}
}
export function blurEffect(views: View | View[], config?: Partial<BlurEffect>) { export function blurEffect(views: View | View[], config?: Partial<BlurEffect>) {
const ret = new BlurEffect const ret = new BlurEffect
ret.layoutConfig = layoutConfig().fit() ret.layoutConfig = layoutConfig().fit()
@ -52,4 +68,20 @@ export function blurEffect(views: View | View[], config?: Partial<BlurEffect>) {
ret.apply(config) ret.apply(config)
} }
return ret return ret
}
export function aeroEffect(views: View | View[], config?: Partial<AeroEffect>) {
const ret = new AeroEffect
ret.layoutConfig = layoutConfig().fit()
if (views instanceof View) {
ret.addChild(views)
} else {
views.forEach(e => {
ret.addChild(e)
})
}
if (config) {
ret.apply(config)
}
return ret
} }

View File

@ -4317,6 +4317,12 @@ __decorate([
Property, Property,
__metadata("design:type", Number) __metadata("design:type", Number)
], BlurEffect.prototype, "radius", void 0); ], BlurEffect.prototype, "radius", void 0);
class AeroEffect extends Stack {
}
__decorate([
Property,
__metadata("design:type", Object)
], AeroEffect.prototype, "effectiveRect", void 0);
function blurEffect(views, config) { function blurEffect(views, config) {
const ret = new BlurEffect; const ret = new BlurEffect;
ret.layoutConfig = layoutConfig().fit(); ret.layoutConfig = layoutConfig().fit();
@ -4333,6 +4339,22 @@ function blurEffect(views, config) {
} }
return ret; return ret;
} }
function aeroEffect(views, config) {
const ret = new AeroEffect;
ret.layoutConfig = layoutConfig().fit();
if (views instanceof View) {
ret.addChild(views);
}
else {
views.forEach(e => {
ret.addChild(e);
});
}
if (config) {
ret.apply(config);
}
return ret;
}
function modal(context) { function modal(context) {
return { return {
@ -4982,6 +5004,7 @@ class ModularPanel extends Module {
} }
} }
exports.AeroEffect = AeroEffect;
exports.AlphaAnimation = AlphaAnimation; exports.AlphaAnimation = AlphaAnimation;
exports.AnimationSet = AnimationSet; exports.AnimationSet = AnimationSet;
exports.AssetResource = AssetResource; exports.AssetResource = AssetResource;
@ -5049,6 +5072,7 @@ exports.View = View;
exports.ViewComponent = ViewComponent; exports.ViewComponent = ViewComponent;
exports.ViewHolder = ViewHolder; exports.ViewHolder = ViewHolder;
exports.ViewModel = ViewModel; exports.ViewModel = ViewModel;
exports.aeroEffect = aeroEffect;
exports.animate = animate; exports.animate = animate;
exports.blurEffect = blurEffect; exports.blurEffect = blurEffect;
exports.coordinator = coordinator; exports.coordinator = coordinator;

File diff suppressed because one or more lines are too long