refactor(nav): update getActiveChildNavs to getChildNavs, publicly expose it

This commit is contained in:
Dan Bucholtz
2018-01-09 00:06:31 -06:00
parent a15f9dfdc6
commit 4a59c3f58d
4 changed files with 18 additions and 8 deletions

View File

@ -104,7 +104,7 @@ export class App {
export function findTopNavs(nav: NavContainer): NavContainer[] { export function findTopNavs(nav: NavContainer): NavContainer[] {
let containers: NavContainer[] = []; let containers: NavContainer[] = [];
const childNavs = nav.getActiveChildNavs(); const childNavs = nav.getChildNavs();
if (!childNavs || !childNavs.length) { if (!childNavs || !childNavs.length) {
containers.push(nav); containers.push(nav);
} else { } else {

View File

@ -22,11 +22,12 @@ export interface PublicNav {
removeView(viewController: PublicViewController, opts?: NavOptions): Promise<any>; removeView(viewController: PublicViewController, opts?: NavOptions): Promise<any>;
setPages(componentDataPairs: any[], opts?: NavOptions): Promise<any>; setPages(componentDataPairs: any[], opts?: NavOptions): Promise<any>;
getActive?(): PublicViewController; getActive(): PublicViewController;
getPrevious?(view?: PublicViewController): PublicViewController; getPrevious(view?: PublicViewController): PublicViewController;
canGoBack?(): boolean; canGoBack(): boolean;
canSwipeBack?(): boolean; canSwipeBack(): boolean;
getFirstView?(): PublicViewController; getFirstView(): PublicViewController;
getChildNavs(): PublicNav[];
element?: HTMLElement; element?: HTMLElement;
} }
@ -35,7 +36,7 @@ export interface NavContainer {
id?: number; id?: number;
name?: string; name?: string;
parent?: Nav; parent?: Nav;
getActiveChildNavs?(): NavContainer[]; getChildNavs?(): NavContainer[];
getAllChildNavs?(): NavContainer[]; getAllChildNavs?(): NavContainer[];
getType?(): string; getType?(): string;
getSecondaryIdentifier?(): string; getSecondaryIdentifier?(): string;

View File

@ -6,6 +6,7 @@ import {
ComponentDataPair, ComponentDataPair,
Config, Config,
FrameworkDelegate, FrameworkDelegate,
NavContainer,
NavOptions, NavOptions,
NavResult, NavResult,
NavState, NavState,
@ -60,7 +61,7 @@ const queueMap = new Map<number, TransitionInstruction[]>();
tag: 'ion-nav', tag: 'ion-nav',
styleUrl: 'nav.scss' styleUrl: 'nav.scss'
}) })
export class Nav implements PublicNav { export class Nav implements PublicNav, NavContainer {
@Element() element: HTMLElement; @Element() element: HTMLElement;
@Event() navInit: EventEmitter; @Event() navInit: EventEmitter;
@ -217,6 +218,11 @@ export class Nav implements PublicNav {
return this.routes; return this.routes;
} }
@Method()
getChildNavs(): PublicNav[] {
return this.childNavs || [];
}
render() { render() {
return <slot></slot>; return <slot></slot>;
} }

View File

@ -58,6 +58,9 @@ any
#### getActive() #### getActive()
#### getChildNavs()
#### getFirstView() #### getFirstView()