Fix cannot working Modal's onDismiss. (#29882)

Summary:
Fixes: https://github.com/facebook/react-native/issues/29455

Modal's onDismiss is not called on iOS.
This issue occurred the commit https://github.com/facebook/react-native/commit/bd2b7d6c0366b5f19de56b71cb706a0af4b0be43 and was fixed the commit https://github.com/facebook/react-native/commit/27a3248a3b37410b5ee6dda421ae00fa485b525c.
However, the master and stable-0.63 branches do not have this modified commit applied to them.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Modal's onDismiss prop will now be called successfully.

Pull Request resolved: https://github.com/facebook/react-native/pull/29882

Test Plan:
Tested on iOS with this change:

1. Set function Modal's onDismiss prop.
1. Set Modal's visible props is true. (show Modal)
1. Set Modal's visible props is false. (close Modal)
1. The set function in onDismiss is called.

Reviewed By: shergin

Differential Revision: D24648412

Pulled By: hramos

fbshipit-source-id: acf28fef21420117c845d3aed97e47b5dd4e9390
This commit is contained in:
Koichi Nagaoka
2020-11-13 23:56:09 -08:00
committed by Facebook GitHub Bot
parent 47000756fe
commit d85d5d2e19
7 changed files with 114 additions and 21 deletions
@@ -129,6 +129,13 @@ void ModalHostViewEventEmitter::onShow(OnShow event) const {
return payload;
});
}
void ModalHostViewEventEmitter::onDismiss(OnDismiss event) const {
dispatchEvent("dismiss", [event=std::move(event)](jsi::Runtime &runtime) {
auto payload = jsi::Object(runtime);
return payload;
});
}
void ModalHostViewEventEmitter::onOrientationChange(OnOrientationChange event) const {
dispatchEvent("orientationChange", [event=std::move(event)](jsi::Runtime &runtime) {
auto payload = jsi::Object(runtime);
@@ -196,6 +196,10 @@ class ModalHostViewEventEmitter : public ViewEventEmitter {
};
struct OnDismiss {
};
enum class OnOrientationChangeOrientation {
Portrait,
Landscape
@@ -216,6 +220,8 @@ class ModalHostViewEventEmitter : public ViewEventEmitter {
void onShow(OnShow value) const;
void onDismiss(OnDismiss value) const;
void onOrientationChange(OnOrientationChange value) const;
};