refactor(ViewController): remove need for viewType property

This commit is contained in:
Adam Bradley
2016-06-16 15:26:16 -05:00
parent d13fa4e2cf
commit e5d79d28c0
10 changed files with 16 additions and 41 deletions

View File

@ -141,7 +141,6 @@ export class ActionSheet extends ViewController {
opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
super(ActionSheetCmp, opts);
this.viewType = 'action-sheet';
this.isOverlay = true;
// by default, actionsheets should not fire lifecycle events of other views

View File

@ -194,7 +194,6 @@ export class Alert extends ViewController {
opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
super(AlertCmp, opts);
this.viewType = 'alert';
this.isOverlay = true;
// by default, alerts should not fire lifecycle events of other views

View File

@ -111,7 +111,6 @@ export class Loading extends ViewController {
opts.dismissOnPageChange = isPresent(opts.dismissOnPageChange) ? !!opts.dismissOnPageChange : false;
super(LoadingCmp, opts);
this.viewType = 'loading';
this.isOverlay = true;
this.usePortal = true;

View File

@ -1201,10 +1201,6 @@ export class NavController extends Ion {
this.setTransitioning(!enableApp, duration);
}
if (enteringView.viewType) {
transAnimation.before.addClass(enteringView.viewType);
}
// create a callback for when the animation is done
transAnimation.onFinish((trans: Transition) => {
// transition animation has ended
@ -1472,8 +1468,8 @@ export class NavController extends Ion {
return;
}
// automatically set "ion-page" selector
// TODO: see about having this set using ComponentFactory
// TEMPORARY: automatically set selector w/ dah reflector
// TODO: use componentFactory.create once fixed
addSelector(view.componentType, 'ion-page');
this._compiler.resolveComponent(view.componentType).then(componentFactory => {

View File

@ -68,11 +68,6 @@ export class ViewController {
*/
state: string = '';
/**
* @private
*/
viewType: string = '';
/**
* @private
* If this is currently the active view, then set to false

View File

@ -26,7 +26,6 @@ export class Picker extends ViewController {
opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
super(PickerDisplayCmp, opts);
this.viewType = 'picker';
this.isOverlay = true;
this.ionChange = new EventEmitter();

View File

@ -2,14 +2,13 @@ import {Component, ComponentResolver, ElementRef, HostListener, Renderer, ViewCh
import {addSelector} from '../../config/bootstrap';
import {Animation} from '../../animations/animation';
import {Config} from '../../config/config';
import {CSS, nativeRaf} from '../../util/dom';
import {isPresent, pascalCaseToDashCase} from '../../util/util';
import {Key} from '../../util/key';
import {NavParams} from '../nav/nav-params';
import {PageTransition} from '../../transitions/page-transition';
import {TransitionOptions} from '../../transitions/transition';
import {Config} from '../../config/config';
import {NavParams} from '../nav/nav-params';
import {Platform} from '../../platform/platform';
import {Key} from '../../util/key';
import {isPresent, isUndefined, isDefined} from '../../util/util';
import {nativeRaf, CSS} from '../../util/dom';
import {ViewController} from '../nav/view-controller';
const POPOVER_IOS_BODY_PADDING = 2;
@ -114,7 +113,6 @@ export class Popover extends ViewController {
data.componentType = componentType;
data.opts = opts;
super(PopoverCmp, data);
this.viewType = 'popover';
this.isOverlay = true;
// by default, popovers should not fire lifecycle events of other views
@ -123,13 +121,13 @@ export class Popover extends ViewController {
this.fireOtherLifecycles = false;
}
/**
/**
* @private
*/
getTransitionName(direction: string) {
let key = (direction === 'back' ? 'popoverLeave' : 'popoverEnter');
return this._nav && this._nav.config.get(key);
}
getTransitionName(direction: string) {
let key = (direction === 'back' ? 'popoverLeave' : 'popoverEnter');
return this._nav && this._nav.config.get(key);
}
/**
* Create a popover with the following options
@ -162,7 +160,7 @@ export class Popover extends ViewController {
'<div class="popover-arrow"></div>' +
'<div class="popover-content">' +
'<div class="popover-viewport">' +
'<div #viewport></div>' +
'<div #viewport nav-viewport></div>' +
'</div>' +
'</div>' +
'</div>'
@ -230,7 +228,7 @@ class PopoverCmp {
@HostListener('body:keyup', ['$event'])
private _keyUp(ev: KeyboardEvent) {
if (this.enabled && this._viewCtrl.isLast() && ev.keyCode === Key.ESCAPE ) {
if (this.enabled && ev.keyCode === Key.ESCAPE && this._viewCtrl.isLast()) {
this.bdClick();
}
}

View File

@ -74,7 +74,6 @@ export class Toast extends ViewController {
opts.position = TOAST_POSITION_BOTTOM;
}
this.viewType = 'toast';
this.isOverlay = true;
this.usePortal = true;

View File

@ -21,6 +21,7 @@ export * from './util/keyboard';
export * from './util/form';
export * from './animations/animation';
export * from './transitions/page-transition';
export * from './transitions/transition';
export * from './translation/translate';

View File

@ -2,7 +2,7 @@ import {Animation} from '../animations/animation';
import {closest} from '../util/dom';
import {Content} from '../components/content/content';
import {Tabs} from '../components/tabs/tabs';
import {Transition} from './transition';
import {Transition, TransitionOptions} from './transition';
import {ViewController} from '../components/nav/view-controller';
@ -130,13 +130,3 @@ function parsePxUnit(val: string): number {
return (val.indexOf('px') > 0) ? parseInt(val, 10) : 0;
}
export interface TransitionOptions {
animation: string;
duration: number;
easing: string;
direction: string;
renderDelay?: number;
isRTL?: boolean;
ev?: any;
}