rename NavBase to ViewController

This commit is contained in:
Adam Bradley
2015-06-09 11:51:00 -05:00
parent 7ea9929ab1
commit b28bd21ad0
10 changed files with 51 additions and 51 deletions

View File

@ -48,7 +48,7 @@ export class Animation {
return this;
}
addAnimation(childAnimations) {
add(childAnimations) {
childAnimations = Array.isArray(childAnimations) ? childAnimations : arguments;
for (let i = 0; i < childAnimations.length; i++) {
childAnimations[i].parent(this);

View File

@ -2,15 +2,15 @@ import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
import {bind} from 'angular2/di';
import * as util from 'ionic/util';
import {ViewController} from '../view/view-controller';
import {NavController} from './nav-controller';
import {NavBase} from './nav-base';
import * as util from 'ionic/util';
export class NavItem {
constructor(navBase, ComponentClass, params = {}) {
this.nav = navBase;
constructor(viewController, ComponentClass, params = {}) {
this.viewController = viewController;
this.ComponentClass = ComponentClass;
this.params = params;
this.instance = null;
@ -31,30 +31,30 @@ export class NavItem {
}
stage(callback) {
let nav = this.nav;
let viewController = this.viewController;
// update if it's possible to go back from this nav item
this.enableBack = nav && !!nav.getPrevious(this);
this.enableBack = viewController && !!viewController.getPrevious(this);
if (this.instance || !nav) {
if (this.instance || !viewController) {
// already compiled this view
return callback();
}
// compile the Component
nav.compiler.compileInHost(this.ComponentClass).then(componentProtoViewRef => {
viewController.compiler.compileInHost(this.ComponentClass).then(componentProtoViewRef => {
// 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 = getProtoViewStructure(componentProtoViewRef);
// get the appropriate Pane which this NavItem will fit into
nav.getPane(itemStructure, pane => {
viewController.getPane(itemStructure, pane => {
// create a new injector just for this NavItem
let injector = nav.injector.resolveAndCreateChild([
bind(NavBase).toValue(this.nav),
bind(NavController).toValue(nav.navCtrl),
let injector = viewController.injector.resolveAndCreateChild([
bind(ViewController).toValue(viewController),
bind(NavController).toValue(viewController.navCtrl),
bind(NavParams).toValue(new NavParams(this.params)),
bind(NavItem).toValue(this)
]);
@ -65,7 +65,7 @@ export class NavItem {
let newLocation = new ElementRef(hostViewRef, 0);
this.setInstance( nav.loader._viewManager.getComponent(newLocation) );
this.setInstance( viewController.loader._viewManager.getComponent(newLocation) );
this.setViewElement( hostViewRef._view.render._view.rootNodes[0] );
this.disposals.push(() => {
@ -82,7 +82,7 @@ export class NavItem {
};
// get the item container's nav bar
let navbarViewContainer = nav.navbarViewContainer();
let navbarViewContainer = viewController.navbarViewContainer();
// get the item's navbar protoview
let navbarProtoView = this.protos.navbar;

View File

@ -7,7 +7,7 @@ import {ElementRef} from 'angular2/src/core/compiler/element_ref';
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
import {Injector} from 'angular2/di';
import {NavBase} from './nav-base';
import {ViewController} from '../view/view-controller';
import {IonicComponent} from '../../config/component';
@ -24,16 +24,16 @@ import {IonicComponent} from '../../config/component';
`,
directives: [NavPaneAnchor]
})
export class Nav extends NavBase {
export class Nav extends ViewController {
constructor(
@Optional() parentNavBase: NavBase,
@Optional() viewController: ViewController,
compiler: Compiler,
elementRef: ElementRef,
loader: DynamicComponentLoader,
injector: Injector
) {
super(parentNavBase, compiler, elementRef, loader, injector);
super(viewController, compiler, elementRef, loader, injector);
this.domElement = elementRef.domElement;
this.config = Nav.config.invoke(this);

View File

@ -4,8 +4,8 @@ import {Parent} from 'angular2/src/core/annotations_impl/visibility';
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
import {ViewController} from '../view/view-controller';
import {Nav} from './nav';
import {NavBase} from './nav-base';
import {SwipeHandle} from './swipe-handle';
@ -69,7 +69,7 @@ export class NavBarContainer {}
selector: 'template[navbar-anchor]'
})
class NavBarAnchor {
constructor(nav: NavBase, viewContainerRef: ViewContainerRef) {
nav.navbarViewContainer(viewContainerRef);
constructor(viewController: ViewController, viewContainerRef: ViewContainerRef) {
viewController.navbarViewContainer(viewContainerRef);
}
}

View File

@ -2,8 +2,8 @@ import {ElementRef} from 'angular2/angular2'
import {Directive} from 'angular2/src/core/annotations_impl/annotations';
import {Optional} from 'angular2/src/di/annotations_impl';
import {ViewController} from '../view/view-controller';
import {Gesture} from 'ionic/gestures/gesture';
import {NavBase} from './nav-base';
@Directive({
@ -14,12 +14,12 @@ import {NavBase} from './nav-base';
})
export class SwipeHandle {
constructor(
@Optional() navBase: NavBase,
@Optional() viewController: ViewController,
elementRef: ElementRef
) {
if (!navBase) return;
if (!viewController) return;
this.navBase = navBase;
this.viewController = viewController;
let gesture = new Gesture(elementRef.domElement);
gesture.listen();
@ -62,7 +62,7 @@ export class SwipeHandle {
}
}
navBase.swipeBackEnd(completeSwipeBack, progress, playbackRate);
viewController.swipeBackEnd(completeSwipeBack, progress, playbackRate);
startX = null;
}
@ -73,18 +73,18 @@ export class SwipeHandle {
ev.stopPropagation();
startX = ev.gesture.center.x;
swipeableAreaWidth = navBase.width() - startX;
swipeableAreaWidth = viewController.width() - startX;
navBase.swipeBackStart();
viewController.swipeBackStart();
}
navBase.swipeBackProgress( (ev.gesture.center.x - startX) / swipeableAreaWidth );
viewController.swipeBackProgress( (ev.gesture.center.x - startX) / swipeableAreaWidth );
}
}
showHandle() {
return (this.navBase ? this.navBase.swipeBackEnabled() : false);
return (this.viewController ? this.viewController.swipeBackEnabled() : false);
}
}

View File

@ -8,8 +8,8 @@ import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_compone
import {Injector} from 'angular2/di';
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
import {ViewController} from '../view/view-controller';
import {Tabs} from './tabs';
import {NavBase} from '../nav/nav-base';
import {NavItem} from '../nav/nav-item';
import {Content} from '../content/content';
import {IonicComponent} from '../../config/component';
@ -39,7 +39,7 @@ import {IonicComponent} from '../../config/component';
`,
directives: [TabContentAnchor]
})
export class Tab extends NavBase {
export class Tab extends ViewController {
constructor(
@Parent() tabs: Tabs,
@ -97,6 +97,6 @@ export class Tab extends NavBase {
})
class TabContentAnchor {
constructor(@Parent() tab: Tab, viewContainerRef: ViewContainerRef) {
this.contentContainerRef = viewContainerRef;
tab.contentContainerRef = viewContainerRef;
}
}

View File

@ -9,8 +9,8 @@ import {Injector} from 'angular2/di';
import {NgFor} from 'angular2/angular2';
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
import {ViewController} from '../view/view-controller';
import {TabButton} from './tab-button';
import {NavBase} from '../nav/nav-base';
import {Icon} from '../icon/icon';
import {NavItem} from '../nav/nav-item';
import {IonicComponent} from '../../config/component';
@ -39,17 +39,17 @@ import {IonicComponent} from '../../config/component';
`,
directives: [NgFor, TabButton, Icon]
})
export class Tabs extends NavBase {
export class Tabs extends ViewController {
constructor(
@Optional() parentNavBase: NavBase,
@Optional() viewController: ViewController,
@Optional() navItem: NavItem,
compiler: Compiler,
elementRef: ElementRef,
loader: DynamicComponentLoader,
injector: Injector
) {
super(parentNavBase, compiler, elementRef, loader, injector);
super(viewController, compiler, elementRef, loader, injector);
this.item = navItem;
this.domElement = elementRef.domElement;

View File

@ -9,18 +9,18 @@ import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
import {Compiler} from 'angular2/angular2';
import {bind} from 'angular2/di';
import {NavController} from './nav-controller';
import {NavItem, NavParams} from './nav-item';
import {Pane, NavBarContainer} from './pane';
import {NavController} from '../nav/nav-controller';
import {NavItem, NavParams} from '../nav/nav-item';
import {Pane, NavBarContainer} from '../nav/pane';
import {Transition} from '../../transitions/transition';
import {ClickBlock} from '../../util/click-block';
import * as util from 'ionic/util';
export class NavBase {
export class ViewController {
constructor(
parent: NavBase,
parent: ViewController,
compiler: Compiler,
elementRef: ElementRef,
loader: DynamicComponentLoader,
@ -62,7 +62,7 @@ export class NavBase {
this.panes[itemStructure.key] = null;
let injector = this.injector.resolveAndCreateChild([
bind(NavBase).toValue(this)
bind(ViewController).toValue(this)
]);
// add a Pane element

View File

@ -39,7 +39,7 @@ class IOSTransition extends Transition {
enteringBackButton
.from(OPACITY, 0)
.to(OPACITY, 1);
this.addAnimation(enteringBackButton);
this.add(enteringBackButton);
}
// leaving view moves off screen
@ -55,7 +55,7 @@ class IOSTransition extends Transition {
leavingBackButton
.from(OPACITY, 1)
.to(OPACITY, 0);
this.addAnimation(leavingBackButton);
this.add(leavingBackButton);
// set properties depending on direction
if (opts.direction === 'back') {

View File

@ -19,7 +19,7 @@ export class Transition extends Animation {
// create animation for the entering item's "ion-view" element
this.enteringView = new Animation(enteringItem.viewElement());
this.enteringView.beforePlay.addClass(SHOW_VIEW_CSS);
this.addAnimation(this.enteringView);
this.add(this.enteringView);
// create animation for the entering item's "ion-navbar" element
if (opts.navbar !== false) {
@ -28,8 +28,8 @@ export class Transition extends Animation {
// create animation for the entering item's "ion-title" element
this.enteringTitle = new Animation(enteringItem.titleElement());
this.enteringNavbar.addAnimation(this.enteringTitle);
this.addAnimation(this.enteringNavbar);
this.enteringNavbar.add(this.enteringTitle);
this.add(this.enteringNavbar);
}
if (leavingItem) {
@ -43,9 +43,9 @@ export class Transition extends Animation {
// create animation for the leaving item's "ion-title" element
this.leavingTitle = new Animation(leavingItem.titleElement());
this.leavingNavbar.addAnimation(this.leavingTitle);
this.leavingNavbar.add(this.leavingTitle);
this.addAnimation(this.leavingView, this.leavingNavbar);
this.add(this.leavingView, this.leavingNavbar);
}
}