From 1291f8becddd01303f9d3f767ced1fea7ea00306 Mon Sep 17 00:00:00 2001 From: Dan Bucholtz Date: Mon, 18 Sep 2017 09:54:16 -0500 Subject: [PATCH] refactor(app): remove overlay portal --- .../core/src/components/app/app-constants.ts | 4 -- packages/core/src/components/app/app.tsx | 25 +++-------- .../overlay-portal/overlay-portal.tsx | 45 ------------------- .../core/src/navigation/nav-interfaces.ts | 5 --- packages/core/stencil.config.js | 3 +- 5 files changed, 8 insertions(+), 74 deletions(-) delete mode 100644 packages/core/src/components/app/app-constants.ts delete mode 100644 packages/core/src/components/overlay-portal/overlay-portal.tsx diff --git a/packages/core/src/components/app/app-constants.ts b/packages/core/src/components/app/app-constants.ts deleted file mode 100644 index 362d60658b..0000000000 --- a/packages/core/src/components/app/app-constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const PORTAL_DEFAULT = 'general'; -export const PORTAL_LOADING = 'loading'; -export const PORTAL_MODAL = 'modal'; -export const PORTAL_TOAST = 'toast'; diff --git a/packages/core/src/components/app/app.tsx b/packages/core/src/components/app/app.tsx index 895c6b7fa2..5599659d17 100644 --- a/packages/core/src/components/app/app.tsx +++ b/packages/core/src/components/app/app.tsx @@ -1,18 +1,10 @@ import { Element, Component, Listen, Prop } from '@stencil/core'; -import { Nav, NavContainer, OverlayPortal } from '../../navigation/nav-interfaces'; +import { Nav, NavContainer } from '../../navigation/nav-interfaces'; import { Config } from '../..'; import { App } from './app-interfaces'; import { isReady } from '../../utils/helpers'; -import { - PORTAL_DEFAULT, - PORTAL_LOADING, - PORTAL_MODAL, - PORTAL_TOAST -} from './app-constants'; - const rootNavs = new Map(); -const portals = new Map(); @Component({ tag: 'ion-app', @@ -35,20 +27,19 @@ export class IonApp implements App { rootNavs.set((event.detail as Nav).id, (event.detail as Nav)); } - @Listen('body:registerPortal') - registerPortal(event: CustomEvent) { - portals.set((event.detail as OverlayPortal).type, (event.detail as OverlayPortal)); - } + componentWillLoad() { componentDidLoadImpl(this); } getActiveNavs(rootNavId?: number): Nav[] { - const portal = portals.get(PORTAL_MODAL); + /*const portal = portals.get(PORTAL_MODAL); if (portal && portal.views && portal.views.length) { return findTopNavs(portal); } + */ + // TODO - figure out if a modal is open, don't use portal if (!rootNavs.size) { return []; } @@ -79,11 +70,7 @@ export class IonApp implements App { render() { return ([ - , - , - , - , - , + ]); } } diff --git a/packages/core/src/components/overlay-portal/overlay-portal.tsx b/packages/core/src/components/overlay-portal/overlay-portal.tsx deleted file mode 100644 index 54717e9717..0000000000 --- a/packages/core/src/components/overlay-portal/overlay-portal.tsx +++ /dev/null @@ -1,45 +0,0 @@ - -import { Component, Element, Event, EventEmitter, Prop } from '@stencil/core'; -import { Nav, NavContainer, OverlayPortal } from '../../navigation/nav-interfaces'; - -@Component({ - tag: 'ion-overlay-portal' -}) -export class IonOverlayPortal implements NavContainer, OverlayPortal { - - id: number; - name: string; - parent: Nav; - - @Element() element: HTMLElement; - @Prop() type: string; - @Event() registerPortal: EventEmitter; - - getActiveChildNavs(): NavContainer[] { - throw new Error("Method not implemented."); - } - - getAllChildNavs?(): NavContainer[] { - throw new Error("Method not implemented."); - } - - getType(): string { - return 'portal'; - } - - getSecondaryIdentifier(): string { - return null; - } - - componentWillLoad() { - componentWillLoadImpl(this); - } - - render() { - return ; - } -} - -export function componentWillLoadImpl(overlayPortal: OverlayPortal) { - overlayPortal.registerPortal.emit(overlayPortal); -} \ No newline at end of file diff --git a/packages/core/src/navigation/nav-interfaces.ts b/packages/core/src/navigation/nav-interfaces.ts index ef8d6b57ba..ec59b1a6dc 100644 --- a/packages/core/src/navigation/nav-interfaces.ts +++ b/packages/core/src/navigation/nav-interfaces.ts @@ -57,11 +57,6 @@ export interface Nav { setPages?(componentDataPairs: ComponentDataPair[], opts? : NavOptions): Promise; } -export interface OverlayPortal extends Nav { - type?: string; - registerPortal?: EventEmitter; -} - export interface NavController { push(nav: Nav, component: any, data: any, opts: NavOptions): Promise; pop(nav: Nav, opts: NavOptions): Promise; diff --git a/packages/core/stencil.config.js b/packages/core/stencil.config.js index 4712f3aa40..0eb2ed0616 100644 --- a/packages/core/stencil.config.js +++ b/packages/core/stencil.config.js @@ -5,7 +5,7 @@ exports.config = { generateCollection: true, bundles: [ { components: ['ion-animation-controller'] }, - { components: ['ion-app', 'ion-content', 'ion-fixed', 'ion-footer', 'ion-header', 'ion-navbar', 'ion-overlay-portal', 'ion-page', 'ion-title', 'ion-toolbar'] }, + { components: ['ion-app', 'ion-content', 'ion-fixed', 'ion-footer', 'ion-header', 'ion-navbar', 'ion-page', 'ion-title', 'ion-toolbar'] }, { components: ['ion-action-sheet', 'ion-action-sheet-controller'] }, { components: ['ion-alert', 'ion-alert-controller'] }, { components: ['ion-avatar', 'ion-badge', 'ion-thumbnail'] }, @@ -32,6 +32,7 @@ exports.config = { { components: ['ion-tabs', 'ion-tab', 'ion-tab-bar', 'ion-tab-button', 'ion-tab-highlight'] }, { components: ['ion-toggle'] }, { components: ['ion-nav', 'ion-nav-controller', 'stencil-ion-nav-delegate','page-one', 'page-two', 'page-three'] }, + { components: ['ion-toast', 'ion-toast-controller'] }, ], preamble: '(C) Ionic http://ionicframework.com - MIT License',