diff --git a/packages/core/src/components/nav/nav.tsx b/packages/core/src/components/nav/nav.tsx index f2171ccc3c..bc666f4424 100644 --- a/packages/core/src/components/nav/nav.tsx +++ b/packages/core/src/components/nav/nav.tsx @@ -1,4 +1,4 @@ -import { Component, Element, Method, Prop } from '@stencil/core'; +import { Component, Element, Event, EventEmitter, Method, Prop } from '@stencil/core'; import { AnimationController, Config } from '../..'; import { ComponentDataPair, FrameworkDelegate, Nav, NavController, NavOptions, ViewController } from '../../navigation/nav-interfaces'; @@ -11,6 +11,8 @@ import { isReady } from '../../utils/helpers'; export class IonNav implements Nav { @Element() element: HTMLElement; + @Event() navInit: EventEmitter; + id: number; parent: Nav; views: ViewController[]; @@ -33,7 +35,8 @@ export class IonNav implements Nav { } ionViewDidLoad() { - this.setRoot(this.root); + ionViewDidLoadImpl(this); + } getViews(): ViewController[] { @@ -41,52 +44,52 @@ export class IonNav implements Nav { } @Method() - push(component: any, data?: any, opts?: NavOptions) { + push(component: any, data?: any, opts?: NavOptions): Promise { return pushImpl(this, component, data, opts); } @Method() - pop(opts?: NavOptions) { + pop(opts?: NavOptions): Promise { return popImpl(this, opts); } @Method() - setRoot(component: any, data?: any, opts?: NavOptions) { + setRoot(component: any, data?: any, opts?: NavOptions): Promise { return setRootImpl(this, component, data, opts); } @Method() - insert(insertIndex: number, page: any, params?: any, opts?: NavOptions) { + insert(insertIndex: number, page: any, params?: any, opts?: NavOptions): Promise { return insertImpl(this, insertIndex, page, params, opts); } @Method() - insertPages(insertIndex: number, insertPages: any[], opts?: NavOptions) { + insertPages(insertIndex: number, insertPages: any[], opts?: NavOptions): Promise { return insertPagesImpl(this, insertIndex, insertPages, opts); } @Method() - popToRoot(opts?: NavOptions) { + popToRoot(opts?: NavOptions): Promise { return popToRootImpl(this, opts); } @Method() - popTo(indexOrViewCtrl: any, opts?: NavOptions) { + popTo(indexOrViewCtrl: any, opts?: NavOptions): Promise { return popToImpl(this, indexOrViewCtrl, opts); } @Method() - remove(startIndex: number, removeCount?: number, opts?: NavOptions) { + remove(startIndex: number, removeCount?: number, opts?: NavOptions): Promise { return removeImpl(this, startIndex, removeCount, opts); } @Method() - removeView(viewController: ViewController, opts?: NavOptions) { + removeView(viewController: ViewController, opts?: NavOptions): Promise { return removeViewImpl(this, viewController, opts); } @Method() - setPages(componentDataPairs: ComponentDataPair[], opts? : NavOptions) { + setPages(componentDataPairs: ComponentDataPair[], opts? : NavOptions): Promise { return setPagesImpl(this, componentDataPairs, opts); } @@ -120,6 +123,13 @@ export class IonNav implements Nav { } } +export function ionViewDidLoadImpl(nav: Nav) { + nav. + if (nav.root) { + nav.setRoot(nav.root); + } +} + export function pushImpl(nav: Nav, component: any, data: any, opts: NavOptions) { return getNavController(nav).then(() => { return nav.navController.push(nav, component, data, opts); diff --git a/packages/core/src/navigation/nav-interfaces.d.ts b/packages/core/src/navigation/nav-interfaces.d.ts index 182828ed18..c01e677891 100644 --- a/packages/core/src/navigation/nav-interfaces.d.ts +++ b/packages/core/src/navigation/nav-interfaces.d.ts @@ -23,11 +23,22 @@ export interface Nav { swipeToGoBackTransition?: any; // TODO Transition navController?: NavController; parent?: Nav; + childNavs?: Nav[]; // TODO - make nav container + root?: any; + getActive(): ViewController; getPrevious(view?: ViewController): ViewController; - childNavs?: Nav[]; // TODO - make nav container - animationCtrl?: AnimationController; - config?: Config; + getViews(): ViewController[]; + push(component: any, data?: any, opts?: NavOptions): Promise; + pop(opts?: NavOptions): Promise; + setRoot(component: any, data?: any, opts?: NavOptions): Promise; + insert(insertIndex: number, page: any, params?: any, opts?: NavOptions): Promise; + insertPages(insertIndex: number, insertPages: any[], opts?: NavOptions): Promise; + popToRoot(opts?: NavOptions): Promise; + popTo(indexOrViewCtrl: any, opts?: NavOptions): Promise; + remove(startIndex: number, removeCount?: number, opts?: NavOptions): Promise; + removeView(viewController: ViewController, opts?: NavOptions): Promise; + setPages(componentDataPairs: ComponentDataPair[], opts? : NavOptions): Promise; } export interface NavController {