Skip to content
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

feat: over keyboard view #589

Merged
merged 44 commits into from
Sep 23, 2024
Merged

feat: over keyboard view #589

merged 44 commits into from
Sep 23, 2024

Conversation

kirillzyusko
Copy link
Owner

@kirillzyusko kirillzyusko commented Sep 20, 2024

📜 Description

Added OverKeyboardView component.

💡 Motivation and Context

From an implementation perspective I think it's worth to note that there are only one way to implement that:

  • on Android we need to attach a view directly to WindowManager with TYPE_APPLICATION_PANEL;
  • on iOS we need to attach view directly to UIRemoteKeyboardWindow (prior to iOS 16 it was possible to attach just as a last window, but starting from iOS 16 the UIRemoteKeyboardWindow gets hidden in window list);

So in this PR I used approaches from above to achieve this.

From an unusual things:

  • on Android we need to stretch first children to screen size manually - it's done via custom ShadowNode and overwriting lifecycle method;
  • on iOS we have to do the same, but I couldn't achieve this from a native code, so I specified styles in JS code;
  • on iOS touch handlers from Detox are not working (I don't know why - plaing touchable system and RNGH works fine);
  • on Android if touch gets unhandled then application will instantly crash - that's why I wrapped the OverKeyboardView in TouchableWithoutFeedback.

Closes #373

📢 Changelog

Docs

  • added a page in API section;
  • added to feature comparison;
  • added a new line in README;
  • added a new keyword in package.json;

E2E

  • added new test for OverKeybaordView;

JS

  • added OverKeyboardView view;
  • added unit-tests for new component;
  • added new mocks;
  • added example screen with usage of new component;

iOS

  • export new OverKeyboardView component;
  • added new UIWindow.topWindow extension;

Android

  • export new OverKeyboardView component;
  • added new getDisplaySize extension;

🤔 How Has This Been Tested?

Tested manually on:

  • iPhone 6s (iOS 15, real device);
  • iPhone 15 Pro (iOS 17.5, simulator);
  • iPhone 11 (iOS 18, real device);
  • Xiaomi Redmi Note 5 Pro (Android 9, real device)
  • Pixel 7 Pro (Android 14, real device);
  • Pixel 3a (Android 13, emulator);

📸 Screenshots (if appropriate):

Android iOS
image

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko added documentation Improvements or additions to documentation enhancement New feature or request e2e Anything about E2E tests tests You added or changed unit tests labels Sep 20, 2024
@kirillzyusko kirillzyusko self-assigned this Sep 20, 2024
Copy link
Contributor

github-actions bot commented Sep 20, 2024

PR Preview Action v1.4.8
🚀 Deployed preview to https://kirillzyusko.github.io/react-native-keyboard-controller/pr-preview/pr-589/
on branch gh-pages at 2024-09-23 09:30 UTC

@kirillzyusko kirillzyusko added the OverKeyboardView Anything related to OverKeyboardView label Sep 20, 2024
Copy link

argos-ci bot commented Sep 20, 2024

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Sep 23, 2024, 9:32 AM

Copy link
Contributor

github-actions bot commented Sep 20, 2024

📊 Package size report

Current size Target Size Difference
155924 bytes 148737 bytes 7187 bytes 📈

@kirillzyusko kirillzyusko marked this pull request as ready for review September 23, 2024 09:21
@kirillzyusko kirillzyusko merged commit bc8d3b7 into main Sep 23, 2024
34 checks passed
@kirillzyusko kirillzyusko deleted the feat/over-keyboard-view branch September 23, 2024 10:35
kirillzyusko added a commit that referenced this pull request Sep 29, 2024
## 📜 Description

Fixed integration of `GestureDetector` inside `OverKeyboardView`.

## 💡 Motivation and Context

The problem came to the fact that `TouchableWithoutFeedback` kind of
intercepted touches and `GestureDetector` didn't receive it. I added
`TouchableWithoutFeedback` in
#589
- in that PR it was reasonable to keep it there as it prevented crashes
when touch gets handled by `rootView`. However in most cases developers
will wrap area in `OverKeyboardView` in `Touchable*` to handle closing
of their views, so now for me it seems to be safe to remove it.

The second thing is that if we apply styles to stretch inner view in JS
then `GestureDetector` becomes broken again. I added this fix as iOS
only and back to the time I haven't discovered any issues on Android.
Now I see, that it introduces some edge-case bugs, so I apply this
style/fix conditionally (iOS only).

Applying these 2 fixes `GestureDetector` can work in `OverKeyboardView`.

Fixes an issue discovered in
#599

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### JS

- removed `TouchableWithoutFeedback`;
- apply `width`/`height` style only for `ios`.

## 🤔 How Has This Been Tested?

Tested manually on Pixel 3a (API 33, emulator) and Pixel 7 Pro (API 34,
real device).

## 📸 Screenshots (if appropriate):

|Before|After|
|-------|-----|
|<video
src="https://github.com/user-attachments/assets/b26347e8-38ee-48b8-ba2c-2a5f4a354c70">|<video
src="https://github.com/user-attachments/assets/5b54733b-9f2d-4c73-80ce-441c1f43c7a6">|

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation e2e Anything about E2E tests enhancement New feature or request OverKeyboardView Anything related to OverKeyboardView tests You added or changed unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an ability to show views over the keyboard (when it's open)
1 participant