feat:refact View Dirty Props,prepare to use in ListView
This commit is contained in:
parent
dab3c00b4c
commit
eea7eb5d27
@ -13,7 +13,9 @@ class CounterView extends ViewHolder<CountModel> {
|
|||||||
text({
|
text({
|
||||||
textSize: 40,
|
textSize: 40,
|
||||||
layoutConfig: {
|
layoutConfig: {
|
||||||
alignment: new Gravity().center()
|
alignment: new Gravity().center(),
|
||||||
|
widthSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
|
heightSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
},
|
},
|
||||||
}).also(it => { this.number = it }),
|
}).also(it => { this.number = it }),
|
||||||
text({
|
text({
|
||||||
@ -25,7 +27,9 @@ class CounterView extends ViewHolder<CountModel> {
|
|||||||
},
|
},
|
||||||
corners: 5,
|
corners: 5,
|
||||||
layoutConfig: {
|
layoutConfig: {
|
||||||
alignment: new Gravity().center()
|
alignment: new Gravity().center(),
|
||||||
|
widthSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
|
heightSpec: LayoutSpec.WRAP_CONTENT,
|
||||||
},
|
},
|
||||||
shadow: {
|
shadow: {
|
||||||
color: Color.parse("#00ff00"),
|
color: Color.parse("#00ff00"),
|
||||||
|
@ -44,6 +44,10 @@ export class List extends Superview {
|
|||||||
return this.cachedViews.get(id)
|
return this.cachedViews.get(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allSubviews() {
|
||||||
|
return this.cachedViews.values()
|
||||||
|
}
|
||||||
|
|
||||||
@Property
|
@Property
|
||||||
itemCount = 0
|
itemCount = 0
|
||||||
|
|
||||||
|
@ -99,8 +99,8 @@ export abstract class Panel {
|
|||||||
|
|
||||||
private retrospectView(ids: string[]): View {
|
private retrospectView(ids: string[]): View {
|
||||||
return ids.reduce((acc: View, cur) => {
|
return ids.reduce((acc: View, cur) => {
|
||||||
if (Reflect.has(acc, "subViewById")) {
|
if (Reflect.has(acc, "subviewById")) {
|
||||||
return Reflect.apply(Reflect.get(acc, "subViewById"), acc, [cur])
|
return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur])
|
||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
}, this.__root__)
|
}, this.__root__)
|
||||||
|
@ -254,6 +254,20 @@ export abstract class View implements Modeling, IView {
|
|||||||
|
|
||||||
export abstract class Superview extends View {
|
export abstract class Superview extends View {
|
||||||
abstract subviewById(id: string): View | undefined
|
abstract subviewById(id: string): View | undefined
|
||||||
|
abstract allSubviews(): Iterable<View>
|
||||||
|
|
||||||
|
isDirty() {
|
||||||
|
if (super.isDirty()) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
for (const v of this.allSubviews()) {
|
||||||
|
if (v.isDirty()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class Group extends Superview {
|
export abstract class Group extends Superview {
|
||||||
@ -276,6 +290,10 @@ export abstract class Group extends Superview {
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allSubviews() {
|
||||||
|
return this.children
|
||||||
|
}
|
||||||
|
|
||||||
addChild(view: View) {
|
addChild(view: View) {
|
||||||
this.children.push(view)
|
this.children.push(view)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user