feat:popover can dismiss all poped views

This commit is contained in:
pengfei.zhou
2019-11-29 09:35:20 +08:00
parent a79e288679
commit 35d377f9b9
8 changed files with 65 additions and 48 deletions

View File

@@ -31,10 +31,14 @@ export function popover(context: BridgeContext) {
return context.popover.show(view.toModel())
},
dismiss: (view: View | undefined = undefined) => {
if (panel && view) {
panel.removeHeadView(view)
if (panel) {
if (view) {
panel.removeHeadView(view)
} else {
panel.clearHeadViews()
}
}
return context.popover.dismiss()
return context.popover.dismiss(view ? { id: view.viewId } : undefined)
},
}
}

View File

@@ -58,6 +58,10 @@ export abstract class Panel {
}
}
clearHeadViews() {
this.headviews.clear()
}
getRootView() {
return this.__root__
}
@@ -65,9 +69,6 @@ export abstract class Panel {
getInitData() {
return this.__data__
}
constructor() {
this.addHeadView(this.__root__)
}
@NativeCall
private __init__(frame: Frame, data: any) {
@@ -137,6 +138,7 @@ export abstract class Panel {
}
private hookBeforeNativeCall() {
this.__root__.clean()
for (let v of this.headviews.values()) {
v.clean()
}
@@ -145,6 +147,10 @@ export abstract class Panel {
private hookAfterNativeCall() {
//Here insert a native call to ensure the promise is resolved done.
nativeEmpty()
if (this.__root__.isDirty()) {
const model = this.__root__.toModel()
this.nativeRender(model)
}
for (let v of this.headviews.values()) {
if (v.isDirty()) {
const model = v.toModel()