From 604ed818c8306138e62b1863aeb92544dedfb82b Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 4 Jun 2015 13:36:42 -0500 Subject: [PATCH] tabs wip --- ionic/components/nav/nav-base.js | 2 +- ionic/components/tabs/tab.js | 2 +- .../tabs/test/advanced/pages/tabs.html | 3 + .../tabs/test/advanced/pages/tabs.js | 120 +++++++++++------- 4 files changed, 82 insertions(+), 45 deletions(-) diff --git a/ionic/components/nav/nav-base.js b/ionic/components/nav/nav-base.js index f14bcd2067..65c820e954 100644 --- a/ionic/components/nav/nav-base.js +++ b/ionic/components/nav/nav-base.js @@ -110,7 +110,7 @@ export class NavBase { } push(Component, params = {}, opts = {}) { - if (this.isTransitioning()) { + if (!Component || this.isTransitioning()) { return Promise.reject(); } diff --git a/ionic/components/tabs/tab.js b/ionic/components/tabs/tab.js index 8f1e76f44a..d24e26e813 100644 --- a/ionic/components/tabs/tab.js +++ b/ionic/components/tabs/tab.js @@ -54,7 +54,7 @@ export class Tab { this.viewContainerRef = viewContainerRef; - this.sections = parentNavBase; + this.sections = parentNavBase.panes['_n'].sections; this.navBase.panes['_n'] = this; this.isSelected = false; diff --git a/ionic/components/tabs/test/advanced/pages/tabs.html b/ionic/components/tabs/test/advanced/pages/tabs.html index 012b6f36bb..b5343ba623 100644 --- a/ionic/components/tabs/test/advanced/pages/tabs.html +++ b/ionic/components/tabs/test/advanced/pages/tabs.html @@ -4,4 +4,7 @@ + + + diff --git a/ionic/components/tabs/test/advanced/pages/tabs.js b/ionic/components/tabs/test/advanced/pages/tabs.js index 6b943f6871..556c0c7fd4 100644 --- a/ionic/components/tabs/test/advanced/pages/tabs.js +++ b/ionic/components/tabs/test/advanced/pages/tabs.js @@ -15,7 +15,7 @@ import {Tabs, Tab, NavController, NavbarTemplate, Navbar, Content} from 'ionic/i export class TabsPage { constructor(nav: NavController) { this.tab1Initial = Tab1Page1 - //this.tab2Initial = Tab2Page1 + this.tab2Initial = Tab2Page1 } } @@ -39,7 +39,6 @@ export class TabsPage { export class Tab1Page1 { constructor(nav: NavController) { this.nav = nav; - console.log('Tab1Page1 onInit') } push() { @@ -54,7 +53,8 @@ export class Tab1Page1 { 'Tabs 1 Page 2' + '' + '' + - '

' + + '

' + + '

' + '' + '' + '
', @@ -65,63 +65,97 @@ export class Tab1Page2 { this.nav = nav; } - pop() { - this.nav.push() + push() { + this.nav.push(Tab1Page3) } } +@Component({selector: 'ion-view'}) +@View({ + template: '' + + '' + + 'Tabs 1 Page 3' + + '' + + '' + + '

' + + '' + + '' + + '
', + directives: [NavbarTemplate, Navbar, Content] +}) +export class Tab1Page3 { + constructor(nav: NavController) { + this.nav = nav; + } +} + + // // tab 2 // -@Component({ selector: 't2p1' }) +@Component({selector: 'ion-view'}) @View({ - template: ` - -

Tab 2 Page 1.

- -
I have got an aside on the left. - -
- `, - directives: [Content] + template: '' + + '' + + 'Tabs 2 Page 1' + + '' + + '' + + '

' + + '' + + '' + + '
', + directives: [NavbarTemplate, Navbar, Content] }) -class Tab2Page1 { - // TODO change to 'Nav' injection when we're allowed to inject a tab as a nav. +export class Tab2Page1 { constructor(nav: NavController) { - this.nav = nav + this.nav = nav; } - next() { + + push() { this.nav.push(Tab2Page2) } } -@Component({ selector: 't2p2' }) +@Component({selector: 'ion-view'}) @View({ - template: ` - - - - Nested Tab 1, static content - - - - - - Nested Tab 2, static content - - - - - `, - directives: [Tabs, Tab, Content] + template: '' + + '' + + 'Tabs 2 Page 2' + + '' + + '' + + '

' + + '

' + + '' + + '' + + '
', + directives: [NavbarTemplate, Navbar, Content] }) -class Tab2Page2 { - // TODO change to 'Nav' injection when we're allowed to inject a tab as a nav. +export class Tab2Page2 { constructor(nav: NavController) { - this.nav = nav + this.nav = nav; + } + + push() { + this.nav.push(Tab2Page3) + } +} + +@Component({selector: 'ion-view'}) +@View({ + template: '' + + '' + + 'Tabs 2 Page 3' + + '' + + '' + + '

' + + '' + + '' + + '
', + directives: [NavbarTemplate, Navbar, Content] +}) +export class Tab2Page3 { + constructor(nav: NavController) { + this.nav = nav; } - pop() { this.nav.pop() } }