This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-js/lib/src/native/popover.js

28 lines
814 B
JavaScript
Raw Normal View History

2020-01-03 14:44:51 +08:00
import { Panel } from "../ui/panel";
export function popover(context) {
const entity = context.entity;
let panel = undefined;
if (entity instanceof Panel) {
panel = entity;
}
return {
show: (view) => {
if (panel) {
2020-01-09 11:17:44 +08:00
panel.addHeadView("popover", view);
2020-01-03 14:44:51 +08:00
}
return context.callNative('popover', 'show', view.toModel());
2020-01-03 14:44:51 +08:00
},
dismiss: (view = undefined) => {
if (panel) {
if (view) {
2020-01-09 11:17:44 +08:00
panel.removeHeadView("popover", view);
2020-01-03 14:44:51 +08:00
}
else {
2020-01-09 11:17:44 +08:00
panel.clearHeadViews("popover");
2020-01-03 14:44:51 +08:00
}
}
return context.callNative('popover', 'dismiss', view ? { id: view.viewId } : undefined);
2020-01-03 14:44:51 +08:00
},
};
}