mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-26 16:21:55 +08:00
rename NavBase to ViewController
This commit is contained in:
@ -48,7 +48,7 @@ export class Animation {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
addAnimation(childAnimations) {
|
add(childAnimations) {
|
||||||
childAnimations = Array.isArray(childAnimations) ? childAnimations : arguments;
|
childAnimations = Array.isArray(childAnimations) ? childAnimations : arguments;
|
||||||
for (let i = 0; i < childAnimations.length; i++) {
|
for (let i = 0; i < childAnimations.length; i++) {
|
||||||
childAnimations[i].parent(this);
|
childAnimations[i].parent(this);
|
||||||
|
@ -2,15 +2,15 @@ import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
|||||||
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
||||||
import {bind} from 'angular2/di';
|
import {bind} from 'angular2/di';
|
||||||
|
|
||||||
import * as util from 'ionic/util';
|
import {ViewController} from '../view/view-controller';
|
||||||
import {NavController} from './nav-controller';
|
import {NavController} from './nav-controller';
|
||||||
import {NavBase} from './nav-base';
|
import * as util from 'ionic/util';
|
||||||
|
|
||||||
|
|
||||||
export class NavItem {
|
export class NavItem {
|
||||||
|
|
||||||
constructor(navBase, ComponentClass, params = {}) {
|
constructor(viewController, ComponentClass, params = {}) {
|
||||||
this.nav = navBase;
|
this.viewController = viewController;
|
||||||
this.ComponentClass = ComponentClass;
|
this.ComponentClass = ComponentClass;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.instance = null;
|
this.instance = null;
|
||||||
@ -31,30 +31,30 @@ export class NavItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stage(callback) {
|
stage(callback) {
|
||||||
let nav = this.nav;
|
let viewController = this.viewController;
|
||||||
|
|
||||||
// update if it's possible to go back from this nav item
|
// 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
|
// already compiled this view
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
// compile the Component
|
// compile the Component
|
||||||
nav.compiler.compileInHost(this.ComponentClass).then(componentProtoViewRef => {
|
viewController.compiler.compileInHost(this.ComponentClass).then(componentProtoViewRef => {
|
||||||
|
|
||||||
// figure out the sturcture of this Component
|
// figure out the sturcture of this Component
|
||||||
// does it have a navbar? Is it tabs? Should it not have a navbar or any toolbars?
|
// does it have a navbar? Is it tabs? Should it not have a navbar or any toolbars?
|
||||||
let itemStructure = getProtoViewStructure(componentProtoViewRef);
|
let itemStructure = getProtoViewStructure(componentProtoViewRef);
|
||||||
|
|
||||||
// get the appropriate Pane which this NavItem will fit into
|
// 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
|
// create a new injector just for this NavItem
|
||||||
let injector = nav.injector.resolveAndCreateChild([
|
let injector = viewController.injector.resolveAndCreateChild([
|
||||||
bind(NavBase).toValue(this.nav),
|
bind(ViewController).toValue(viewController),
|
||||||
bind(NavController).toValue(nav.navCtrl),
|
bind(NavController).toValue(viewController.navCtrl),
|
||||||
bind(NavParams).toValue(new NavParams(this.params)),
|
bind(NavParams).toValue(new NavParams(this.params)),
|
||||||
bind(NavItem).toValue(this)
|
bind(NavItem).toValue(this)
|
||||||
]);
|
]);
|
||||||
@ -65,7 +65,7 @@ export class NavItem {
|
|||||||
|
|
||||||
let newLocation = new ElementRef(hostViewRef, 0);
|
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.setViewElement( hostViewRef._view.render._view.rootNodes[0] );
|
||||||
|
|
||||||
this.disposals.push(() => {
|
this.disposals.push(() => {
|
||||||
@ -82,7 +82,7 @@ export class NavItem {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// get the item container's nav bar
|
// get the item container's nav bar
|
||||||
let navbarViewContainer = nav.navbarViewContainer();
|
let navbarViewContainer = viewController.navbarViewContainer();
|
||||||
|
|
||||||
// get the item's navbar protoview
|
// get the item's navbar protoview
|
||||||
let navbarProtoView = this.protos.navbar;
|
let navbarProtoView = this.protos.navbar;
|
||||||
|
@ -7,7 +7,7 @@ import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
|||||||
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
|
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
|
||||||
import {Injector} from 'angular2/di';
|
import {Injector} from 'angular2/di';
|
||||||
|
|
||||||
import {NavBase} from './nav-base';
|
import {ViewController} from '../view/view-controller';
|
||||||
import {IonicComponent} from '../../config/component';
|
import {IonicComponent} from '../../config/component';
|
||||||
|
|
||||||
|
|
||||||
@ -24,16 +24,16 @@ import {IonicComponent} from '../../config/component';
|
|||||||
`,
|
`,
|
||||||
directives: [NavPaneAnchor]
|
directives: [NavPaneAnchor]
|
||||||
})
|
})
|
||||||
export class Nav extends NavBase {
|
export class Nav extends ViewController {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Optional() parentNavBase: NavBase,
|
@Optional() viewController: ViewController,
|
||||||
compiler: Compiler,
|
compiler: Compiler,
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
loader: DynamicComponentLoader,
|
loader: DynamicComponentLoader,
|
||||||
injector: Injector
|
injector: Injector
|
||||||
) {
|
) {
|
||||||
super(parentNavBase, compiler, elementRef, loader, injector);
|
super(viewController, compiler, elementRef, loader, injector);
|
||||||
|
|
||||||
this.domElement = elementRef.domElement;
|
this.domElement = elementRef.domElement;
|
||||||
this.config = Nav.config.invoke(this);
|
this.config = Nav.config.invoke(this);
|
||||||
|
@ -4,8 +4,8 @@ import {Parent} from 'angular2/src/core/annotations_impl/visibility';
|
|||||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||||
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
||||||
|
|
||||||
|
import {ViewController} from '../view/view-controller';
|
||||||
import {Nav} from './nav';
|
import {Nav} from './nav';
|
||||||
import {NavBase} from './nav-base';
|
|
||||||
import {SwipeHandle} from './swipe-handle';
|
import {SwipeHandle} from './swipe-handle';
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ export class NavBarContainer {}
|
|||||||
selector: 'template[navbar-anchor]'
|
selector: 'template[navbar-anchor]'
|
||||||
})
|
})
|
||||||
class NavBarAnchor {
|
class NavBarAnchor {
|
||||||
constructor(nav: NavBase, viewContainerRef: ViewContainerRef) {
|
constructor(viewController: ViewController, viewContainerRef: ViewContainerRef) {
|
||||||
nav.navbarViewContainer(viewContainerRef);
|
viewController.navbarViewContainer(viewContainerRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ import {ElementRef} from 'angular2/angular2'
|
|||||||
import {Directive} from 'angular2/src/core/annotations_impl/annotations';
|
import {Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||||
import {Optional} from 'angular2/src/di/annotations_impl';
|
import {Optional} from 'angular2/src/di/annotations_impl';
|
||||||
|
|
||||||
|
import {ViewController} from '../view/view-controller';
|
||||||
import {Gesture} from 'ionic/gestures/gesture';
|
import {Gesture} from 'ionic/gestures/gesture';
|
||||||
import {NavBase} from './nav-base';
|
|
||||||
|
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
@ -14,12 +14,12 @@ import {NavBase} from './nav-base';
|
|||||||
})
|
})
|
||||||
export class SwipeHandle {
|
export class SwipeHandle {
|
||||||
constructor(
|
constructor(
|
||||||
@Optional() navBase: NavBase,
|
@Optional() viewController: ViewController,
|
||||||
elementRef: ElementRef
|
elementRef: ElementRef
|
||||||
) {
|
) {
|
||||||
if (!navBase) return;
|
if (!viewController) return;
|
||||||
|
|
||||||
this.navBase = navBase;
|
this.viewController = viewController;
|
||||||
|
|
||||||
let gesture = new Gesture(elementRef.domElement);
|
let gesture = new Gesture(elementRef.domElement);
|
||||||
gesture.listen();
|
gesture.listen();
|
||||||
@ -62,7 +62,7 @@ export class SwipeHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navBase.swipeBackEnd(completeSwipeBack, progress, playbackRate);
|
viewController.swipeBackEnd(completeSwipeBack, progress, playbackRate);
|
||||||
|
|
||||||
startX = null;
|
startX = null;
|
||||||
}
|
}
|
||||||
@ -73,18 +73,18 @@ export class SwipeHandle {
|
|||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
|
||||||
startX = ev.gesture.center.x;
|
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() {
|
showHandle() {
|
||||||
return (this.navBase ? this.navBase.swipeBackEnabled() : false);
|
return (this.viewController ? this.viewController.swipeBackEnabled() : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_compone
|
|||||||
import {Injector} from 'angular2/di';
|
import {Injector} from 'angular2/di';
|
||||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||||
|
|
||||||
|
import {ViewController} from '../view/view-controller';
|
||||||
import {Tabs} from './tabs';
|
import {Tabs} from './tabs';
|
||||||
import {NavBase} from '../nav/nav-base';
|
|
||||||
import {NavItem} from '../nav/nav-item';
|
import {NavItem} from '../nav/nav-item';
|
||||||
import {Content} from '../content/content';
|
import {Content} from '../content/content';
|
||||||
import {IonicComponent} from '../../config/component';
|
import {IonicComponent} from '../../config/component';
|
||||||
@ -39,7 +39,7 @@ import {IonicComponent} from '../../config/component';
|
|||||||
`,
|
`,
|
||||||
directives: [TabContentAnchor]
|
directives: [TabContentAnchor]
|
||||||
})
|
})
|
||||||
export class Tab extends NavBase {
|
export class Tab extends ViewController {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Parent() tabs: Tabs,
|
@Parent() tabs: Tabs,
|
||||||
@ -97,6 +97,6 @@ export class Tab extends NavBase {
|
|||||||
})
|
})
|
||||||
class TabContentAnchor {
|
class TabContentAnchor {
|
||||||
constructor(@Parent() tab: Tab, viewContainerRef: ViewContainerRef) {
|
constructor(@Parent() tab: Tab, viewContainerRef: ViewContainerRef) {
|
||||||
this.contentContainerRef = viewContainerRef;
|
tab.contentContainerRef = viewContainerRef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ import {Injector} from 'angular2/di';
|
|||||||
import {NgFor} from 'angular2/angular2';
|
import {NgFor} from 'angular2/angular2';
|
||||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||||
|
|
||||||
|
import {ViewController} from '../view/view-controller';
|
||||||
import {TabButton} from './tab-button';
|
import {TabButton} from './tab-button';
|
||||||
import {NavBase} from '../nav/nav-base';
|
|
||||||
import {Icon} from '../icon/icon';
|
import {Icon} from '../icon/icon';
|
||||||
import {NavItem} from '../nav/nav-item';
|
import {NavItem} from '../nav/nav-item';
|
||||||
import {IonicComponent} from '../../config/component';
|
import {IonicComponent} from '../../config/component';
|
||||||
@ -39,17 +39,17 @@ import {IonicComponent} from '../../config/component';
|
|||||||
`,
|
`,
|
||||||
directives: [NgFor, TabButton, Icon]
|
directives: [NgFor, TabButton, Icon]
|
||||||
})
|
})
|
||||||
export class Tabs extends NavBase {
|
export class Tabs extends ViewController {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Optional() parentNavBase: NavBase,
|
@Optional() viewController: ViewController,
|
||||||
@Optional() navItem: NavItem,
|
@Optional() navItem: NavItem,
|
||||||
compiler: Compiler,
|
compiler: Compiler,
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
loader: DynamicComponentLoader,
|
loader: DynamicComponentLoader,
|
||||||
injector: Injector
|
injector: Injector
|
||||||
) {
|
) {
|
||||||
super(parentNavBase, compiler, elementRef, loader, injector);
|
super(viewController, compiler, elementRef, loader, injector);
|
||||||
this.item = navItem;
|
this.item = navItem;
|
||||||
|
|
||||||
this.domElement = elementRef.domElement;
|
this.domElement = elementRef.domElement;
|
||||||
|
@ -9,18 +9,18 @@ import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
|||||||
import {Compiler} from 'angular2/angular2';
|
import {Compiler} from 'angular2/angular2';
|
||||||
import {bind} from 'angular2/di';
|
import {bind} from 'angular2/di';
|
||||||
|
|
||||||
import {NavController} from './nav-controller';
|
import {NavController} from '../nav/nav-controller';
|
||||||
import {NavItem, NavParams} from './nav-item';
|
import {NavItem, NavParams} from '../nav/nav-item';
|
||||||
import {Pane, NavBarContainer} from './pane';
|
import {Pane, NavBarContainer} from '../nav/pane';
|
||||||
import {Transition} from '../../transitions/transition';
|
import {Transition} from '../../transitions/transition';
|
||||||
import {ClickBlock} from '../../util/click-block';
|
import {ClickBlock} from '../../util/click-block';
|
||||||
import * as util from 'ionic/util';
|
import * as util from 'ionic/util';
|
||||||
|
|
||||||
|
|
||||||
export class NavBase {
|
export class ViewController {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
parent: NavBase,
|
parent: ViewController,
|
||||||
compiler: Compiler,
|
compiler: Compiler,
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
loader: DynamicComponentLoader,
|
loader: DynamicComponentLoader,
|
||||||
@ -62,7 +62,7 @@ export class NavBase {
|
|||||||
this.panes[itemStructure.key] = null;
|
this.panes[itemStructure.key] = null;
|
||||||
|
|
||||||
let injector = this.injector.resolveAndCreateChild([
|
let injector = this.injector.resolveAndCreateChild([
|
||||||
bind(NavBase).toValue(this)
|
bind(ViewController).toValue(this)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// add a Pane element
|
// add a Pane element
|
@ -39,7 +39,7 @@ class IOSTransition extends Transition {
|
|||||||
enteringBackButton
|
enteringBackButton
|
||||||
.from(OPACITY, 0)
|
.from(OPACITY, 0)
|
||||||
.to(OPACITY, 1);
|
.to(OPACITY, 1);
|
||||||
this.addAnimation(enteringBackButton);
|
this.add(enteringBackButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
// leaving view moves off screen
|
// leaving view moves off screen
|
||||||
@ -55,7 +55,7 @@ class IOSTransition extends Transition {
|
|||||||
leavingBackButton
|
leavingBackButton
|
||||||
.from(OPACITY, 1)
|
.from(OPACITY, 1)
|
||||||
.to(OPACITY, 0);
|
.to(OPACITY, 0);
|
||||||
this.addAnimation(leavingBackButton);
|
this.add(leavingBackButton);
|
||||||
|
|
||||||
// set properties depending on direction
|
// set properties depending on direction
|
||||||
if (opts.direction === 'back') {
|
if (opts.direction === 'back') {
|
||||||
|
@ -19,7 +19,7 @@ export class Transition extends Animation {
|
|||||||
// create animation for the entering item's "ion-view" element
|
// create animation for the entering item's "ion-view" element
|
||||||
this.enteringView = new Animation(enteringItem.viewElement());
|
this.enteringView = new Animation(enteringItem.viewElement());
|
||||||
this.enteringView.beforePlay.addClass(SHOW_VIEW_CSS);
|
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
|
// create animation for the entering item's "ion-navbar" element
|
||||||
if (opts.navbar !== false) {
|
if (opts.navbar !== false) {
|
||||||
@ -28,8 +28,8 @@ export class Transition extends Animation {
|
|||||||
|
|
||||||
// create animation for the entering item's "ion-title" element
|
// create animation for the entering item's "ion-title" element
|
||||||
this.enteringTitle = new Animation(enteringItem.titleElement());
|
this.enteringTitle = new Animation(enteringItem.titleElement());
|
||||||
this.enteringNavbar.addAnimation(this.enteringTitle);
|
this.enteringNavbar.add(this.enteringTitle);
|
||||||
this.addAnimation(this.enteringNavbar);
|
this.add(this.enteringNavbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leavingItem) {
|
if (leavingItem) {
|
||||||
@ -43,9 +43,9 @@ export class Transition extends Animation {
|
|||||||
|
|
||||||
// create animation for the leaving item's "ion-title" element
|
// create animation for the leaving item's "ion-title" element
|
||||||
this.leavingTitle = new Animation(leavingItem.titleElement());
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user