Second View via href
diff --git a/ionic/components/view/view-item.ts b/ionic/components/nav/view-controller.ts
similarity index 90%
rename from ionic/components/view/view-item.ts
rename to ionic/components/nav/view-controller.ts
index 0ef0eea026..a6fae1471c 100644
--- a/ionic/components/view/view-item.ts
+++ b/ionic/components/nav/view-controller.ts
@@ -1,15 +1,15 @@
import {Component, EventEmitter, ElementRef, bind, Injector, ComponentRef} from 'angular2/angular2';
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
-import {NavParams} from '../nav/nav-controller';
+import {NavParams} from './nav-controller';
/**
* TODO
*/
-export class ViewItem {
+export class ViewController {
- constructor(viewCtrl, componentType, params = {}) {
- this.viewCtrl = viewCtrl;
+ constructor(navCtrl, componentType, params = {}) {
+ this.navCtrl = navCtrl;
this.componentType = componentType;
this.params = new NavParams(params);
this.instance = null;
@@ -47,9 +47,9 @@ export class ViewItem {
* @returns {TODO} TODO
*/
stage(callback) {
- let viewCtrl = this.viewCtrl;
+ let navCtrl = this.navCtrl;
- if (this.instance || !viewCtrl) {
+ if (this.instance || !navCtrl) {
// already compiled this view
return callback();
}
@@ -67,19 +67,19 @@ export class ViewItem {
ionViewComponentType.token = 'ionView' + this.componentType.name;
// compile the Component
- viewCtrl.compiler.compileInHost(ionViewComponentType).then(hostProtoViewRef => {
+ navCtrl.compiler.compileInHost(ionViewComponentType).then(hostProtoViewRef => {
// figure out the sturcture of this Component
// does it have a navbar? Is it tabs? Should it not have a navbar or any toolbars?
let itemStructure = this.sturcture = this.inspectStructure(hostProtoViewRef);
- // get the appropriate Pane which this ViewItem will fit into
- viewCtrl.panes.get(itemStructure, pane => {
+ // get the appropriate Pane which this ViewController will fit into
+ navCtrl.panes.get(itemStructure, pane => {
this.pane = pane;
- let bindings = viewCtrl.bindings.concat(Injector.resolve([
+ let bindings = navCtrl.bindings.concat(Injector.resolve([
bind(NavParams).toValue(this.params),
- bind(ViewItem).toValue(this)
+ bind(ViewController).toValue(this)
]));
// add the content of the view to the content area
@@ -89,8 +89,8 @@ export class ViewItem {
// the same guts as DynamicComponentLoader.loadNextToLocation
var hostViewRef =
contentContainer.createHostView(hostProtoViewRef, -1, bindings);
- var newLocation = viewCtrl.viewMngr.getHostElement(hostViewRef);
- var newComponent = viewCtrl.viewMngr.getComponent(newLocation);
+ var newLocation = navCtrl.viewMngr.getHostElement(hostViewRef);
+ var newComponent = navCtrl.viewMngr.getComponent(newLocation);
pane.totalItems++;
var dispose = () => {
@@ -108,12 +108,12 @@ export class ViewItem {
this.disposals.push(dispose);
var viewComponetRef = new ComponentRef(newLocation, newComponent, dispose);
- // get the component's instance, and set it to the this ViewItem
+ // get the component's instance, and set it to the this ViewController
this.setInstance(viewComponetRef.instance);
this.viewElementRef(viewComponetRef.location);
// // get the item container's nav bar
- let navbarViewContainer = viewCtrl.navbarViewContainer();
+ let navbarViewContainer = navCtrl.navbarViewContainer();
// // get the item's navbar protoview
let navbarTemplateRef = this.templateRefs.navbar;
@@ -186,7 +186,7 @@ export class ViewItem {
});
});
- if (this.viewCtrl.childNavbar()) {
+ if (this.navCtrl.childNavbar()) {
navbar = false;
}
@@ -204,8 +204,8 @@ export class ViewItem {
*/
enableBack() {
// update if it's possible to go back from this nav item
- if (this.viewCtrl) {
- let previousItem = this.viewCtrl.getPrevious(this);
+ if (this.navCtrl) {
+ let previousItem = this.navCtrl.getPrevious(this);
// the previous view may exist, but if it's about to be destroyed
// it shouldn't be able to go back to
return !!(previousItem && !previousItem.shouldDestroy);
@@ -219,11 +219,10 @@ export class ViewItem {
*/
setInstance(instance) {
this.instance = instance;
- this.instance._viewItem = this;
}
get index() {
- return (this.viewCtrl ? this.viewCtrl.indexOf(this) : -1);
+ return (this.navCtrl ? this.navCtrl.indexOf(this) : -1);
}
isRoot() {
diff --git a/ionic/components/tabs/tab.ts b/ionic/components/tabs/tab.ts
index a872b07d05..c4f4ae99e8 100644
--- a/ionic/components/tabs/tab.ts
+++ b/ionic/components/tabs/tab.ts
@@ -1,7 +1,7 @@
import {Directive, Component, View, Host, ElementRef, forwardRef, Injector, NgZone} from 'angular2/angular2';
-import {ViewController} from '../view/view-controller';
-import {ViewItem} from '../view/view-item';
+import {NavController} from '../nav/nav-controller';
+import {ViewController} from '../nav/view-controller';
import {Tabs} from './tabs';
@@ -35,7 +35,7 @@ import {Tabs} from './tabs';
template: '',
directives: [forwardRef(() => TabPaneAnchor)]
})
-export class Tab extends ViewController {
+export class Tab extends NavController {
/**
* TODO
@@ -51,32 +51,32 @@ export class Tab extends ViewController {
zone: NgZone
) {
// A Tab is both a container of many views, and is a view itself.
- // A Tab is one ViewItem within it's Host Tabs (which extends ViewController)
- // A Tab is a ViewController for its child ViewItems
+ // A Tab is one ViewController within it's Host Tabs (which extends NavController)
+ // A Tab is a NavController for its child ViewControllers
super(tabs, injector, elementRef, zone);
this.tabs = tabs;
this.childNavbar(true);
- let item = this.item = new ViewItem(tabs.Host);
- item.setInstance(this);
- item.viewElementRef(elementRef);
+ let viewCtrl = this.viewCtrl = new ViewController(tabs.Host);
+ viewCtrl.setInstance(this);
+ viewCtrl.viewElementRef(elementRef);
tabs.addTab(this);
- this.navbarView = item.navbarView = () => {
- let activeItem = this.getActive();
- return activeItem && activeItem.navbarView();
+ this.navbarView = viewCtrl.navbarView = () => {
+ let activeView = this.getActive();
+ return activeView && activeView.navbarView();
};
- item.enableBack = () => {
- // override ViewItem's enableBack(), should use the
+ viewCtrl.enableBack = () => {
+ // override ViewController's enableBack(), should use the
// active child nav item's enableBack() instead
- let activeItem = this.getActive();
- return (activeItem && activeItem.enableBack());
+ let activeView = this.getActive();
+ return (activeView && activeView.enableBack());
};
- this.panelId = 'tab-panel-' + item.id;
- this.labeledBy = 'tab-button-' + item.id;
+ this.panelId = 'tab-panel-' + viewCtrl.id;
+ this.labeledBy = 'tab-button-' + viewCtrl.id;
}
onInit() {
@@ -118,11 +118,11 @@ export class Tab extends ViewController {
}
get isSelected() {
- return this.tabs.isActive(this.item);
+ return this.tabs.isActive(this.viewCtrl);
}
get isNotSelected() {
- return !this.tabs.isActive(this.item);
+ return !this.tabs.isActive(this.viewCtrl);
}
}
diff --git a/ionic/components/tabs/tabs.ts b/ionic/components/tabs/tabs.ts
index 3dfb8af5d3..346512ec2e 100644
--- a/ionic/components/tabs/tabs.ts
+++ b/ionic/components/tabs/tabs.ts
@@ -1,8 +1,8 @@
import {Component, Directive, View, Injector, NgFor, ElementRef, Optional, Host, forwardRef, NgZone} from 'angular2/angular2';
import {IonicApp} from '../app/app';
-import {ViewController} from '../view/view-controller';
-import {ViewItem} from '../view/view-item';
+import {NavController} from '../nav/nav-controller';
+import {ViewController} from '../nav/view-controller';
import {Icon} from '../icon/icon';
import {IonicComponent, IonicView} from '../../config/decorators';
@@ -50,41 +50,41 @@ import {IonicComponent, IonicView} from '../../config/decorators';
'',
directives: [forwardRef(() => TabButton)]
})
-export class Tabs extends ViewController {
+export class Tabs extends NavController {
/**
* TODO
*/
constructor(
- @Optional() hostViewCtrl: ViewController,
- @Optional() viewItem: ViewItem,
+ @Optional() hostNavCtrl: NavController,
+ @Optional() viewCtrl: ViewController,
app: IonicApp,
injector: Injector,
elementRef: ElementRef,
zone: NgZone
) {
- super(hostViewCtrl, injector, elementRef, zone);
+ super(hostNavCtrl, injector, elementRef, zone);
this.app = app;
- // Tabs may also be an actual ViewItem which was navigated to
- // if Tabs is static and not navigated to within a ViewController
- // then skip this and don't treat it as it's own ViewItem
- if (viewItem) {
- this.item = viewItem;
+ // Tabs may also be an actual ViewController which was navigated to
+ // if Tabs is static and not navigated to within a NavController
+ // then skip this and don't treat it as it's own ViewController
+ if (viewCtrl) {
+ this.viewCtrl = viewCtrl;
- // special overrides for the Tabs ViewItem
- // the Tabs ViewItem does not have it's own navbar
+ // special overrides for the Tabs ViewController
+ // the Tabs ViewController does not have it's own navbar
// so find the navbar it should use within it's active Tab
- viewItem.navbarView = () => {
+ viewCtrl.navbarView = () => {
let activeTab = this.getActive();
if (activeTab && activeTab.instance) {
return activeTab.instance.navbarView();
}
};
- // a Tabs ViewItem should not have a back button
+ // a Tabs ViewController should not have a back button
// enableBack back button will later be determined
- // by the active ViewItem that has a navbar
- viewItem.enableBack = () => {
+ // by the active ViewController that has a navbar
+ ViewController.enableBack = () => {
return false;
};
}
@@ -96,14 +96,14 @@ export class Tabs extends ViewController {
* @param {Tab} tab TODO
*/
addTab(tab) {
- // tab.item refers to the ViewItem of the individual Tab being added to Tabs (ViewController)
- // this.item refers to the ViewItem instsance on Tabs
- this.add(tab.item);
+ // tab.viewCtrl refers to the ViewController of the individual Tab being added to Tabs (NavController)
+ // this.viewCtrl refers to the ViewController instsance on Tabs
+ this.add(tab.viewCtrl);
if (this.length() === 1) {
// this was the first tab added, queue this one to be loaded and selected
let promise = tab.queueInitial();
- this.item && this.item.addPromise(promise);
+ this.viewCtrl && this.viewCtrl.addPromise(promise);
}
}
@@ -113,28 +113,28 @@ export class Tabs extends ViewController {
* @returns {TODO} TODO
*/
select(tab) {
- let enteringItem = null;
+ let enteringView = null;
if (typeof tab === 'number') {
- enteringItem = this.getByIndex(tab);
+ enteringView = this.getByIndex(tab);
} else {
- enteringItem = this.getByInstance(tab)
+ enteringView = this.getByInstance(tab)
}
- if (!enteringItem || !enteringItem.instance || !this.app.isEnabled()) {
+ if (!enteringView || !enteringView.instance || !this.app.isEnabled()) {
return Promise.reject();
}
return new Promise(resolve => {
- enteringItem.instance.load(() => {
+ enteringView.instance.load(() => {
let opts = {
animate: false
};
- let leavingItem = this.getActive() || new ViewItem();
- leavingItem.shouldDestroy = false;
- leavingItem.shouldCache = true;
+ let leavingView = this.getActive() || new ViewController();
+ leavingView.shouldDestroy = false;
+ leavingView.shouldCache = true;
- this.transition(enteringItem, leavingItem, opts, () => {
+ this.transition(enteringView, leavingView, opts, () => {
resolve();
});
});
@@ -171,7 +171,7 @@ class TabButton {
}
onInit() {
- let id = this.tab.item.id;
+ let id = this.tab.viewCtrl.id;
this.btnId = 'tab-button-' + id;
this.panelId = 'tab-panel-' + id;
diff --git a/ionic/components/view/view-controller.ts b/ionic/components/view/view-controller.ts
deleted file mode 100644
index f68ffa257d..0000000000
--- a/ionic/components/view/view-controller.ts
+++ /dev/null
@@ -1,780 +0,0 @@
-import {Compiler, ElementRef, Injector, bind, NgZone} from 'angular2/angular2';
-import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
-import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
-
-import {Ion} from '../ion';
-import {IonicConfig} from '../../config/config';
-import {IonicApp} from '../app/app';
-import {ViewItem} from './view-item';
-import {NavController} from '../nav/nav-controller';
-import {PaneController} from '../nav/pane';
-import {Transition} from '../../transitions/transition';
-import {SwipeBackGesture} from './swipe-back';
-import * as util from 'ionic/util';
-
-/**
- * TODO
- */
-export class ViewController extends Ion {
-
- constructor(
- parentViewCtrl: ViewController,
- injector: Injector,
- elementRef: ElementRef,
- zone: NgZone
- ) {
- let config = injector.get(IonicConfig);
- super(elementRef, config);
-
- this.parent = parentViewCtrl;
-
- this.compiler = injector.get(Compiler);
- this.loader = injector.get(DynamicComponentLoader);
- this.viewMngr = injector.get(AppViewManager);
- this.app = injector.get(IonicApp);
- this.config = config;
- this.zone = zone;
-
- this.items = [];
- this.panes = new PaneController(this);
-
- this._sbTrans = null;
- this.sbEnabled = config.setting('swipeBackEnabled') || false;
- this.sbThreshold = config.setting('swipeBackThreshold') || 40
-
- this.id = ++ctrlIds;
- this._ids = -1;
- this.zIndexes = -1;
-
- // build a new injector for child ViewItems to use
- this.bindings = Injector.resolve([
- bind(ViewController).toValue(this),
- bind(NavController).toValue(new NavController(this))
- ]);
- }
-
- /**
- * TODO
- * @param {TODO} componentType TODO
- * @param {TODO} [params={}] TODO
- * @param {TODO} [opts={}] TODO
- * @returns {Promise} TODO
- */
- push(componentType, params = {}, opts = {}) {
- if (!componentType) {
- return Promise.reject();
- }
- if (typeof componentType !== 'function') {
- throw 'Loading component must be a component class, not "' + componentType.toString() + '"';
- }
-
- let resolve;
- let promise = new Promise(res => { resolve = res; });
-
- // do not animate if this is the first in the stack
- if (!this.items.length) {
- opts.animation = 'none';
- }
-
- // default the direction to "forward"
- opts.direction = opts.direction || 'forward';
-
- // the active item is going to be the leaving one (if one exists)
- let leavingItem = this.getActive() || new ViewItem();
- leavingItem.shouldCache = (util.isBoolean(opts.cacheLeavingItem) ? opts.cacheLeavingItem : true);
- leavingItem.shouldDestroy = !leavingItem.shouldCache;
- if (leavingItem.shouldDestroy) {
- leavingItem.willUnload();
- }
-
- // create a new ViewItem
- let enteringItem = new ViewItem(this, componentType, params);
-
- // add the item to the stack
- this.add(enteringItem);
-
- if (this.router) {
- // notify router of the state change
- this.router.stateChange('push', enteringItem, params);
- }
-
- // start the transition
- this.transition(enteringItem, leavingItem, opts, () => {
- resolve();
- });
-
- return promise;
- }
-
- /**
- * TODO
- * @param {TODO} [opts={}] TODO
- * @returns {Promise} TODO
- */
- pop(opts = {}) {
- if (!this.canGoBack()) {
- return Promise.reject();
- }
-
- let resolve;
- let promise = new Promise(res => { resolve = res; });
-
- // default the direction to "back"
- opts.direction = opts.direction || 'back';
-
- // get the active item and set that it is staged to be leaving
- // was probably the one popped from the stack
- let leavingItem = this.getActive() || new ViewItem();
- leavingItem.shouldCache = (util.isBoolean(opts.cacheLeavingItem) ? opts.cacheLeavingItem : false);
- leavingItem.shouldDestroy = !leavingItem.shouldCache;
- if (leavingItem.shouldDestroy) {
- leavingItem.willUnload();
- }
-
- // the entering item is now the new last item
- // Note: we might not have an entering item if this is the
- // only item on the history stack.
- let enteringItem = this.getPrevious(leavingItem);
- if (enteringItem) {
- if (this.router) {
- // notify router of the state change
- this.router.stateChange('pop', enteringItem);
- }
-
- // start the transition
- this.transition(enteringItem, leavingItem, opts, () => {
- // transition completed, destroy the leaving item
- resolve();
- });
-
- } else {
- this._transComplete();
- resolve();
- }
-
- return promise;
- }
-
- /**
- * Set the item stack to reflect the given component classes.
- * @param {TODO} components TODO
- * @param {TODO} [opts={}] TODO
- * @returns {Promise} TODO
- */
- setItems(components, opts = {}) {
- if (!components || !components.length) {
- return Promise.resolve();
- }
-
- // if animate has not been set then default to false
- opts.animate = opts.animate || false;
-
- // ensure leaving items are not cached, and should be destroyed
- opts.cacheLeavingItem = false;
-
- // get the items to auto remove without having to do a transiton for each
- // the last item (the currently active one) will do a normal transition out
- if (this.items.length > 1) {
- let autoRemoveItems = this.items.slice(0, this.items.length - 1);
- for (let i = 0; i < autoRemoveItems.length; i++) {
- autoRemoveItems[i].shouldDestroy = true;
- autoRemoveItems[i].shouldCache = false;
- autoRemoveItems[i].willUnload();
- }
- }
-
- let componentObj = null;
- let componentType = null;
- let viewItem = null;
-
- // create the ViewItems that go before the new active ViewItem in the stack
- // but the previous views won't should render yet
- if (components.length > 1) {
- let newBeforeItems = components.slice(0, components.length - 1);
- for (let j = 0; j < newBeforeItems.length; j++) {
- componentObj = newBeforeItems[j];
-
- if (componentObj) {
-
- // could be an object with a componentType property, or it is a componentType
- componentType = componentObj.componentType || componentObj;
-
- viewItem = new ViewItem(this, componentType, componentObj.params);
- viewItem.state = CACHED_STATE;
- viewItem.shouldDestroy = false;
- viewItem.shouldCache = false;
-
- // add the item to the stack
- this.add(viewItem);
- }
- }
- }
-
- // get the component that will become the active item
- // it'll be the last one in the given components array
- componentObj = components[ components.length - 1 ];
- componentType = componentObj.componentType || componentObj;
-
- // transition the leaving and entering
- return this.push(componentType, componentObj.params, opts);
- }
-
- /**
- * TODO
- * @param {TODO} componentType TODO
- * @param {TODO} [params={}] TODO
- * @param {TODO} [opts={}] TODO
- * @returns {Promise} TODO
- */
- setRoot(componentType, params = {}, opts = {}) {
- return this.setItems([{
- componentType,
- params
- }], opts);
- }
-
- /**
- * TODO
- * @param {TODO} enteringItem TODO
- * @param {TODO} leavingItem TODO
- * @param {TODO} opts TODO
- * @param {Function} callback TODO
- * @returns {any} TODO
- */
- transition(enteringItem, leavingItem, opts, callback) {
- if (!enteringItem || enteringItem === leavingItem) {
- return callback();
- }
-
- if (opts.animate === false) {
- opts.animation = 'none';
-
- } else if (!opts.animation) {
- opts.animation = this.config.setting('viewTransition');
- }
-
- opts.animate = (opts.animation !== 'none');
-
- // wait for the new item to complete setup
- enteringItem.stage(() => {
-
- this.zone.runOutsideAngular(() => {
-
- enteringItem.shouldDestroy = false;
- enteringItem.shouldCache = false;
- enteringItem.willEnter();
- leavingItem.willLeave();
-
- // set that the new item pushed on the stack is staged to be entering/leaving
- // staged state is important for the transition to find the correct item
- enteringItem.state = STAGED_ENTERING_STATE;
- leavingItem.state = STAGED_LEAVING_STATE;
-
- // init the transition animation
- let transAnimation = Transition.create(this, opts);
- if (!opts.animate) {
- // force it to not animate the elements, just apply the "to" styles
- transAnimation.duration(0);
- }
-
- let duration = transAnimation.duration();
- if (duration > 64) {
- // block any clicks during the transition and provide a
- // fallback to remove the clickblock if something goes wrong
- this.app.setEnabled(false, duration);
- }
-
- // start the transition
- transAnimation.play().then(() => {
-
- // transition has completed, update each item's state
- enteringItem.state = ACTIVE_STATE;
- leavingItem.state = CACHED_STATE;
-
- // dispose any items that shouldn't stay around
- transAnimation.dispose();
-
- enteringItem.didEnter();
- leavingItem.didLeave();
-
- // all done!
- this.zone.run(() => {
- this._transComplete();
- callback();
- });
- });
-
- });
-
- });
-
- }
-
- /**
- * TODO
- */
- swipeBackStart() {
- if (!this.app.isEnabled() || !this.canSwipeBack()) {
- return;
- }
-
- // disables the app during the transition
- this.app.setEnabled(false);
-
- // default the direction to "back"
- let opts = {
- direction: 'back'
- };
-
- // get the active item and set that it is staged to be leaving
- // was probably the one popped from the stack
- let leavingItem = this.getActive() || new ViewItem();
- leavingItem.shouldDestroy = true;
- leavingItem.shouldCache = false;
- leavingItem.willLeave();
- leavingItem.willUnload();
-
- // the entering item is now the new last item
- let enteringItem = this.getPrevious(leavingItem);
- enteringItem.shouldDestroy = false;
- enteringItem.shouldCache = false;
- enteringItem.willEnter();
-
- // wait for the new item to complete setup
- enteringItem.stage(() => {
-
- this.zone.runOutsideAngular(() => {
- // set that the new item pushed on the stack is staged to be entering/leaving
- // staged state is important for the transition to find the correct item
- enteringItem.state = STAGED_ENTERING_STATE;
- leavingItem.state = STAGED_LEAVING_STATE;
-
- // init the swipe back transition animation
- this._sbTrans = Transition.create(this, opts);
- this._sbTrans.easing('linear').progressStart();
-
- });
- });
-
- }
-
- /**
- * TODO
- * @param {TODO} progress TODO
- */
- swipeBackProgress(value) {
- if (this._sbTrans) {
- // continue to disable the app while actively dragging
- this.app.setEnabled(false, 4000);
-
- // set the transition animation's progress
- this._sbTrans.progress(value);
- }
- }
-
- /**
- * @private
- * @param {TODO} completeSwipeBack Should the swipe back complete or not.
- * @param {number} rate How fast it closes
- */
- swipeBackEnd(completeSwipeBack, rate) {
- if (!this._sbTrans) return;
-
- // disables the app during the transition
- this.app.setEnabled(false);
-
- this._sbTrans.progressEnd(completeSwipeBack, rate).then(() => {
-
- this.zone.run(() => {
- // find the items that were entering and leaving
- let enteringItem = this.getStagedEnteringItem();
- let leavingItem = this.getStagedLeavingItem();
-
- if (enteringItem && leavingItem) {
- // finish up the animation
-
- if (completeSwipeBack) {
- // swipe back has completed navigating back
- // update each item's state
- enteringItem.state = ACTIVE_STATE;
- leavingItem.state = CACHED_STATE;
-
- enteringItem.didEnter();
- leavingItem.didLeave();
-
- if (this.router) {
- // notify router of the pop state change
- this.router.stateChange('pop', enteringItem);
- }
-
- } else {
- // cancelled the swipe back, they didn't end up going back
- // return items to their original state
- leavingItem.state = ACTIVE_STATE;
- enteringItem.state = CACHED_STATE;
-
- leavingItem.willEnter();
- leavingItem.didEnter();
- enteringItem.didLeave();
-
- leavingItem.shouldDestroy = false;
- enteringItem.shouldDestroy = false;
- }
- }
-
- // empty out and dispose the swipe back transition animation
- this._sbTrans && this._sbTrans.dispose();
- this._sbTrans = null;
-
- // all done!
- this._transComplete();
-
- });
- });
-
- }
-
- _runSwipeBack() {
- if (this.canSwipeBack()) {
- // it is possible to swipe back
-
- if (this.sbGesture) {
- // this is already an active gesture, don't create another one
- return;
- }
-
- let opts = {
- edge: 'left',
- threshold: this.sbThreshold
- };
- this.sbGesture = new SwipeBackGesture(this.getNativeElement(), opts, this);
- console.debug('SwipeBackGesture listen');
- this.sbGesture.listen();
-
-
- } else if (this.sbGesture) {
- // it is not possible to swipe back and there is an
- // active sbGesture, so unlisten it
- console.debug('SwipeBackGesture unlisten');
- this.sbGesture.unlisten();
- this.sbGesture = null;
- }
- }
-
- /**
- * TODO
- * @param {TODO} val TODO
- * @returns {TODO} TODO
- */
- isSwipeBackEnabled(val) {
- if (arguments.length) {
- this.sbEnabled = !!val;
- }
- return this.sbEnabled;
- }
-
- /**
- * If it's possible to use swipe back or not. If it's not possible
- * to go back, or swipe back is not enable then this will return false.
- * If it is possible to go back, and swipe back is enabled, then this
- * will return true.
- * @returns {boolean}
- */
- canSwipeBack() {
- return (this.sbEnabled && this.canGoBack());
- }
-
- /**
- * Returns `true` if there's a valid previous view that we can pop back to.
- * Otherwise returns false.
- * @returns {boolean}
- */
- canGoBack() {
- let activeItem = this.getActive();
- if (activeItem) {
- return activeItem.enableBack();
- }
- return false;
- }
-
- /**
- * @private
- */
- _transComplete() {
- let destroys = [];
-
- this.items.forEach(item => {
- if (item) {
- if (item.shouldDestroy) {
- destroys.push(item);
-
- } else if (item.state === CACHED_STATE && item.shouldCache) {
- item.shouldCache = false;
- }
- }
- });
-
- destroys.forEach(item => {
- this.remove(item);
- item.destroy();
- });
-
- // allow clicks again, but still set an enable time
- // meaning nothing with this view controller can happen for XXms
- this.app.setEnabled(true);
-
- if (this.items.length === 1) {
- this.elementRef.nativeElement.classList.add('has-views');
- }
-
- this._runSwipeBack();
- }
-
- /**
- * TODO
- * @returns {TODO} TODO
- */
- getActive() {
- for (let i = 0, ii = this.items.length; i < ii; i++) {
- if (this.items[i].state === ACTIVE_STATE) {
- return this.items[i];
- }
- }
- return null;
- }
-
- /**
- * TODO
- * @param {TODO} instance TODO
- * @returns {TODO} TODO
- */
- getByInstance(instance) {
- if (instance) {
- for (let i = 0, ii = this.items.length; i < ii; i++) {
- if (this.items[i].instance === instance) {
- return this.items[i];
- }
- }
- }
- return null;
- }
-
- /**
- * TODO
- * @param {TODO} index TODO
- * @returns {TODO} TODO
- */
- getByIndex(index) {
- if (index < this.items.length && index > -1) {
- return this.items[index];
- }
- return null;
- }
-
- /**
- * TODO
- * @param {TODO} item TODO
- * @returns {TODO} TODO
- */
- getPrevious(item) {
- if (item) {
- return this.items[ this.items.indexOf(item) - 1 ];
- }
- return null;
- }
-
- /**
- * TODO
- * @returns {TODO} TODO
- */
- getStagedEnteringItem() {
- for (let i = 0, ii = this.items.length; i < ii; i++) {
- if (this.items[i].state === STAGED_ENTERING_STATE) {
- return this.items[i];
- }
- }
- return null;
- }
-
- /**
- * TODO
- * @returns {TODO} TODO
- */
- getStagedLeavingItem() {
- for (let i = 0, ii = this.items.length; i < ii; i++) {
- if (this.items[i].state === STAGED_LEAVING_STATE) {
- return this.items[i];
- }
- }
- return null;
- }
-
- /**
- * TODO
- * @param {TODO} nbContainer TODO
- * @returns {TODO} TODO
- */
- navbarViewContainer(nbContainer) {
- if (nbContainer) {
- this._nbContainer = nbContainer;
- }
- if (this._nbContainer) {
- return this._nbContainer;
- }
- if (this.parent) {
- return this.parent.navbarViewContainer();
- }
- }
-
- /**
- * TODO
- * @returns {TODO} TODO
- */
- anchorElementRef() {
- if (arguments.length) {
- this._anchorER = arguments[0];
- }
- return this._anchorER;
- }
-
- /**
- * TODO
- * @returns {TODO} TODO
- */
- anchorViewContainerRef() {
- if (arguments.length) {
- this._anchorVC = arguments[0];
- }
- return this._anchorVC;
- }
-
- /**
- * TODO
- * @returns {TODO} TODO
- */
- childNavbar() {
- if (arguments.length) {
- this._childNavbar = arguments[0];
- }
- return this._childNavbar;
- }
-
- /**
- * TODO
- * @param {TODO} item TODO
- * @returns {TODO} TODO
- */
- add(item) {
- item.id = this.id + '-' + (++this._ids);
- this.items.push(item);
- }
-
- /**
- * TODO
- * @param {TODO} itemOrIndex TODO
- * @returns {TODO} TODO
- */
- remove(itemOrIndex) {
- util.array.remove(this.items, itemOrIndex);
- }
-
- /**
- * First view item in this view controller's stack. This would
- * not return an item which is about to be destroyed.
- * @returns {TODO} TODO
- */
- first() {
- for (let i = 0, l = this.items.length; i < l; i++) {
- if (!this.items[i].shouldDestroy) {
- return this.items[i];
- }
- }
- return null;
- }
-
- /**
- * Last view item in this view controller's stack. This would
- * not return an item which is about to be destroyed.
- * @returns {TODO} TODO
- */
- last() {
- for (let i = this.items.length - 1; i >= 0; i--) {
- if (!this.items[i].shouldDestroy) {
- return this.items[i];
- }
- }
- return null;
- }
-
- /**
- * TODO
- * @param {TODO} item TODO
- * @returns {TODO} TODO
- */
- indexOf(item) {
- return this.items.indexOf(item);
- }
-
- /**
- * Number of sibling view items in the view controller. This does
- * not include items which are about to be destroyed.
- * @returns {TODO} TODO
- */
- length() {
- let len = 0;
- for (let i = 0, l = this.items.length; i < l; i++) {
- if (!this.items[i].shouldDestroy) {
- len++;
- }
- }
- return len;
- }
-
- /**
- * TODO
- * @returns {TODO} TODO
- */
- instances() {
- let instances = [];
- for (let item of this.items) {
- if (item.instance) {
- instances.push(item.instance);
- }
- }
- return instances;
- }
-
- /**
- * TODO
- * @param {TODO} item TODO
- * @returns {TODO} TODO
- */
- isActive(item) {
- return (item && item.state === ACTIVE_STATE);
- }
-
- /**
- * TODO
- * @param {TODO} item TODO
- * @returns {TODO} TODO
- */
- isStagedEntering(item) {
- return (item && item.state === STAGED_ENTERING_STATE);
- }
-
- /**
- * TODO
- * @param {TODO} router TODO
- */
- registerRouter(router) {
- this.router = router;
- }
-
-}
-
-const ACTIVE_STATE = 1;
-const CACHED_STATE = 2;
-const STAGED_ENTERING_STATE = 3;
-const STAGED_LEAVING_STATE = 4;
-
-let ctrlIds = -1;
diff --git a/ionic/components/view/view.scss b/ionic/components/view/view.scss
deleted file mode 100644
index 042a49e86a..0000000000
--- a/ionic/components/view/view.scss
+++ /dev/null
@@ -1,17 +0,0 @@
-
-// View
-// --------------------------------------------------
-
-ion-view {
- display: flex;
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- flex-direction: column;
-
- background-color: white;
-
- transform: translateZ(0px);
-}
diff --git a/ionic/ionic.core.scss b/ionic/ionic.core.scss
index 792960d6ab..612c128cdb 100644
--- a/ionic/ionic.core.scss
+++ b/ionic/ionic.core.scss
@@ -47,8 +47,7 @@
"components/search-bar/search-bar",
"components/segment/segment",
"components/switch/switch",
- "components/tabs/tabs",
- "components/view/view";
+ "components/tabs/tabs";
// Ionicons
diff --git a/ionic/transitions/transition.ts b/ionic/transitions/transition.ts
index 728b0a56db..19fb51a977 100644
--- a/ionic/transitions/transition.ts
+++ b/ionic/transitions/transition.ts
@@ -14,61 +14,61 @@ export class Transition extends Animation {
super();
// get the entering and leaving items
- let enteringItem = this.entering = nav.getStagedEnteringItem();
- let leavingItem = this.leaving = nav.getStagedLeavingItem();
+ let enteringView = this.entering = nav.getStagedenteringView();
+ let leavingView = this.leaving = nav.getStagedleavingView();
// create animation for the entering item's "ion-view" element
- this.enteringView = new Animation(enteringItem.viewElementRef());
+ this.enteringView = new Animation(enteringView.viewElementRef());
this.enteringView.before.addClass(SHOW_VIEW_CSS);
this.enteringView.onPlay(() => {
- enteringItem.postRender();
+ enteringView.postRender();
});
this.add(this.enteringView);
if (opts.navbar !== false) {
- let enteringNavbar = this.enteringNavbar = new Animation(enteringItem.navbarRef());
+ let enteringNavbar = this.enteringNavbar = new Animation(enteringView.navbarRef());
enteringNavbar.before.addClass(SHOW_NAVBAR_CSS);
- if (enteringItem.enableBack()) {
+ if (enteringView.enableBack()) {
// only animate in the back button if the entering view has it enabled
- let enteringBackButton = this.enteringBackButton = new Animation(enteringItem.backBtnRef());
+ let enteringBackButton = this.enteringBackButton = new Animation(enteringView.backBtnRef());
enteringBackButton
.before.addClass(SHOW_BACK_BUTTON)
.fadeIn();
enteringNavbar.add(enteringBackButton);
}
- this.enteringTitle = new Animation(enteringItem.titleRef());
+ this.enteringTitle = new Animation(enteringView.titleRef());
enteringNavbar.add(this.enteringTitle);
this.add(enteringNavbar);
- this.enteringNavbarItems = new Animation(enteringItem.navbarItemRefs());
+ this.enteringNavbarItems = new Animation(enteringView.navbarItemRefs());
this.enteringNavbarItems.fadeIn();
enteringNavbar.add(this.enteringNavbarItems);
}
- if (leavingItem) {
+ if (leavingView) {
// setup the leaving item if one exists (initial viewing wouldn't have a leaving item)
- this.leavingView = new Animation(leavingItem.viewElementRef());
+ this.leavingView = new Animation(leavingView.viewElementRef());
this.leavingView.after.removeClass(SHOW_VIEW_CSS);
- let leavingNavbar = this.leavingNavbar = new Animation(leavingItem.navbarRef());
+ let leavingNavbar = this.leavingNavbar = new Animation(leavingView.navbarRef());
leavingNavbar.after.removeClass(SHOW_NAVBAR_CSS);
- let leavingBackButton = this.leavingBackButton = new Animation(leavingItem.backBtnRef());
+ let leavingBackButton = this.leavingBackButton = new Animation(leavingView.backBtnRef());
leavingBackButton
.after.removeClass(SHOW_BACK_BUTTON)
.fadeOut();
leavingNavbar.add(leavingBackButton);
- this.leavingTitle = new Animation(leavingItem.titleRef());
+ this.leavingTitle = new Animation(leavingView.titleRef());
leavingNavbar.add(this.leavingTitle);
- this.leavingNavbarItems = new Animation(leavingItem.navbarItemRefs());
+ this.leavingNavbarItems = new Animation(leavingView.navbarItemRefs());
this.leavingNavbarItems.fadeOut();
leavingNavbar.add(this.leavingNavbarItems);