-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
[RNKC-053] - native-stack + statusBarTranslucent causes incorrect positioning #51
Comments
The progress can be tracked here: https://github.com/kirillzyusko/react-native-screens/tree/refactor/removed-deprecated-replace-system-window-insets |
Just found a workaround: if you don't change soft-input method in screens, where status bar translucency is controlled by const useKeyboardAnimationInNativeStack = () => {
const context = useContext(KeyboardContext);
return context.animated;
}; This is a temporary workaround - I'm still looking for a complete solution/fix 👀 |
## 📜 Description Setup `onApplyWindowInsetsListener` that manages `systemBars` and `navigationBar` on `rootView` to get correct and constant insets. ## 💡 Motivation and Context If we setup `onApplyWindowInsetsListener` on `EdgeToEdgeReactViewGroup`, then sometimes insets are including keyboard size (it's is `0, 1225` (top, bottom) instead of expected `144, 84`). I discovered that if we setup `onApplyWindowInsetsListener` on `rootVIew` - in this case insets are always stable. So I reworked this part (worth to note that `onApplyWindowInsetsListener` that detects keyboard size changes still should listen to `EdgeToEdgeReactViewGroup` because otherwise it's not working). It fixes a problem with content jump, however the old approach (setting `padding` for `action_bar_root`) is not working anymore - instead we should apply margin. Last, but not least - we should setup it asynchronously, because if we setup it in `onAttachedToWindow`/`init` then it'll add undesired padding: <p align="center"> <img width="257" alt="image" src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/bac5586a-c91b-4162-8098-831b63607323"> </p> <p align="center"> <i>Area in blue - undesired margin</i> </p> Fixes #51 ## 📢 Changelog ### Android - apply `margin` to `action_bar_root` instead of `padding`; - for managing paddings setup `onApplyWindowInsetsListener` on `rootView`, keep `onApplyWindowInsetsListener` on `EdgeToEdgeView` just for detecting keyboard size changes; - setup `onApplyWindowInsetsListener` on `rootView` asynchronously (to avoid unnecessary margin on mount); - added `ThemedReactContext` extension that returns `rootView`; ## 🤔 How Has This Been Tested? Tested (fabric/paper) on: - Pixel 7 Pro (Android 13); - Redmi note 5 Pro (Android 9); ## 📸 Screenshots (if appropriate): |Before|After| |------|-----| |![telegram-cloud-photo-size-2-5402402906965133775-y](https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/e89ac555-4ef6-463d-81b6-7f66178fe506)|![telegram-cloud-photo-size-2-5402402906965133774-y](https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/1b94cb28-ce09-4977-967a-c7d1487377f9)| ## 📝 Checklist - [x] CI successfully passed
Describe the bug
using a combination of RN 0.69, native-stack and
statusBarTranslucent
causes some issues. Seems like keyboard insets are also applied automatically, and because of that positioning of views is incorrect.Repo for reproducing
#50
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Views shouldn't react on keyboard appearance if they don't subscribed to
useKeyboardAnimation
animated values.Screenshots
Smartphone (please complete the following information):
Additional context
Seems like it wasn't an issue in RN 0.68
The text was updated successfully, but these errors were encountered: