@@ -7,7 +7,7 @@ import {IonicApp} from '../app/app';
7
7
import { Keyboard } from '../../util/keyboard' ;
8
8
import { NavParams } from './nav-params' ;
9
9
import { NavRouter } from './nav-router' ;
10
- import { pascalCaseToDashCase , isTrueProperty , isUndefined } from '../../util/util' ;
10
+ import { pascalCaseToDashCase , isTrueProperty , isBlank } from '../../util/util' ;
11
11
import { raf } from '../../util/dom' ;
12
12
import { SwipeBackGesture } from './swipe-back' ;
13
13
import { Transition } from '../../transitions/transition' ;
@@ -178,7 +178,7 @@ export class NavController extends Ion {
178
178
* @param {object } [opts={}] Any options you want to use pass to transtion
179
179
* @returns {Promise } Returns a promise when done
180
180
*/
181
- setRoot ( page : Type , params : any = { } , opts : NavOptions = { } ) : Promise < any > {
181
+ setRoot ( page : Type , params ? : any , opts ? : NavOptions ) : Promise < any > {
182
182
return this . setPages ( [ { page, params} ] , opts ) ;
183
183
}
184
184
@@ -255,11 +255,15 @@ export class NavController extends Ion {
255
255
* @param {object } [opts={}] Any options you want to use pass
256
256
* @returns {Promise } Returns a promise when the pages are set
257
257
*/
258
- setPages ( pages : Array < { page : Type , params ?: any } > , opts : NavOptions = { } ) : Promise < any > {
258
+ setPages ( pages : Array < { page : Type , params ?: any } > , opts ? : NavOptions ) : Promise < any > {
259
259
if ( ! pages || ! pages . length ) {
260
260
return Promise . resolve ( false ) ;
261
261
}
262
262
263
+ if ( isBlank ( opts ) ) {
264
+ opts = { } ;
265
+ }
266
+
263
267
// deprecated warning
264
268
pages . forEach ( pg => {
265
269
if ( pg [ 'componentType' ] ) {
@@ -303,7 +307,7 @@ export class NavController extends Ion {
303
307
/**
304
308
* @private
305
309
*/
306
- private setViews ( components , opts : NavOptions = { } ) {
310
+ private setViews ( components , opts ? : NavOptions ) {
307
311
console . warn ( 'setViews() deprecated, use setPages() instead' ) ;
308
312
return this . setPages ( components , opts ) ;
309
313
}
@@ -373,7 +377,7 @@ export class NavController extends Ion {
373
377
* @param {object } [opts={}] Any options you want to use pass to transtion
374
378
* @returns {Promise } Returns a promise, which resolves when the transition has completed
375
379
*/
376
- push ( page : Type , params : any = { } , opts : NavOptions = { } ) {
380
+ push ( page : Type , params ? : any , opts ? : NavOptions ) {
377
381
return this . insertPages ( - 1 , [ { page : page , params : params } ] , opts ) ;
378
382
}
379
383
@@ -402,7 +406,7 @@ export class NavController extends Ion {
402
406
* @param {object } [opts={}] Any options you want to use pass to transtion
403
407
* @returns {Promise } Returns a promise, which resolves when the transition has completed
404
408
*/
405
- present ( enteringView : ViewController , opts : NavOptions = { } ) : Promise < any > {
409
+ present ( enteringView : ViewController , opts ? : NavOptions ) : Promise < any > {
406
410
let rootNav = this . rootNav ;
407
411
408
412
if ( rootNav [ '_tabs' ] ) {
@@ -412,6 +416,10 @@ export class NavController extends Ion {
412
416
return ;
413
417
}
414
418
419
+ if ( isBlank ( opts ) ) {
420
+ opts = { } ;
421
+ }
422
+
415
423
enteringView . setNav ( rootNav ) ;
416
424
417
425
opts . keyboardClose = false ;
@@ -454,7 +462,7 @@ export class NavController extends Ion {
454
462
* @param {object } [opts={}] Any options you want to use pass to transtion
455
463
* @returns {Promise } Returns a promise when the page has been inserted into the navigation stack
456
464
*/
457
- insert ( insertIndex : number , page : Type , params : any = { } , opts : NavOptions = { } ) : Promise < any > {
465
+ insert ( insertIndex : number , page : Type , params ? : any , opts ? : NavOptions ) : Promise < any > {
458
466
return this . insertPages ( insertIndex , [ { page : page , params : params } ] , opts ) ;
459
467
}
460
468
@@ -486,16 +494,20 @@ export class NavController extends Ion {
486
494
* @param {object } [opts={}] Any options you want to use pass to transtion
487
495
* @returns {Promise } Returns a promise when the pages have been inserted into the navigation stack
488
496
*/
489
- insertPages ( insertIndex : number , insertPages : Array < { page : Type , params ?: any } > , opts : NavOptions = { } ) : Promise < any > {
497
+ insertPages ( insertIndex : number , insertPages : Array < { page : Type , params ?: any } > , opts ? : NavOptions ) : Promise < any > {
490
498
let views = insertPages . map ( p => new ViewController ( p . page , p . params ) ) ;
491
499
return this . _insertViews ( insertIndex , views , opts ) ;
492
500
}
493
501
494
- private _insertViews ( insertIndex : number , insertViews : Array < ViewController > , opts : NavOptions = { } ) : Promise < any > {
502
+ private _insertViews ( insertIndex : number , insertViews : Array < ViewController > , opts ? : NavOptions ) : Promise < any > {
495
503
if ( ! insertViews || ! insertViews . length ) {
496
504
return Promise . reject ( 'invalid pages' ) ;
497
505
}
498
506
507
+ if ( isBlank ( opts ) ) {
508
+ opts = { } ;
509
+ }
510
+
499
511
// insert the new page into the stack
500
512
// returns the newly created entering view
501
513
let enteringView = this . _insert ( insertIndex , insertViews ) ;
@@ -616,16 +628,20 @@ export class NavController extends Ion {
616
628
* @param {object } [opts={}] Any options you want to use pass to transtion
617
629
* @returns {Promise } Returns a promise when the transition is completed
618
630
*/
619
- pop ( opts : NavOptions = { } ) : Promise < any > {
631
+ pop ( opts ? : NavOptions ) : Promise < any > {
620
632
// get the index of the active view
621
633
// which will become the view to be leaving
622
634
let activeView = this . getByState ( STATE_TRANS_ENTER ) ||
623
635
this . getByState ( STATE_INIT_ENTER ) ||
624
636
this . getActive ( ) ;
625
637
638
+ if ( isBlank ( opts ) ) {
639
+ opts = { } ;
640
+ }
641
+
626
642
// if not set, by default climb up the nav controllers if
627
643
// there isn't a previous view in this nav controller
628
- if ( isUndefined ( opts . climbNav ) ) {
644
+ if ( isBlank ( opts . climbNav ) ) {
629
645
opts . climbNav = true ;
630
646
}
631
647
return this . remove ( this . indexOf ( activeView ) , 1 , opts ) ;
@@ -635,7 +651,7 @@ export class NavController extends Ion {
635
651
* Similar to `pop()`, this method let's you navigate back to the root of the stack, no matter how many views that is
636
652
* @param {object } [opts={}] Any options you want to use pass to transtion
637
653
*/
638
- popToRoot ( opts : NavOptions = { } ) : Promise < any > {
654
+ popToRoot ( opts ? : NavOptions ) : Promise < any > {
639
655
return this . popTo ( this . first ( ) , opts ) ;
640
656
}
641
657
@@ -644,7 +660,7 @@ export class NavController extends Ion {
644
660
* @param {ViewController } view to pop to
645
661
* @param {object } [opts={}] Any options you want to use pass to transtion
646
662
*/
647
- popTo ( view : ViewController , opts : NavOptions = { } ) : Promise < any > {
663
+ popTo ( view : ViewController , opts ? : NavOptions ) : Promise < any > {
648
664
let startIndex = this . indexOf ( view ) ;
649
665
let activeView = this . getByState ( STATE_TRANS_ENTER ) ||
650
666
this . getByState ( STATE_INIT_ENTER ) ||
@@ -673,14 +689,18 @@ export class NavController extends Ion {
673
689
* @param {object } [opts={}] Any options you want to use pass to transtion.
674
690
* @returns {Promise } Returns a promise when the page has been removed.
675
691
*/
676
- remove ( startIndex : number = - 1 , removeCount : number = 1 , opts : NavOptions = { } ) : Promise < any > {
692
+ remove ( startIndex : number = - 1 , removeCount : number = 1 , opts ? : NavOptions ) : Promise < any > {
677
693
if ( startIndex === - 1 ) {
678
694
startIndex = this . _views . length - 1 ;
679
695
680
696
} else if ( startIndex < 0 || startIndex >= this . _views . length ) {
681
697
return Promise . reject ( "remove index out of range" ) ;
682
698
}
683
699
700
+ if ( isBlank ( opts ) ) {
701
+ opts = { } ;
702
+ }
703
+
684
704
// default the direction to "back"
685
705
opts . direction = opts . direction || 'back' ;
686
706
@@ -878,8 +898,11 @@ export class NavController extends Ion {
878
898
// lets time this sucker, ready go
879
899
let wtfScope = wtfStartTimeRange ( 'NavController#_transition' , ( enteringView && enteringView . name ) ) ;
880
900
881
- if ( this . config . get ( 'animate' ) === false ||
882
- ( this . _views . length === 1 && ! this . _init ) ) {
901
+ if ( isBlank ( opts ) ) {
902
+ opts = { } ;
903
+ }
904
+
905
+ if ( this . config . get ( 'animate' ) === false || ( this . _views . length === 1 && ! this . _init ) ) {
883
906
opts . animate = false ;
884
907
}
885
908
0 commit comments