From 33c061b57200f4ef0c883418285694852d74b5f1 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Sun, 29 Mar 2015 10:34:01 -0600 Subject: [PATCH] feat(nav-view): basic structure and example --- src/components/nav-view/nav-view.js | 74 ++++++++++++++++---- src/components/nav-view/nav-view.spec.js | 0 src/components/nav-view/test/basic/main.html | 2 + src/components/nav-view/test/basic/main.js | 16 +++++ 4 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 src/components/nav-view/nav-view.spec.js create mode 100644 src/components/nav-view/test/basic/main.html create mode 100644 src/components/nav-view/test/basic/main.js diff --git a/src/components/nav-view/nav-view.js b/src/components/nav-view/nav-view.js index a3ccaad3e4..ac401f9926 100644 --- a/src/components/nav-view/nav-view.js +++ b/src/components/nav-view/nav-view.js @@ -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: `` +}) export class NavView { + constructor(@NgElement() element: NgElement) { + console.log('Nav View constructed') - // viewControllers: Stack; - // visibleViewController: ViewController; + this._views = [] + } - // push(viewController) { - // stack.push(viewController) - // } - // pop(viewController) { - // stack.pop(viewController) - // } - // set viewControllers(v) { - // this.viewControllers = v - // } + /** + * Push a new view into the history stack. + * + * @param view the new view + * @param shouldAnimate whether to animate + */ + push(view, shouldAnimate) { + this.views.push(view) - constructor() { - console.log('construct nav-view') - this.history = [] // <---- would be fancy pants + if(shouldAnimate) { + this.animateIn(view) + } + } + + /** + * 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) { } } diff --git a/src/components/nav-view/nav-view.spec.js b/src/components/nav-view/nav-view.spec.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/components/nav-view/test/basic/main.html b/src/components/nav-view/test/basic/main.html new file mode 100644 index 0000000000..9d267a2e9b --- /dev/null +++ b/src/components/nav-view/test/basic/main.html @@ -0,0 +1,2 @@ + + diff --git a/src/components/nav-view/test/basic/main.js b/src/components/nav-view/test/basic/main.js new file mode 100644 index 0000000000..ee0651270d --- /dev/null +++ b/src/components/nav-view/test/basic/main.js @@ -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)