mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 13:32:54 +08:00
feat(nav-view): basic structure and example
This commit is contained in:
@ -1,21 +1,67 @@
|
|||||||
|
import {Component, Template, Inject, Parent, NgElement} from 'angular2/angular2'
|
||||||
|
import {ComponentConfig} from 'ionic2/config/component-config'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ion-nav',
|
||||||
|
bind: {
|
||||||
|
},
|
||||||
|
services: []
|
||||||
|
})
|
||||||
|
@Template({
|
||||||
|
inline: `<content></content>`
|
||||||
|
})
|
||||||
export class NavView {
|
export class NavView {
|
||||||
|
constructor(@NgElement() element: NgElement) {
|
||||||
|
console.log('Nav View constructed')
|
||||||
|
|
||||||
// viewControllers: Stack<ViewController>;
|
this._views = []
|
||||||
// visibleViewController: ViewController;
|
}
|
||||||
|
|
||||||
// push(viewController) {
|
/**
|
||||||
// stack.push(viewController)
|
* Push a new view into the history stack.
|
||||||
// }
|
*
|
||||||
// pop(viewController) {
|
* @param view the new view
|
||||||
// stack.pop(viewController)
|
* @param shouldAnimate whether to animate
|
||||||
// }
|
*/
|
||||||
// set viewControllers(v) {
|
push(view, shouldAnimate) {
|
||||||
// this.viewControllers = v
|
this.views.push(view)
|
||||||
// }
|
|
||||||
|
|
||||||
constructor() {
|
if(shouldAnimate) {
|
||||||
console.log('construct nav-view')
|
this.animateIn(view)
|
||||||
this.history = [] // <---- would be fancy pants
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pop a view off the history
|
||||||
|
*
|
||||||
|
* @param shouldAnimate whether to animate
|
||||||
|
*/
|
||||||
|
pop(shouldAnimate) {
|
||||||
|
last = stack.pop()
|
||||||
|
|
||||||
|
if(shouldAnimate) {
|
||||||
|
this.animateOut(last)
|
||||||
|
}
|
||||||
|
|
||||||
|
return last
|
||||||
|
}
|
||||||
|
|
||||||
|
get views() {
|
||||||
|
return this._views
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set the view stack explicitly.
|
||||||
|
*/
|
||||||
|
set views(v) {
|
||||||
|
this._views = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animate a new view *in*
|
||||||
|
_animateIn(view) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animate an old view *out*
|
||||||
|
_animateOut(view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
0
src/components/nav-view/nav-view.spec.js
Normal file
0
src/components/nav-view/nav-view.spec.js
Normal file
2
src/components/nav-view/test/basic/main.html
Normal file
2
src/components/nav-view/test/basic/main.html
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<ion-nav>
|
||||||
|
</ion-nav>
|
16
src/components/nav-view/test/basic/main.js
Normal file
16
src/components/nav-view/test/basic/main.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import {bootstrap} from 'angular2/core';
|
||||||
|
import {Component, Template} from 'angular2/angular2';
|
||||||
|
import {NavView} from 'ionic2/components/nav-view/nav-view';
|
||||||
|
|
||||||
|
@Component({ selector: '[ion-app]' })
|
||||||
|
@Template({
|
||||||
|
directives: [NavView],
|
||||||
|
url: 'main.html'
|
||||||
|
})
|
||||||
|
class IonicApp {
|
||||||
|
constructor() {
|
||||||
|
console.log('IonicApp Start')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrap(IonicApp)
|
Reference in New Issue
Block a user