Skip to content

Commit c8264b4

Browse files
authored
fix: OverKeyboardView compatibility with RN 0.72 (#658)
## 📜 Description Added `RootViewCompat` interface to prevent build issues on RN < 0.72. ## 💡 Motivation and Context Prior to RN 0.73 `RootView` marked `onChildStartedNativeGesture(ev: MotionEvent?)` as deprecated, but without default implementation, so if you use `RootView` you had to override two methods: - `onChildStartedNativeGesture(ev: MotionEvent?)` - `override fun onChildStartedNativeGesture(childView: View, ev: MotionEvent)`; To fix this problem I decided to introduce common `RootViewCompat` interface that will have a stub for deprecated method. The reason why I moved it to separate file was mostly following SOLID principles - potentially this interface can be re-used in other parts of application, and I can not implement method directly in `OverKeyboardRootViewGroup` because I'll exceed maximum methods amount (11+). Closes #657 ## 📢 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 --> ### Android - added `RootViewCompat`; - use `RootViewCompat` instead of `RootView`. ## 🤔 How Has This Been Tested? Tested on CI. ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent f42d69d commit c8264b4

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import com.facebook.react.bridge.UiThreadUtil
1010
import com.facebook.react.config.ReactFeatureFlags
1111
import com.facebook.react.uimanager.JSPointerDispatcher
1212
import com.facebook.react.uimanager.JSTouchDispatcher
13-
import com.facebook.react.uimanager.RootView
1413
import com.facebook.react.uimanager.ThemedReactContext
1514
import com.facebook.react.uimanager.UIManagerHelper
1615
import com.facebook.react.uimanager.events.EventDispatcher
@@ -98,7 +97,7 @@ class OverKeyboardHostView(
9897
class OverKeyboardRootViewGroup(
9998
private val reactContext: ThemedReactContext,
10099
) : ReactViewGroup(reactContext),
101-
RootView {
100+
RootViewCompat {
102101
private val jsTouchDispatcher: JSTouchDispatcher = JSTouchDispatcher(this)
103102
private var jsPointerDispatcher: JSPointerDispatcher? = null
104103
internal var eventDispatcher: EventDispatcher? = null
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.reactnativekeyboardcontroller.views.overlay
2+
3+
import android.view.MotionEvent
4+
import com.facebook.react.uimanager.RootView
5+
6+
/**
7+
* Compat layer for `RootView` interface for RN < 0.73
8+
* which has a default implementation of deprecated method.
9+
*/
10+
interface RootViewCompat : RootView {
11+
@Deprecated(
12+
"This method shouldn't be used anymore.",
13+
ReplaceWith("onChildStartedNativeGesture(View childView, MotionEvent ev)"),
14+
)
15+
override fun onChildStartedNativeGesture(ev: MotionEvent?) {
16+
onChildStartedNativeGesture(null, ev)
17+
}
18+
}

0 commit comments

Comments
 (0)