From 5bfe7e44a00fb8856bb5cedea4aa602f4b6c2d58 Mon Sep 17 00:00:00 2001 From: mhartington Date: Thu, 3 Aug 2017 12:24:22 -0400 Subject: [PATCH] chore(): update events for popover and action-sheet --- .../action-sheet-controller.tsx | 6 ++--- .../components/action-sheet/action-sheet.tsx | 24 +++++++------------ .../popover-controller/popover-controller.tsx | 6 ++--- .../core/src/components/popover/popover.tsx | 4 +++- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/packages/core/src/components/action-sheet-controller/action-sheet-controller.tsx b/packages/core/src/components/action-sheet-controller/action-sheet-controller.tsx index 1397c482f2..e3244adf97 100644 --- a/packages/core/src/components/action-sheet-controller/action-sheet-controller.tsx +++ b/packages/core/src/components/action-sheet-controller/action-sheet-controller.tsx @@ -43,7 +43,7 @@ export class ActionSheetController implements IonicControllerApi { @Listen('body:ionActionSheetDidLoad') - viewDidLoad(ev) { + viewDidLoad(ev: ActionSheetEvent) { const actionsheet = ev.detail.actionsheet; const actionsheetResolve = this.actionsheetResolves[actionsheet.id]; if (actionsheetResolve) { @@ -55,13 +55,13 @@ export class ActionSheetController implements IonicControllerApi { @Listen('body:ionActionSheetWillPresent') willPresent(ev: ActionSheetEvent) { - this.actionsheets.push(ev.actionsheet); + this.actionsheets.push(ev.detail.actionsheet); } @Listen('body:ionActionSheetWillDismiss, body:ionActionSheetDidUnload') willDismiss(ev: ActionSheetEvent) { - const index = this.actionsheets.indexOf(ev.actionsheet); + const index = this.actionsheets.indexOf(ev.detail.actionsheet); if (index > -1) { this.actionsheets.splice(index, 1); } diff --git a/packages/core/src/components/action-sheet/action-sheet.tsx b/packages/core/src/components/action-sheet/action-sheet.tsx index d2593d6493..7cbcbdf77e 100644 --- a/packages/core/src/components/action-sheet/action-sheet.tsx +++ b/packages/core/src/components/action-sheet/action-sheet.tsx @@ -70,9 +70,7 @@ export class ActionSheet { // this.animation.destroy(); // this.animation = null; // } - this.ionActionSheetWillPresent.emit( - { actionsheet: this } as ActionSheetEvent - ); + this.ionActionSheetWillPresent.emit({ actionsheet: this }); // let animationBuilder = this.enterAnimation // ? this.enterAnimation @@ -96,12 +94,8 @@ export class ActionSheet { // } return new Promise(resolve => { - this.ionActionSheetWillDismiss.emit( - { actionsheet: this } as ActionSheetEvent - ); + this.ionActionSheetWillDismiss.emit({ actionsheet: this }); - // get the user's animation fn if one was provided - let animationBuilder = this.exitAnimation; // let animationBuilder = this.exitAnimation // ? this.exitAnimation @@ -111,9 +105,7 @@ export class ActionSheet { // this.animation = animationBuilder(this.el); // this.animation.onFinish((a: any) => { // a.destroy(); - this.ionActionSheetDidDismiss.emit( - { actionsheet: this } as ActionSheetEvent - ); + this.ionActionSheetDidDismiss.emit({ actionsheet: this }); Core.dom.write(() => { this.el.parentNode.removeChild(this.el); @@ -125,9 +117,7 @@ export class ActionSheet { } ionViewDidUnload() { - this.ionActionSheetDidUnload.emit( - { actionsheet: this } as ActionSheetEvent - ); + this.ionActionSheetDidUnload.emit({ actionsheet: this }); } backdropClick() { @@ -175,7 +165,7 @@ export interface ActionSheetOptions { title?: string; subTitle?: string; cssClass?: string; - buttons?: (ActionSheetButton | string)[]; + buttons?: (ActionSheetButtons | string)[]; enableBackdropDismiss?: boolean; } @@ -188,5 +178,7 @@ export interface ActionSheetButtons { } export interface ActionSheetEvent { - actionsheet: ActionSheet; + detail: { + actionsheet: ActionSheet; + }; } diff --git a/packages/core/src/components/popover-controller/popover-controller.tsx b/packages/core/src/components/popover-controller/popover-controller.tsx index 0cf6fd677d..34579e57ee 100644 --- a/packages/core/src/components/popover-controller/popover-controller.tsx +++ b/packages/core/src/components/popover-controller/popover-controller.tsx @@ -43,7 +43,7 @@ export class PopoverController implements IonicControllerApi { @Listen('body:ionPopoverDidLoad') - viewDidLoad(ev) { + viewDidLoad(ev: PopoverEvent) { const popover = ev.detail.popover; const popoverResolve = this.popoverResolves[popover.id]; if (popoverResolve) { @@ -55,13 +55,13 @@ export class PopoverController implements IonicControllerApi { @Listen('body:ionPopoverWillPresent') willPresent(ev: PopoverEvent) { - this.popovers.push(ev.popover); + this.popovers.push(ev.detail.popover); } @Listen('body:ionPopoverWillDismiss, body:ionPopoverDidUnload') willDismiss(ev: PopoverEvent) { - const index = this.popovers.indexOf(ev.popover); + const index = this.popovers.indexOf(ev.detail.popover); if (index > -1) { this.popovers.splice(index, 1); } diff --git a/packages/core/src/components/popover/popover.tsx b/packages/core/src/components/popover/popover.tsx index 8d91c674c0..03d0a108f8 100644 --- a/packages/core/src/components/popover/popover.tsx +++ b/packages/core/src/components/popover/popover.tsx @@ -176,5 +176,7 @@ export interface PopoverOptions { export interface PopoverEvent { - popover: Popover; + detail: { + popover: Popover; + } }