fix(navigation): add isTab check to getSegmentsFromNav

This commit is contained in:
Dan Bucholtz
2017-06-20 10:20:39 -05:00
parent 6f7acdbddf
commit f39c3811c5
19 changed files with 304 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
import { Component } from '@angular/core';
@Component({
template: `<ion-nav [root]="root"></ion-nav>`
})
export class AppComponent {
root = 'SecondNav';
}

View File

@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule } from '../../../../..';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
IonicModule.forRoot(AppComponent, { swipeBackEnabled: true, preloadModules: true }),
],
bootstrap: [IonicApp]
})
export class AppModule {}

View File

@@ -0,0 +1,5 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);

View File

@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from '../../../../../..';
import { FirstPage } from './first-page';
@NgModule({
imports: [
IonicPageModule.forChild(FirstPage)
],
declarations: [
FirstPage
]
})
export class FirstPageModule { }

View File

@@ -0,0 +1,27 @@
import { Component } from '@angular/core';
import { IonicPage, NavController } from '../../../../../..';
@IonicPage()
@Component({
selector: 'page-home',
template: `
<ion-header>
<ion-navbar>
<ion-title>Tab 1</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<button ion-button (click)="goToNextPage()">Go to Next Page</button>
</ion-content>
`
})
export class FirstPage {
constructor(public navCtrl: NavController) {
}
goToNextPage() {
this.navCtrl.push('ThirdNav');
}
}

View File

@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from '../../../../../..';
import { HomePage } from './home';
@NgModule({
imports: [
IonicPageModule.forChild(HomePage)
],
declarations: [
HomePage
]
})
export class HomePageModule { }

View File

@@ -0,0 +1,3 @@
page-home {
}

View File

@@ -0,0 +1,36 @@
import { Component } from '@angular/core';
import { IonicPage, NavController } from '../../../../../..';
@IonicPage()
@Component({
selector: 'page-home',
template: `
<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
The world is your oyster.
<p>
If you get lost, the <a href="http://ionicframework.com/docs/v2">docs</a> will be your guide.
</p>
<button ion-button (click)="clickMe()">Go to Tabs</button>
</ion-content>
`
})
export class HomePage {
constructor(public navCtrl: NavController) {
}
clickMe() {
this.navCtrl.push('TabsPage', { paramOne: 'ParamOneData', paramTwo: 'ParamTwoData'});
}
}

View File

@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from '../../../../../..';
import { SecondNav } from './second-nav';
@NgModule({
imports: [
IonicPageModule.forChild(SecondNav)
],
declarations: [
SecondNav
]
})
export class SecondNavModule { }

View File

@@ -0,0 +1,19 @@
import { Component } from '@angular/core';
import { IonicPage, NavController } from '../../../../../..';
@IonicPage()
@Component({
selector: 'page-home',
template: `
<ion-nav [root]="rootPage"></ion-nav>
`
})
export class SecondNav {
rootPage:any = 'HomePage';
constructor(public navCtrl: NavController) {
}
}

View File

@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from '../../../../../..';
import { SecondPage } from './second-page';
@NgModule({
imports: [
IonicPageModule.forChild(SecondPage)
],
declarations: [
SecondPage
]
})
export class SecondPageModule { }

View File

@@ -0,0 +1,24 @@
import { Component } from '@angular/core';
import { IonicPage, NavController } from '../../../../../..';
@IonicPage()
@Component({
selector: 'page-home',
template: `
<ion-header>
<ion-navbar>
<ion-title>Tab 2</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
Second Page
</ion-content>
`
})
export class SecondPage {
constructor(public navCtrl: NavController) {
}
}

View File

@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from '../../../../../..';
import { TabsPage } from './tabs';
@NgModule({
imports: [
IonicPageModule.forChild(TabsPage)
],
declarations: [
TabsPage
]
})
export class TabsPageModule { }

View File

@@ -0,0 +1,28 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from '../../../../../..';
@IonicPage({
segment: 'toot/:paramOne/beep/:paramTwo'
})
@Component({
template: `
<ion-tabs>
<ion-tab tabIcon="heart" [root]="tab1" tabTitle="Taco Burrito Enchilada"></ion-tab>
<ion-tab tabIcon="star" [root]="tab2"></ion-tab>
</ion-tabs>
`
})
export class TabsPage {
tab1 = 'FirstPage';
tab2 = 'SecondPage';
constructor(public nav: NavController, public params: NavParams) {
}
ionViewDidEnter() {
console.log('paramOne: ', this.params.data.paramOne);
console.log('paramTwo: ', this.params.data.paramTwo);
}
}

View File

@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from '../../../../../..';
import { ThirdNav } from './third-nav';
@NgModule({
imports: [
IonicPageModule.forChild(ThirdNav)
],
declarations: [
ThirdNav
]
})
export class ThirdNavModule { }

View File

@@ -0,0 +1,19 @@
import { Component } from '@angular/core';
import { IonicPage, NavController } from '../../../../../..';
@IonicPage()
@Component({
selector: 'page-home',
template: `
<ion-nav [root]="rootPage"></ion-nav>
`
})
export class ThirdNav {
rootPage:any = 'ThirdPage';
constructor(public navCtrl: NavController) {
}
}

View File

@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from '../../../../../..';
import { ThirdPage } from './third-page';
@NgModule({
imports: [
IonicPageModule.forChild(ThirdPage)
],
declarations: [
ThirdPage
]
})
export class ThirdPageModule { }

View File

@@ -0,0 +1,24 @@
import { Component } from '@angular/core';
import { IonicPage, NavController } from '../../../../../..';
@IonicPage()
@Component({
selector: 'page-home',
template: `
<ion-header>
<ion-navbar>
<ion-title>Tab 1</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
Third Page
</ion-content>
`
})
export class ThirdPage {
constructor(public navCtrl: NavController) {
}
}

View File

@@ -147,9 +147,11 @@ export class DeepLinker {
if (isNav(nav)) {
segments.push(this.getSegmentFromNav(nav as NavController));
nav = nav.parent;
} else {
} else if (isTab(nav)) {
segments.push(this.getSegmentFromTab(nav));
nav = nav.parent && nav.parent.parent;
} else {
nav = nav.parent;
}
}
return segments.reverse();