feat:support component view
This commit is contained in:
@@ -200,6 +200,11 @@ function InconsistProperty(target, propKey) {
|
||||
},
|
||||
});
|
||||
}
|
||||
var PROP_KEY_VIEW_TYPE = "__prop__ViewType";
|
||||
function ViewComponent(constructor) {
|
||||
var name = Reflect.get(constructor, PROP_KEY_VIEW_TYPE) || Object.getPrototypeOf(constructor).name;
|
||||
Reflect.set(constructor, PROP_KEY_VIEW_TYPE, name);
|
||||
}
|
||||
var View = /** @class */ (function () {
|
||||
function View() {
|
||||
this.width = 0;
|
||||
@@ -301,7 +306,7 @@ var View = /** @class */ (function () {
|
||||
configurable: true
|
||||
});
|
||||
View.prototype.viewType = function () {
|
||||
return this.constructor.name;
|
||||
return Reflect.get(this.constructor, PROP_KEY_VIEW_TYPE) || this.constructor.name;
|
||||
};
|
||||
View.prototype.onPropertyChanged = function (propKey, oldV, newV) {
|
||||
var _this = this;
|
||||
@@ -3765,6 +3770,7 @@ exports.TranslationAnimation = TranslationAnimation;
|
||||
exports.VLayout = VLayout;
|
||||
exports.VMPanel = VMPanel;
|
||||
exports.View = View;
|
||||
exports.ViewComponent = ViewComponent;
|
||||
exports.ViewHolder = ViewHolder;
|
||||
exports.ViewModel = ViewModel;
|
||||
exports.animate = animate;
|
||||
|
@@ -130,12 +130,17 @@ var __metadata$d = (undefined && undefined.__metadata) || function (k, v) {
|
||||
};
|
||||
const PROP_CONSIST = 1;
|
||||
const PROP_INCONSIST = 2;
|
||||
const PROP_KEY_VIEW_TYPE = "ViewType";
|
||||
function Property(target, propKey) {
|
||||
Reflect.defineMetadata(propKey, PROP_CONSIST, target);
|
||||
}
|
||||
function InconsistProperty(target, propKey) {
|
||||
Reflect.defineMetadata(propKey, PROP_INCONSIST, target);
|
||||
}
|
||||
function ViewComponent(constructor) {
|
||||
const name = Reflect.getMetadata(PROP_KEY_VIEW_TYPE, constructor) || Object.getPrototypeOf(constructor).name;
|
||||
Reflect.defineMetadata(PROP_KEY_VIEW_TYPE, name, constructor);
|
||||
}
|
||||
class View {
|
||||
constructor() {
|
||||
this.width = 0;
|
||||
@@ -227,7 +232,8 @@ class View {
|
||||
return this.__dirty_props__;
|
||||
}
|
||||
viewType() {
|
||||
return this.constructor.name;
|
||||
const viewType = Reflect.getMetadata(PROP_KEY_VIEW_TYPE, this.constructor);
|
||||
return viewType || this.constructor.name;
|
||||
}
|
||||
onPropertyChanged(propKey, oldV, newV) {
|
||||
if (newV instanceof Function) {
|
||||
@@ -2920,6 +2926,7 @@ exports.TranslationAnimation = TranslationAnimation;
|
||||
exports.VLayout = VLayout;
|
||||
exports.VMPanel = VMPanel;
|
||||
exports.View = View;
|
||||
exports.ViewComponent = ViewComponent;
|
||||
exports.ViewHolder = ViewHolder;
|
||||
exports.ViewModel = ViewModel;
|
||||
exports.animate = animate;
|
||||
|
@@ -1651,12 +1651,17 @@ var __metadata$d = (undefined && undefined.__metadata) || function (k, v) {
|
||||
};
|
||||
const PROP_CONSIST = 1;
|
||||
const PROP_INCONSIST = 2;
|
||||
const PROP_KEY_VIEW_TYPE = "ViewType";
|
||||
function Property(target, propKey) {
|
||||
Reflect.defineMetadata(propKey, PROP_CONSIST, target);
|
||||
}
|
||||
function InconsistProperty(target, propKey) {
|
||||
Reflect.defineMetadata(propKey, PROP_INCONSIST, target);
|
||||
}
|
||||
function ViewComponent(constructor) {
|
||||
const name = Reflect.getMetadata(PROP_KEY_VIEW_TYPE, constructor) || Object.getPrototypeOf(constructor).name;
|
||||
Reflect.defineMetadata(PROP_KEY_VIEW_TYPE, name, constructor);
|
||||
}
|
||||
class View {
|
||||
constructor() {
|
||||
this.width = 0;
|
||||
@@ -1748,7 +1753,8 @@ class View {
|
||||
return this.__dirty_props__;
|
||||
}
|
||||
viewType() {
|
||||
return this.constructor.name;
|
||||
const viewType = Reflect.getMetadata(PROP_KEY_VIEW_TYPE, this.constructor);
|
||||
return viewType || this.constructor.name;
|
||||
}
|
||||
onPropertyChanged(propKey, oldV, newV) {
|
||||
if (newV instanceof Function) {
|
||||
@@ -4682,6 +4688,7 @@ exports.TranslationAnimation = TranslationAnimation;
|
||||
exports.VLayout = VLayout;
|
||||
exports.VMPanel = VMPanel;
|
||||
exports.View = View;
|
||||
exports.ViewComponent = ViewComponent;
|
||||
exports.ViewHolder = ViewHolder;
|
||||
exports.ViewModel = ViewModel;
|
||||
exports.animate = animate;
|
||||
|
5
doric-js/index.d.ts
vendored
5
doric-js/index.d.ts
vendored
@@ -166,13 +166,14 @@ declare module 'doric/lib/src/util/types' {
|
||||
|
||||
declare module 'doric/lib/src/ui/view' {
|
||||
import { Color, GradientColor } from "doric/lib/src/util/color";
|
||||
import { Modeling, Model } from "doric/lib/src/util/types";
|
||||
import { Modeling, Model, ClassType } from "doric/lib/src/util/types";
|
||||
import { BridgeContext } from "doric/lib/src/runtime/global";
|
||||
import { LayoutConfig } from 'doric/lib/src/util/layoutconfig';
|
||||
import { IAnimation } from "doric/lib/src/ui/animation";
|
||||
import { FlexConfig } from "doric/lib/src/util/flexbox";
|
||||
export function Property(target: Object, propKey: string): void;
|
||||
export function InconsistProperty(target: Object, propKey: string): void;
|
||||
export function ViewComponent(constructor: ClassType<any>): void;
|
||||
export type NativeViewModel = {
|
||||
id: string;
|
||||
type: string;
|
||||
@@ -239,7 +240,7 @@ declare module 'doric/lib/src/ui/view' {
|
||||
[index: string]: Model;
|
||||
};
|
||||
nativeViewModel: NativeViewModel;
|
||||
viewType(): string;
|
||||
viewType(): any;
|
||||
onPropertyChanged(propKey: string, oldV: Model, newV: Model): void;
|
||||
clean(): void;
|
||||
isDirty(): boolean;
|
||||
|
5
doric-js/lib/src/ui/view.d.ts
vendored
5
doric-js/lib/src/ui/view.d.ts
vendored
@@ -1,11 +1,12 @@
|
||||
import { Color, GradientColor } from "../util/color";
|
||||
import { Modeling, Model } from "../util/types";
|
||||
import { Modeling, Model, ClassType } from "../util/types";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
import { LayoutConfig } from '../util/layoutconfig';
|
||||
import { IAnimation } from "./animation";
|
||||
import { FlexConfig } from "../util/flexbox";
|
||||
export declare function Property(target: Object, propKey: string): void;
|
||||
export declare function InconsistProperty(target: Object, propKey: string): void;
|
||||
export declare function ViewComponent(constructor: ClassType<any>): void;
|
||||
export declare type NativeViewModel = {
|
||||
id: string;
|
||||
type: string;
|
||||
@@ -76,7 +77,7 @@ export declare abstract class View implements Modeling {
|
||||
[index: string]: Model;
|
||||
};
|
||||
nativeViewModel: NativeViewModel;
|
||||
viewType(): string;
|
||||
viewType(): any;
|
||||
onPropertyChanged(propKey: string, oldV: Model, newV: Model): void;
|
||||
clean(): void;
|
||||
isDirty(): boolean;
|
||||
|
@@ -12,12 +12,17 @@ import { uniqueId } from "../util/uniqueId";
|
||||
import { loge } from "../util/log";
|
||||
const PROP_CONSIST = 1;
|
||||
const PROP_INCONSIST = 2;
|
||||
const PROP_KEY_VIEW_TYPE = "ViewType";
|
||||
export function Property(target, propKey) {
|
||||
Reflect.defineMetadata(propKey, PROP_CONSIST, target);
|
||||
}
|
||||
export function InconsistProperty(target, propKey) {
|
||||
Reflect.defineMetadata(propKey, PROP_INCONSIST, target);
|
||||
}
|
||||
export function ViewComponent(constructor) {
|
||||
const name = Reflect.getMetadata(PROP_KEY_VIEW_TYPE, constructor) || Object.getPrototypeOf(constructor).name;
|
||||
Reflect.defineMetadata(PROP_KEY_VIEW_TYPE, name, constructor);
|
||||
}
|
||||
export class View {
|
||||
constructor() {
|
||||
this.width = 0;
|
||||
@@ -109,7 +114,8 @@ export class View {
|
||||
return this.__dirty_props__;
|
||||
}
|
||||
viewType() {
|
||||
return this.constructor.name;
|
||||
const viewType = Reflect.getMetadata(PROP_KEY_VIEW_TYPE, this.constructor);
|
||||
return viewType || this.constructor.name;
|
||||
}
|
||||
onPropertyChanged(propKey, oldV, newV) {
|
||||
if (newV instanceof Function) {
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Color, GradientColor } from "../util/color"
|
||||
import { Modeling, Model, obj2Model } from "../util/types";
|
||||
import { Modeling, Model, obj2Model, ClassType } from "../util/types";
|
||||
import { uniqueId } from "../util/uniqueId";
|
||||
import { loge } from "../util/log";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
@@ -50,6 +50,13 @@ export function InconsistProperty(target: Object, propKey: string) {
|
||||
})
|
||||
}
|
||||
|
||||
const PROP_KEY_VIEW_TYPE = "__prop__ViewType";
|
||||
|
||||
export function ViewComponent(constructor: ClassType<any>) {
|
||||
const name = Reflect.get(constructor, PROP_KEY_VIEW_TYPE) || Object.getPrototypeOf(constructor).name
|
||||
Reflect.set(constructor, PROP_KEY_VIEW_TYPE, name)
|
||||
}
|
||||
|
||||
export type NativeViewModel = {
|
||||
id: string;
|
||||
type: string;
|
||||
@@ -190,7 +197,7 @@ export abstract class View implements Modeling {
|
||||
}
|
||||
|
||||
viewType() {
|
||||
return this.constructor.name
|
||||
return Reflect.get(this.constructor, PROP_KEY_VIEW_TYPE) || this.constructor.name
|
||||
}
|
||||
|
||||
onPropertyChanged(propKey: string, oldV: Model, newV: Model): void {
|
||||
|
@@ -14,17 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Color, GradientColor } from "../util/color"
|
||||
import { Modeling, Model, obj2Model } from "../util/types";
|
||||
import { Modeling, Model, obj2Model, ClassType } from "../util/types";
|
||||
import { uniqueId } from "../util/uniqueId";
|
||||
import { loge } from "../util/log";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
import { LayoutConfig } from '../util/layoutconfig'
|
||||
import { IAnimation } from "./animation";
|
||||
import { FlexConfig } from "../util/flexbox";
|
||||
import { modal } from "../native/modal";
|
||||
|
||||
const PROP_CONSIST = 1;
|
||||
const PROP_INCONSIST = 2;
|
||||
const PROP_KEY_VIEW_TYPE = "ViewType";
|
||||
|
||||
export function Property(target: Object, propKey: string) {
|
||||
Reflect.defineMetadata(propKey, PROP_CONSIST, target)
|
||||
@@ -34,6 +34,11 @@ export function InconsistProperty(target: Object, propKey: string) {
|
||||
Reflect.defineMetadata(propKey, PROP_INCONSIST, target)
|
||||
}
|
||||
|
||||
export function ViewComponent(constructor: ClassType<any>) {
|
||||
const name = Reflect.getMetadata(PROP_KEY_VIEW_TYPE, constructor) || Object.getPrototypeOf(constructor).name
|
||||
Reflect.defineMetadata(PROP_KEY_VIEW_TYPE, name, constructor)
|
||||
}
|
||||
|
||||
export type NativeViewModel = {
|
||||
id: string;
|
||||
type: string;
|
||||
@@ -196,7 +201,8 @@ export abstract class View implements Modeling {
|
||||
}
|
||||
|
||||
viewType() {
|
||||
return this.constructor.name
|
||||
const viewType = Reflect.getMetadata(PROP_KEY_VIEW_TYPE, this.constructor)
|
||||
return viewType || this.constructor.name
|
||||
}
|
||||
|
||||
onPropertyChanged(propKey: string, oldV: Model, newV: Model): void {
|
||||
|
Reference in New Issue
Block a user