UNPKG

3.25 kBJavaScriptView Raw
1import { isString } from '../util/util';
2var OverlayProxy = (function () {
3 /**
4 * @param {?} _app
5 * @param {?} _component
6 * @param {?} _config
7 * @param {?} _deepLinker
8 */
9 function OverlayProxy(_app, _component, _config, _deepLinker) {
10 this._app = _app;
11 this._component = _component;
12 this._config = _config;
13 this._deepLinker = _deepLinker;
14 }
15 /**
16 * @return {?}
17 */
18 OverlayProxy.prototype.getImplementation = function () {
19 throw new Error('Child class must implement "getImplementation" method');
20 };
21 /**
22 * Present the modal instance.
23 *
24 * @param {?=} navOptions
25 * @return {?}
26 */
27 OverlayProxy.prototype.present = function (navOptions) {
28 var _this = this;
29 if (navOptions === void 0) { navOptions = {}; }
30 // check if it's a lazy loaded component, or not
31 var /** @type {?} */ isLazyLoaded = isString(this._component);
32 if (isLazyLoaded) {
33 return this._deepLinker.getComponentFromName(this._component).then(function (loadedComponent) {
34 _this._component = loadedComponent;
35 return _this.createAndPresentOverlay(navOptions);
36 });
37 }
38 else {
39 return this.createAndPresentOverlay(navOptions);
40 }
41 };
42 /**
43 * @param {?=} data
44 * @param {?=} role
45 * @param {?=} navOptions
46 * @return {?}
47 */
48 OverlayProxy.prototype.dismiss = function (data, role, navOptions) {
49 if (this.overlay) {
50 return this.overlay.dismiss(data, role, navOptions);
51 }
52 };
53 /**
54 * Called when the current viewController has be successfully dismissed
55 * @param {?} callback
56 * @return {?}
57 */
58 OverlayProxy.prototype.onDidDismiss = function (callback) {
59 this._onDidDismiss = callback;
60 if (this.overlay) {
61 this.overlay.onDidDismiss(this._onDidDismiss);
62 }
63 };
64 /**
65 * @param {?} navOptions
66 * @return {?}
67 */
68 OverlayProxy.prototype.createAndPresentOverlay = function (navOptions) {
69 this.overlay = this.getImplementation();
70 this.overlay.onWillDismiss(this._onWillDismiss);
71 this.overlay.onDidDismiss(this._onDidDismiss);
72 return this.overlay.present(navOptions);
73 };
74 /**
75 * Called when the current viewController will be dismissed
76 * @param {?} callback
77 * @return {?}
78 */
79 OverlayProxy.prototype.onWillDismiss = function (callback) {
80 this._onWillDismiss = callback;
81 if (this.overlay) {
82 this.overlay.onWillDismiss(this._onWillDismiss);
83 }
84 };
85 return OverlayProxy;
86}());
87export { OverlayProxy };
88function OverlayProxy_tsickle_Closure_declarations() {
89 /** @type {?} */
90 OverlayProxy.prototype.overlay;
91 /** @type {?} */
92 OverlayProxy.prototype._onWillDismiss;
93 /** @type {?} */
94 OverlayProxy.prototype._onDidDismiss;
95 /** @type {?} */
96 OverlayProxy.prototype._app;
97 /** @type {?} */
98 OverlayProxy.prototype._component;
99 /** @type {?} */
100 OverlayProxy.prototype._config;
101 /** @type {?} */
102 OverlayProxy.prototype._deepLinker;
103}
104//# sourceMappingURL=overlay-proxy.js.map
\No newline at end of file