mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
refactor(nav): move stage to nav-controller
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Component, ElementRef, Renderer} from 'angular2/angular2';
|
||||
import {Component} from 'angular2/angular2';
|
||||
|
||||
|
||||
/**
|
||||
@@ -24,10 +24,13 @@ import {Component, ElementRef, Renderer} from 'angular2/angular2';
|
||||
'<ng-content select="[item-right]"></ng-content>' +
|
||||
'<ion-item-content>' +
|
||||
'<ng-content></ng-content>'+
|
||||
'</ion-item-content>'
|
||||
'</ion-item-content>',
|
||||
host: {
|
||||
'[class.item]': 'isItem'
|
||||
}
|
||||
})
|
||||
export class Item {
|
||||
constructor(elementRef: ElementRef, renderer: Renderer) {
|
||||
renderer.setElementClass(elementRef, 'item', true);
|
||||
constructor() {
|
||||
this.isItem = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,6 @@ export class NavController extends Ion {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
opts.direction = opts.direction || 'back';
|
||||
|
||||
// get the views to auto remove without having to do a transiton for each
|
||||
@@ -452,7 +451,7 @@ export class NavController extends Ion {
|
||||
}
|
||||
|
||||
// wait for the new view to complete setup
|
||||
enteringView.stage(() => {
|
||||
this.stage(enteringView, () => {
|
||||
|
||||
if (enteringView.shouldDestroy) {
|
||||
// already marked as a view that will be destroyed, don't continue
|
||||
@@ -515,6 +514,30 @@ export class NavController extends Ion {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
stage(viewCtrl, done) {
|
||||
if (viewCtrl.instance || viewCtrl.shouldDestroy) {
|
||||
// already compiled this view
|
||||
return done();
|
||||
}
|
||||
|
||||
// get the pane the NavController wants to use
|
||||
// the pane is where all this content will be placed into
|
||||
this.loadPage(viewCtrl, null, () => {
|
||||
|
||||
// this ViewController instance has finished loading
|
||||
try {
|
||||
viewCtrl.loaded();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
loadPage(viewCtrl, navbarContainerRef, done) {
|
||||
let providers = this.providers.concat(Injector.resolve([
|
||||
provide(ViewController, {useValue: viewCtrl}),
|
||||
|
||||
@@ -14,18 +14,24 @@ import {NavParams, NavController, ViewController} from 'ionic/ionic';
|
||||
<button>S1</button>
|
||||
</ion-nav-items>
|
||||
</ion-navbar>
|
||||
<ion-content padding>
|
||||
<p>{{title}}</p>
|
||||
<p><button class="e2eFrom1To2" (click)="pushFullPage()">Push to FullPage</button></p>
|
||||
<p><button (click)="pushPrimaryHeaderPage()">Push to PrimaryHeaderPage</button></p>
|
||||
<p><button (click)="pushAnother()">Push to AnotherPage</button></p>
|
||||
<p><button [nav-push]="[pushPage, {id: 42}]">Push FullPage w/ [nav-push] array</button></p>
|
||||
<p><button [nav-push]="pushPage" [nav-params]="{id:40}">Push w/ [nav-push] and [nav-params]</button></p>
|
||||
<p><button [nav-push]="[\'FirstPage\', {id: 22}]">Push w/ [nav-push] array and string view name</button></p>
|
||||
<p><button nav-push="FirstPage" [nav-params]="{id: 23}">Push w/ nav-push and [nav-params]</button></p>
|
||||
<p><button (click)="setViews()">setViews() (Go to PrimaryHeaderPage)</button></p>
|
||||
<p><button (click)="nav.pop()">Pop</button></p>
|
||||
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<ion-header>
|
||||
{{title}}
|
||||
</ion-header>
|
||||
|
||||
<button ion-item class="e2eFrom1To2" (click)="pushFullPage()">Push to FullPage</button>
|
||||
<button ion-item (click)="pushPrimaryHeaderPage()">Push to PrimaryHeaderPage</button>
|
||||
<button ion-item (click)="pushAnother()">Push to AnotherPage</button>
|
||||
<button ion-item [nav-push]="[pushPage, {id: 42}]">Push FullPage w/ [nav-push] array</button>
|
||||
<button ion-item [nav-push]="pushPage" [nav-params]="{id:40}">Push w/ [nav-push] and [nav-params]</button>
|
||||
<button ion-item [nav-push]="[\'FirstPage\', {id: 22}]">Push w/ [nav-push] array and string view name</button>
|
||||
<button ion-item nav-push="FirstPage" [nav-params]="{id: 23}">Push w/ nav-push and [nav-params]</button>
|
||||
<button ion-item (click)="setViews()">setViews() (Go to PrimaryHeaderPage)</button>
|
||||
<button ion-item (click)="nav.pop()">Pop</button>
|
||||
|
||||
<button *ng-for="#i of pages" ion-item (click)="pushPrimaryHeaderPage()">Page {{i}}</button>
|
||||
</ion-list>
|
||||
</ion-content>`
|
||||
})
|
||||
class FirstPage {
|
||||
@@ -38,6 +44,11 @@ class FirstPage {
|
||||
this.title = 'First Page';
|
||||
|
||||
this.pushPage = FullPage;
|
||||
|
||||
this.pages = [];
|
||||
for (var i = 1; i <= 50; i++) {
|
||||
this.pages.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
setViews() {
|
||||
|
||||
@@ -15,32 +15,6 @@ export class ViewController {
|
||||
this._destroys = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
stage(done) {
|
||||
let navCtrl = this.navCtrl;
|
||||
|
||||
if (this.instance || !navCtrl || this.shouldDestroy) {
|
||||
// already compiled this view
|
||||
return done();
|
||||
}
|
||||
|
||||
// get the pane the NavController wants to use
|
||||
// the pane is where all this content will be placed into
|
||||
navCtrl.loadPage(this, null, () => {
|
||||
|
||||
// this ViewController instance has finished loading
|
||||
try {
|
||||
this.loaded();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @returns {boolean} TODO
|
||||
|
||||
Reference in New Issue
Block a user