optimize js code
This commit is contained in:
@@ -354,6 +354,10 @@ export abstract class View implements Modeling {
|
||||
@Property
|
||||
flexConfig?: FlexConfig
|
||||
|
||||
set props(props: Partial<this>) {
|
||||
this.apply(props)
|
||||
}
|
||||
|
||||
doAnimation(context: BridgeContext, animation: IAnimation) {
|
||||
return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => {
|
||||
for (let key in args) {
|
||||
|
@@ -33,9 +33,7 @@ export function draggable(views: View | View[], config?: Partial<Draggable>) {
|
||||
})
|
||||
}
|
||||
if (config) {
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
}
|
||||
return ret
|
||||
}
|
@@ -121,9 +121,7 @@ export function flowItem(item: View | View[], config?: Partial<FlowLayoutItem>)
|
||||
})
|
||||
}
|
||||
if (config) {
|
||||
for (let key in config) {
|
||||
Reflect.set(it, key, Reflect.get(config, key, config), it)
|
||||
}
|
||||
it.apply(config)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@@ -112,8 +112,6 @@ export class Image extends View {
|
||||
export function image(config: Partial<Image>) {
|
||||
const ret = new Image
|
||||
ret.layoutConfig = layoutConfig().fit()
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
return ret
|
||||
}
|
@@ -147,8 +147,6 @@ export enum InputType {
|
||||
export function input(config: Partial<Input>) {
|
||||
const ret = new Input
|
||||
ret.layoutConfig = layoutConfig().just()
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
return ret
|
||||
}
|
||||
|
@@ -44,9 +44,7 @@ export function stack(views: View[], config?: Partial<Stack>) {
|
||||
ret.addChild(v)
|
||||
}
|
||||
if (config) {
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
@@ -58,9 +56,7 @@ export function hlayout(views: View[], config?: Partial<HLayout>) {
|
||||
ret.addChild(v)
|
||||
}
|
||||
if (config) {
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
@@ -72,9 +68,7 @@ export function vlayout(views: View[], config?: Partial<VLayout>) {
|
||||
ret.addChild(v)
|
||||
}
|
||||
if (config) {
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
@@ -91,9 +85,7 @@ export function flexlayout(views: View[], config?: Partial<FlexLayout>) {
|
||||
ret.addChild(v)
|
||||
}
|
||||
if (config) {
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
}
|
||||
return ret
|
||||
}
|
@@ -114,9 +114,7 @@ export class List extends Superview {
|
||||
|
||||
export function list(config: Partial<List>) {
|
||||
const ret = new List
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -131,9 +129,7 @@ export function listItem(item: View | View[], config?: Partial<ListItem>) {
|
||||
})
|
||||
}
|
||||
if (config) {
|
||||
for (let key in config) {
|
||||
Reflect.set(it, key, Reflect.get(config, key, config), it)
|
||||
}
|
||||
it.apply(config)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@@ -47,9 +47,7 @@ export class Refreshable extends Superview {
|
||||
export function refreshable(config: Partial<Refreshable>) {
|
||||
const ret = new Refreshable
|
||||
ret.layoutConfig = layoutConfig().fit()
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
return ret
|
||||
}
|
||||
|
||||
|
@@ -21,9 +21,7 @@ export function scroller(content: View, config?: Partial<Scroller>) {
|
||||
return (new Scroller).also(v => {
|
||||
v.layoutConfig = layoutConfig().fit()
|
||||
if (config) {
|
||||
for (let key in config) {
|
||||
Reflect.set(v, key, Reflect.get(config, key, config), v)
|
||||
}
|
||||
v.apply(config)
|
||||
}
|
||||
v.content = content
|
||||
})
|
||||
|
@@ -83,9 +83,7 @@ export class Slider extends Superview {
|
||||
|
||||
export function slider(config: Partial<Slider>) {
|
||||
const ret = new Slider
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
return ret
|
||||
}
|
||||
|
||||
|
@@ -44,8 +44,6 @@ export function switchView(config: Partial<Switch>) {
|
||||
ret.layoutConfig = layoutConfig().just()
|
||||
ret.width = 50
|
||||
ret.height = 30
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
return ret
|
||||
}
|
||||
|
@@ -72,8 +72,6 @@ export class Text extends View {
|
||||
export function text(config: Partial<Text>) {
|
||||
const ret = new Text
|
||||
ret.layoutConfig = layoutConfig().fit()
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
ret.apply(config)
|
||||
return ret
|
||||
}
|
Reference in New Issue
Block a user