-
-
Notifications
You must be signed in to change notification settings - Fork 570
fix(Android): handle keyboard and formsheet together #2923
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
base: main
Are you sure you want to change the base?
fix(Android): handle keyboard and formsheet together #2923
Conversation
Hey @maciekstosio I noticed this work and thought it would be reasonable to create a discussion here. Do you think this functionality can be achieved using I understand the idea behind "a single package can handle navigation/keyboard management", but I also would love to see less DRY in the react-native ecosystem and more composability?.. Would love to know if the result that you are trying to achieve is not possible to achieve with |
…ithub.com:software-mansion/react-native-screens into @maciekstosio/Handle-bottom-sheet-with-a-keyboard
This looks amazing! Keyboard handling is the last issues that I have on new arch to make it work flawlessly. 🤞 |
Hey guys, is there any plans to merge it soon? |
Description
Fixes #2774, #2664
This issue aims to improve keyboard handling when using formsheet. Currently, we cover the formsheet and move to highest intent (when there are multiple) + force keyboard hide while swiping down. This sometimes look glitchy and causes formsheet to be covered in some scenarios.
Changes
I tested the Jetpack Compose version of form sheet and it didn't really seem to provide consistent experience as it is on iOS, so we modeled the solution to resemble iOS.
Before keyboard and formsheet were independent - one didn't animated with the other. For cases other than
fitToContents
when keyboard was opened the intent was bumped. When changing intent by swipe gesture, keyboard was dismissed.New solution consist of three parts:
WindowInsetsAnimationCompat.Callback
BottomSheetBehavior
onTouchEvent
is overridden and is used to swipe down the keyboard, SimpleImeAnimationController is used to control keyboard based on https://youtu.be/acC7SR1EXsI?feature=shared&t=718When keyboard is open on the previous screen, we force trigger
onApplyWindowInsets
to update screentransitionX
based on the keyboard height.Animating keyboard and controlling it is available from Android API 30, so for backward compatibility we set
translateX
inonApplyWindowInsets
.Screenshots / GIFs
One intent
formshee-1.mov
before-formsheet-1.mov
after-formsheet-1.mov
Two intents
formsheet-2.mov
before-formsheet2.mov
after-formsheet-2.mov
Three intents
formsheet-3.mov
before-formsheet-3.mov
after-formsheet-3.mov
Test code and steps to reproduce
See Test2774.tsx
How this has been tested
Checklist