feat:add Popover demo
This commit is contained in:
@@ -18,3 +18,4 @@ export * from './navbar'
|
||||
export * from './navigator'
|
||||
export * from './network'
|
||||
export * from './storage'
|
||||
export * from './popover'
|
||||
|
@@ -15,13 +15,25 @@
|
||||
*/
|
||||
import { BridgeContext } from "../runtime/global"
|
||||
import { View } from "../ui/view"
|
||||
import { Panel } from "../ui/panel"
|
||||
|
||||
export function popover(context: BridgeContext) {
|
||||
const entity = context.entity
|
||||
let panel: Panel | undefined = undefined
|
||||
if (entity instanceof Panel) {
|
||||
panel = entity
|
||||
}
|
||||
return {
|
||||
show: (view: View) => {
|
||||
return context.popover.show(view)
|
||||
if (panel) {
|
||||
panel.addHeadView(view)
|
||||
}
|
||||
return context.popover.show(view.toModel())
|
||||
},
|
||||
dismiss: () => {
|
||||
dismiss: (view: View | undefined = undefined) => {
|
||||
if (panel && view) {
|
||||
panel.removeHeadView(view)
|
||||
}
|
||||
return context.popover.dismiss()
|
||||
},
|
||||
}
|
||||
|
@@ -137,15 +137,19 @@ export abstract class Panel {
|
||||
}
|
||||
|
||||
private hookBeforeNativeCall() {
|
||||
this.__root__.clean()
|
||||
for (let v of this.headviews.values()) {
|
||||
v.clean()
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
this.nativeRender(model)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user