feat: add possibility to listen to react model open/request close #2
+43
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
At Reanimated we currently facing an issue that we're not able to listing to keyboard height changes in modal. This is due to the fact that android dialogs are attached next to the view tree, so we need to start observing insets on them separately, thus we need to listen to dialog open. To my knowledge, currently, there is no way to detect/listen when modal (dialog) is opened in a way that we can have access to its window (which we need to observe insets). The only hack that I found is listening to all events and act on “showModal”, which seems like hacky approach. In this PR I added observer that would be notified by ReactModalHostManager and would allow to attach listeners in other places. With this change in other packages we could get an instance and listen for those events. That should allow us to fix software-mansion/react-native-reanimated#5916 and may help with kirillzyusko/react-native-keyboard-controller#369.
Changelog:
[ANDROID] [ADDED] - Allow to listen to RN Modal events in native code.
Test Plan:
Tested on clean project from
npx @react-native-community/cli@next init MyApp --version next --skip-install
, which installs RN: 0.75.0-rc.5.Tested with following part added to MainApplication.kt onCreate:
Changes in RN Core as in the PR.
Part added to MainApplication.kt onCreate:
App.ts
Screen.Recording.2024-07-18.at.15.47.57.mov