update js defination,use Partical insted of IView

This commit is contained in:
pengfei.zhou
2020-04-16 19:21:24 +08:00
committed by osborn
parent b2241fe343
commit 2598d0f266
57 changed files with 633 additions and 972 deletions

View File

@@ -37,56 +37,6 @@ export function Property(target: View, propKey: string) {
})
}
export interface IView {
width?: number
height?: number
backgroundColor?: Color | GradientColor
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?: {
left?: number,
right?: number,
top?: number,
bottom?: number,
}
layoutConfig?: LayoutConfig
onClick?: Function
identifier?: string
/**++++++++++transform++++++++++*/
translationX?: number
translationY?: number
scaleX?: number
scaleY?: number
/**
* float [0,..1]
*/
pivotX?: number
/**
* float [0,..1]
*/
pivotY?: number
/**
* rotation*PI
*/
rotation?: number
/**----------transform----------*/
/**
* Only affected when its superview or itself is FlexLayout.
*/
flexConfig?: FlexConfig
}
export type NativeViewModel = {
id: string;
type: string;
@@ -95,7 +45,7 @@ export type NativeViewModel = {
};
}
export abstract class View implements Modeling, IView {
export abstract class View implements Modeling {
private __dirty_props__!: { [index: string]: Model | undefined }
@Property
@@ -276,7 +226,7 @@ export abstract class View implements Modeling, IView {
return this
}
apply(config: IView) {
apply(config: Partial<this>) {
for (let key in config) {
Reflect.set(this, key, Reflect.get(config, key, config), this)
}

View File

@@ -26,56 +26,6 @@ export function Property(target: Object, propKey: string) {
Reflect.defineMetadata(propKey, true, target)
}
export interface IView {
width?: number
height?: number
backgroundColor?: Color | GradientColor
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?: {
left?: number,
right?: number,
top?: number,
bottom?: number,
}
layoutConfig?: LayoutConfig
onClick?: Function
identifier?: string
/**++++++++++transform++++++++++*/
translationX?: number
translationY?: number
scaleX?: number
scaleY?: number
/**
* float [0,..1]
*/
pivotX?: number
/**
* float [0,..1]
*/
pivotY?: number
/**
* rotation*PI
*/
rotation?: number
/**----------transform----------*/
/**
* Only affected when its superview or itself is FlexLayout.
*/
flexConfig?: FlexConfig
}
export type NativeViewModel = {
id: string;
type: string;
@@ -84,7 +34,7 @@ export type NativeViewModel = {
};
}
export abstract class View implements Modeling, IView {
export abstract class View implements Modeling {
@Property
width: number = 0
@@ -108,7 +58,9 @@ export abstract class View implements Modeling, IView {
@Property
shadow?: { color: Color; opacity: number; radius: number; offsetX: number; offsetY: number }
/**
* float [0,..1]
*/
@Property
alpha?: number
@@ -271,7 +223,7 @@ export abstract class View implements Modeling, IView {
return this
}
apply(config: IView) {
apply(config: Partial<this>) {
for (let key in config) {
Reflect.set(this, key, Reflect.get(config, key, config), this)
}
@@ -327,7 +279,9 @@ export abstract class View implements Modeling, IView {
@Property
translationY?: number
/**
* float [0,..1]
*/
@Property
scaleX?: number
@@ -339,11 +293,15 @@ export abstract class View implements Modeling, IView {
@Property
pivotY?: number
/**
* rotation*PI
*/
@Property
rotation?: number
/**----------transform----------*/
/**
* Only affected when its superview or itself is FlexLayout.
*/
@Property
flexConfig?: FlexConfig