feat: closingModally event

This commit is contained in:
Martin Guillon
2021-04-09 15:21:30 +02:00
parent 3f5ec3440d
commit 9618a65d86
3 changed files with 10 additions and 0 deletions

View File

@ -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();

View File

@ -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) {

View File

@ -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;