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[] {
let containers: NavContainer[] = [];
const childNavs = nav.getActiveChildNavs();
const childNavs = nav.getChildNavs();
if (!childNavs || !childNavs.length) {
containers.push(nav);
} else {

View File

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

View File

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

View File

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