From 9618a65d86331a76ddfd88a35881cc928d96f921 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Fri, 9 Apr 2021 15:21:30 +0200 Subject: [PATCH] feat: closingModally event --- packages/core/ui/core/view/index.android.ts | 1 + packages/core/ui/core/view/index.ios.ts | 1 + packages/core/ui/core/view/view-common.ts | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/packages/core/ui/core/view/index.android.ts b/packages/core/ui/core/view/index.android.ts index 07fe9346b..462cc991b 100644 --- a/packages/core/ui/core/view/index.android.ts +++ b/packages/core/ui/core/view/index.android.ts @@ -713,6 +713,7 @@ export class View extends ViewCommon { } protected _hideNativeModalView(parent: View, whenClosedCallback: () => void) { + this._raiseClosingModallyEvent(); const manager = this._dialogFragment.getFragmentManager(); if (manager) { this._dialogFragment.dismissAllowingStateLoss(); diff --git a/packages/core/ui/core/view/index.ios.ts b/packages/core/ui/core/view/index.ios.ts index b695fa014..ff78cd301 100644 --- a/packages/core/ui/core/view/index.ios.ts +++ b/packages/core/ui/core/view/index.ios.ts @@ -543,6 +543,7 @@ export class View extends ViewCommon implements ViewDefinition { return; } + this._raiseClosingModallyEvent(); // modal view has already been closed by UI, probably as a popover if (!parent.viewController.presentedViewController) { diff --git a/packages/core/ui/core/view/view-common.ts b/packages/core/ui/core/view/view-common.ts index 4aac333b6..0278c689b 100644 --- a/packages/core/ui/core/view/view-common.ts +++ b/packages/core/ui/core/view/view-common.ts @@ -71,6 +71,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { public static layoutChangedEvent = 'layoutChanged'; public static shownModallyEvent = 'shownModally'; public static showingModallyEvent = 'showingModally'; + public static closingModallyEvent = 'closingModally'; public static accessibilityBlurEvent = accessibilityBlurEvent; public static accessibilityFocusEvent = accessibilityFocusEvent; public static accessibilityFocusChangedEvent = accessibilityFocusChangedEvent; @@ -434,6 +435,13 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { }; this.notify(args); } + protected _raiseClosingModallyEvent() { + const args: EventData = { + eventName: ViewCommon.closingModallyEvent, + object: this, + }; + this.notify(args); + } private _isEvent(name: string): boolean { return this.constructor && `${name}Event` in this.constructor;