@@ -7,23 +7,25 @@ import { NavControllerBase } from './nav-controller-base';
7
7
import { Transition } from '../transitions/transition' ;
8
8
9
9
10
+ export function getComponent ( linker : DeepLinker , nameOrPageOrView : any ) : any {
11
+ if ( typeof nameOrPageOrView === 'function' ) {
12
+ return nameOrPageOrView ;
13
+ }
14
+ if ( typeof nameOrPageOrView === 'string' ) {
15
+ return linker . getComponentFromName ( nameOrPageOrView ) ;
16
+ }
17
+ return null ;
18
+ }
19
+
10
20
export function convertToView ( linker : DeepLinker , nameOrPageOrView : any , params : any ) : ViewController {
11
21
if ( nameOrPageOrView ) {
12
22
if ( isViewController ( nameOrPageOrView ) ) {
13
23
// is already a ViewController
14
24
return nameOrPageOrView ;
15
25
}
16
- if ( typeof nameOrPageOrView === 'function' ) {
17
- // is a page component, now turn it into a ViewController
18
- return new ViewController ( nameOrPageOrView , params ) ;
19
- }
20
- if ( typeof nameOrPageOrView === 'string' ) {
21
- // is a string, see if it matches a
22
- const component = linker . getComponentFromName ( nameOrPageOrView ) ;
23
- if ( component ) {
24
- // found a page component in the link config by name
25
- return new ViewController ( component , params ) ;
26
- }
26
+ let component = getComponent ( linker , nameOrPageOrView ) ;
27
+ if ( component ) {
28
+ return new ViewController ( component , params ) ;
27
29
}
28
30
}
29
31
console . error ( `invalid page component: ${ nameOrPageOrView } ` ) ;
@@ -77,17 +79,17 @@ export function setZIndex(nav: NavControllerBase, enteringView: ViewController,
77
79
}
78
80
}
79
81
80
- export function isTabs ( nav : any ) {
82
+ export function isTabs ( nav : any ) : boolean {
81
83
// Tabs (ion-tabs)
82
84
return ! ! nav && ! ! nav . getSelected ;
83
85
}
84
86
85
- export function isTab ( nav : any ) {
87
+ export function isTab ( nav : any ) : boolean {
86
88
// Tab (ion-tab)
87
89
return ! ! nav && isPresent ( nav . _tabId ) ;
88
90
}
89
91
90
- export function isNav ( nav : any ) {
92
+ export function isNav ( nav : any ) : boolean {
91
93
// Nav (ion-nav), Tab (ion-tab), Portal (ion-portal)
92
94
return ! ! nav && ! ! nav . push ;
93
95
}
0 commit comments