Skip to content

fix: react-native-navigation integration #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 5, 2023

Conversation

kirillzyusko
Copy link
Owner

@kirillzyusko kirillzyusko commented May 13, 2023

📜 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:

image

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:

image

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):

Screen.Recording.2023-05-13.at.12.41.39.mov

📝 Checklist

  • CI successfully passed

@kirillzyusko kirillzyusko added 🐛 bug Something isn't working 🤖 android Android specific labels May 13, 2023
@kirillzyusko kirillzyusko self-assigned this May 13, 2023
@kirillzyusko kirillzyusko force-pushed the fix/130-native-navigation branch from 716f3ae to 006b176 Compare August 11, 2023 14:29
@github-actions
Copy link
Contributor

github-actions bot commented Aug 11, 2023

📊 Package size report

Current size Target Size Difference
63566 bytes 63385 bytes 181 bytes 📈

@kirillzyusko kirillzyusko force-pushed the fix/130-native-navigation branch from f660a62 to 754b185 Compare September 5, 2023 13:12
@kirillzyusko kirillzyusko marked this pull request as ready for review September 5, 2023 13:32
@kirillzyusko kirillzyusko merged commit 01dbb7f into main Sep 5, 2023
@kirillzyusko kirillzyusko deleted the fix/130-native-navigation branch September 5, 2023 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Android specific 🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with two providers and React Native Navigation (wix)
1 participant