head view manipulation api changed

This commit is contained in:
王劲鹏
2020-01-09 11:17:44 +08:00
committed by osborn
parent 88d45c2967
commit 56852286e3
10 changed files with 219 additions and 128 deletions

View File

@@ -43,24 +43,38 @@ export abstract class Panel {
private __data__?: object
private __root__ = new Root
private headviews: Map<string, View> = new Map
private headviews: Map<string, Map<string, View>> = new Map
addHeadView(v: View) {
this.headviews.set(v.viewId, v)
addHeadView(type: string, v: View) {
let map = this.headviews.get(type)
if (map) {
map.set(v.viewId, v)
} else {
map = new Map
map.set(v.viewId, v)
this.headviews.set(type, map)
}
}
allHeadViews() {
return this.headviews.values()
}
removeHeadView(v: View | string) {
if (v instanceof View) {
this.headviews.delete(v.viewId)
} else {
this.headviews.delete(v)
removeHeadView(type: string, v: View | string) {
if (this.headviews.has(type)) {
let map = this.headviews.get(type)
if (map) {
if (v instanceof View) {
map.delete(v.viewId)
} else {
map.delete(v)
}
}
}
}
clearHeadViews() {
this.headviews.clear()
clearHeadViews(type: string) {
if (this.headviews.has(type)) {
this.headviews.delete(type)
}
}
getRootView() {
@@ -144,8 +158,10 @@ export abstract class Panel {
private hookBeforeNativeCall() {
if (Environment.platform !== 'h5') {
this.__root__.clean()
for (let v of this.headviews.values()) {
v.clean()
for (let map of this.headviews.values()) {
for (let v of map.values()) {
v.clean()
}
}
}
}
@@ -158,10 +174,12 @@ export abstract class Panel {
const model = this.__root__.toModel()
this.nativeRender(model)
}
for (let v of this.headviews.values()) {
if (v.isDirty()) {
const model = v.toModel()
this.nativeRender(model)
for (let map of this.headviews.values()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel()
this.nativeRender(model)
}
}
}
} else {
@@ -171,11 +189,13 @@ export abstract class Panel {
this.nativeRender(model)
this.__root__.clean()
}
for (let v of this.headviews.values()) {
if (v.isDirty()) {
const model = v.toModel()
this.nativeRender(model)
v.clean()
for (let map of this.headviews.values()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel()
this.nativeRender(model)
v.clean()
}
}
}
})