UNPKG

2.46 kBJavaScriptView Raw
1import { isString } from '../util/util';
2var OverlayProxy = (function () {
3 function OverlayProxy(_app, _component, _config, _deepLinker) {
4 this._app = _app;
5 this._component = _component;
6 this._config = _config;
7 this._deepLinker = _deepLinker;
8 }
9 OverlayProxy.prototype.getImplementation = function () {
10 throw new Error('Child class must implement "getImplementation" method');
11 };
12 /**
13 * Present the modal instance.
14 *
15 * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
16 * @returns {Promise} Returns a promise which is resolved when the transition has completed.
17 */
18 OverlayProxy.prototype.present = function (navOptions) {
19 var _this = this;
20 if (navOptions === void 0) { navOptions = {}; }
21 // check if it's a lazy loaded component, or not
22 var isLazyLoaded = isString(this._component);
23 if (isLazyLoaded) {
24 return this._deepLinker.getComponentFromName(this._component).then(function (loadedComponent) {
25 _this._component = loadedComponent;
26 return _this.createAndPresentOverlay(navOptions);
27 });
28 }
29 else {
30 return this.createAndPresentOverlay(navOptions);
31 }
32 };
33 OverlayProxy.prototype.dismiss = function (data, role, navOptions) {
34 if (this.overlay) {
35 return this.overlay.dismiss(data, role, navOptions);
36 }
37 };
38 /**
39 * Called when the current viewController has be successfully dismissed
40 */
41 OverlayProxy.prototype.onDidDismiss = function (callback) {
42 this._onDidDismiss = callback;
43 if (this.overlay) {
44 this.overlay.onDidDismiss(this._onDidDismiss);
45 }
46 };
47 OverlayProxy.prototype.createAndPresentOverlay = function (navOptions) {
48 this.overlay = this.getImplementation();
49 this.overlay.onWillDismiss(this._onWillDismiss);
50 this.overlay.onDidDismiss(this._onDidDismiss);
51 return this.overlay.present(navOptions);
52 };
53 /**
54 * Called when the current viewController will be dismissed
55 */
56 OverlayProxy.prototype.onWillDismiss = function (callback) {
57 this._onWillDismiss = callback;
58 if (this.overlay) {
59 this.overlay.onWillDismiss(this._onWillDismiss);
60 }
61 };
62 return OverlayProxy;
63}());
64export { OverlayProxy };
65//# sourceMappingURL=overlay-proxy.js.map
\No newline at end of file