mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 18:54:11 +08:00
refactor(app): remove overlay portal
This commit is contained in:
@ -1,4 +0,0 @@
|
||||
export const PORTAL_DEFAULT = 'general';
|
||||
export const PORTAL_LOADING = 'loading';
|
||||
export const PORTAL_MODAL = 'modal';
|
||||
export const PORTAL_TOAST = 'toast';
|
@ -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<number, Nav>();
|
||||
const portals = new Map<string, OverlayPortal>();
|
||||
|
||||
@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 ([
|
||||
<slot></slot>,
|
||||
<ion-overlay-portal type={PORTAL_MODAL}></ion-overlay-portal>,
|
||||
<ion-overlay-portal type={PORTAL_DEFAULT}></ion-overlay-portal>,
|
||||
<ion-overlay-portal type={PORTAL_LOADING}></ion-overlay-portal>,
|
||||
<ion-overlay-portal type={PORTAL_TOAST}></ion-overlay-portal>,
|
||||
<slot></slot>
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -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 <slot></slot>;
|
||||
}
|
||||
}
|
||||
|
||||
export function componentWillLoadImpl(overlayPortal: OverlayPortal) {
|
||||
overlayPortal.registerPortal.emit(overlayPortal);
|
||||
}
|
@ -57,11 +57,6 @@ export interface Nav {
|
||||
setPages?(componentDataPairs: ComponentDataPair[], opts? : NavOptions): Promise<any>;
|
||||
}
|
||||
|
||||
export interface OverlayPortal extends Nav {
|
||||
type?: string;
|
||||
registerPortal?: EventEmitter;
|
||||
}
|
||||
|
||||
export interface NavController {
|
||||
push(nav: Nav, component: any, data: any, opts: NavOptions): Promise<any>;
|
||||
pop(nav: Nav, opts: NavOptions): Promise<any>;
|
||||
|
@ -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',
|
||||
|
Reference in New Issue
Block a user