a zip code crypto-currency system good for red ONLY

overlay-proxy.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { isString } from '../util/util';
  2. export class OverlayProxy {
  3. constructor(_app, _component, _config, _deepLinker) {
  4. this._app = _app;
  5. this._component = _component;
  6. this._config = _config;
  7. this._deepLinker = _deepLinker;
  8. }
  9. getImplementation() {
  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. present(navOptions = {}) {
  19. // check if it's a lazy loaded component, or not
  20. const isLazyLoaded = isString(this._component);
  21. if (isLazyLoaded) {
  22. return this._deepLinker.getComponentFromName(this._component).then((loadedComponent) => {
  23. this._component = loadedComponent;
  24. return this.createAndPresentOverlay(navOptions);
  25. });
  26. }
  27. else {
  28. return this.createAndPresentOverlay(navOptions);
  29. }
  30. }
  31. dismiss(data, role, navOptions) {
  32. if (this.overlay) {
  33. return this.overlay.dismiss(data, role, navOptions);
  34. }
  35. }
  36. /**
  37. * Called when the current viewController has be successfully dismissed
  38. */
  39. onDidDismiss(callback) {
  40. this._onDidDismiss = callback;
  41. if (this.overlay) {
  42. this.overlay.onDidDismiss(this._onDidDismiss);
  43. }
  44. }
  45. createAndPresentOverlay(navOptions) {
  46. this.overlay = this.getImplementation();
  47. this.overlay.onWillDismiss(this._onWillDismiss);
  48. this.overlay.onDidDismiss(this._onDidDismiss);
  49. return this.overlay.present(navOptions);
  50. }
  51. /**
  52. * Called when the current viewController will be dismissed
  53. */
  54. onWillDismiss(callback) {
  55. this._onWillDismiss = callback;
  56. if (this.overlay) {
  57. this.overlay.onWillDismiss(this._onWillDismiss);
  58. }
  59. }
  60. }
  61. //# sourceMappingURL=overlay-proxy.js.map