You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 📜 Description
Fixed an integration with `react-native-navigation` without hacks.
## 💡 Motivation and Context
To overcome the initial problem I've decided to re-create callback
between `onAttachedToWindow`/`onDetachFromWindow` lifecycles. It
improves the situation, but at some point of time you still may
inconsistent values returned by hook and actual keyboard position.
For me it seems like if the `WindowInsetsAnimationCompat.Callback` is
attached to any parent view of the current screen (i. e. `decorView`,
`rootView`, etc.), then it can be broken after some navigation cycles.
This solution was inspired by
Omelyan/RNNKeyboardController-Test@d5ee7ea.
If we send events through overlay, then it's never broken. I had a look
on a view hierarchy and realised, that overlays are not attached to
parent views or to navigation tree:
<img width="672" alt="image"
src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/629002ec-7b41-479e-83b0-6122e75c5827">
I got an inspiration from this idea and decided to replicate this
mechanism in native code. I've decided to attach a view as a child to
`@id/action_bar_root` and setup callback on this view. In this case this
view will not be a parent of navigation tree and will not be inside of
navigation tree:
<img width="675" alt="image"
src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/18fc5714-6260-4b8f-b66a-7cee7ff3bc29">
However such approach didn't work out - it seems like if current view
has `onAttachedToWindow`/`onDetachedFromWindow` calls, then Keyboard
insets detection in the end will be broken on API < 30.
I've tried to remove this `eventView` in `onDetachedFromWindow` and
re-create it again in `onAttachedToWindow` - and such combination worked
out.
Fixes#130
## 📢 Changelog
### Android
- setup callbacks in `onAttachedToWindow`;
- add `eventView` as a child of `@id/action_bar_root` view (in
`onAttachedToWindow`);
- attach a callback to `eventView` rather than
`EdgeToEdgeReactViewGroup` (but still send events through
`EdgeToEdgeReactViewGroup` id)
- added `removeSelf` to `ViewGroup` extensions;
- remove `eventView` in `onDetachedFromWindow`;
- change `inputMode` only if new mode is not equal to current one;
### Docs
- update `README.md`;
## 🤔 How Has This Been Tested?
Tested on Pixel 6 Pro (API 28), emulator.
## 📸 Screenshots (if appropriate):
https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/923fe0b6-cdb3-4bca-92e2-44a2c7fe678d
## 📝 Checklist
- [x] CI successfully passed
0 commit comments