mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +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 { 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 { Config } from '../..';
|
||||||
import { App } from './app-interfaces';
|
import { App } from './app-interfaces';
|
||||||
import { isReady } from '../../utils/helpers';
|
import { isReady } from '../../utils/helpers';
|
||||||
|
|
||||||
import {
|
|
||||||
PORTAL_DEFAULT,
|
|
||||||
PORTAL_LOADING,
|
|
||||||
PORTAL_MODAL,
|
|
||||||
PORTAL_TOAST
|
|
||||||
} from './app-constants';
|
|
||||||
|
|
||||||
const rootNavs = new Map<number, Nav>();
|
const rootNavs = new Map<number, Nav>();
|
||||||
const portals = new Map<string, OverlayPortal>();
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-app',
|
tag: 'ion-app',
|
||||||
@ -35,20 +27,19 @@ export class IonApp implements App {
|
|||||||
rootNavs.set((event.detail as Nav).id, (event.detail as Nav));
|
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() {
|
componentWillLoad() {
|
||||||
componentDidLoadImpl(this);
|
componentDidLoadImpl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveNavs(rootNavId?: number): Nav[] {
|
getActiveNavs(rootNavId?: number): Nav[] {
|
||||||
const portal = portals.get(PORTAL_MODAL);
|
/*const portal = portals.get(PORTAL_MODAL);
|
||||||
if (portal && portal.views && portal.views.length) {
|
if (portal && portal.views && portal.views.length) {
|
||||||
return findTopNavs(portal);
|
return findTopNavs(portal);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
// TODO - figure out if a modal is open, don't use portal
|
||||||
if (!rootNavs.size) {
|
if (!rootNavs.size) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@ -79,11 +70,7 @@ export class IonApp implements App {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return ([
|
return ([
|
||||||
<slot></slot>,
|
<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>,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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>;
|
setPages?(componentDataPairs: ComponentDataPair[], opts? : NavOptions): Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OverlayPortal extends Nav {
|
|
||||||
type?: string;
|
|
||||||
registerPortal?: EventEmitter;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NavController {
|
export interface NavController {
|
||||||
push(nav: Nav, component: any, data: any, opts: NavOptions): Promise<any>;
|
push(nav: Nav, component: any, data: any, opts: NavOptions): Promise<any>;
|
||||||
pop(nav: Nav, opts: NavOptions): Promise<any>;
|
pop(nav: Nav, opts: NavOptions): Promise<any>;
|
||||||
|
@ -5,7 +5,7 @@ exports.config = {
|
|||||||
generateCollection: true,
|
generateCollection: true,
|
||||||
bundles: [
|
bundles: [
|
||||||
{ components: ['ion-animation-controller'] },
|
{ 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-action-sheet', 'ion-action-sheet-controller'] },
|
||||||
{ components: ['ion-alert', 'ion-alert-controller'] },
|
{ components: ['ion-alert', 'ion-alert-controller'] },
|
||||||
{ components: ['ion-avatar', 'ion-badge', 'ion-thumbnail'] },
|
{ 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-tabs', 'ion-tab', 'ion-tab-bar', 'ion-tab-button', 'ion-tab-highlight'] },
|
||||||
{ components: ['ion-toggle'] },
|
{ components: ['ion-toggle'] },
|
||||||
{ components: ['ion-nav', 'ion-nav-controller', 'stencil-ion-nav-delegate','page-one', 'page-two', 'page-three'] },
|
{ components: ['ion-nav', 'ion-nav-controller', 'stencil-ion-nav-delegate','page-one', 'page-two', 'page-three'] },
|
||||||
|
|
||||||
{ components: ['ion-toast', 'ion-toast-controller'] },
|
{ components: ['ion-toast', 'ion-toast-controller'] },
|
||||||
],
|
],
|
||||||
preamble: '(C) Ionic http://ionicframework.com - MIT License',
|
preamble: '(C) Ionic http://ionicframework.com - MIT License',
|
||||||
|
Reference in New Issue
Block a user