Skip to content

Commit

Permalink
Patched react-native-navigation 0.75.x build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-saia-datadog committed Jan 27, 2025
1 parent aeda8cb commit 2c3ed01
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 99 deletions.
9 changes: 5 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"android": "yarn postinstall && react-native run-android",
"ios": "yarn postinstall && react-native run-ios",
"start": "yarn postinstall && react-native start",
"postinstall": "patch-package"
},
"dependencies": {
Expand Down Expand Up @@ -44,7 +44,8 @@
"@react-native/typescript-config": "0.75.4",
"@rnx-kit/metro-resolver-symlinks": "^0.1.36",
"babel-plugin-module-resolver": "^4.0.0",
"patch-package": "^8.0.0"
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0"
},
"engines": {
"node": ">=18"
Expand Down
154 changes: 59 additions & 95 deletions example/patches/react-native-navigation+7.40.1.patch
Original file line number Diff line number Diff line change
@@ -1,157 +1,121 @@
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactTypefaceUtils.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactTypefaceUtils.java
index 834d734..0246ecc 100644
index 834d734..7d90437 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactTypefaceUtils.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactTypefaceUtils.java
@@ -96,14 +96,14 @@ public class ReactTypefaceUtils {
@@ -96,12 +96,12 @@ public class ReactTypefaceUtils {

int want = 0;
if ((weight == Typeface.BOLD)
- || ((oldStyle & Typeface.BOLD) != 0 && weight == ReactTextShadowNode.UNSET)) {
- want |= Typeface.BOLD;
- }
+ || ((oldStyle & Typeface.BOLD) != 0)) {
+ want |= Typeface.BOLD;
+ }
want |= Typeface.BOLD;
}

if ((style == Typeface.ITALIC)
- || ((oldStyle & Typeface.ITALIC) != 0 && style == ReactTextShadowNode.UNSET)) {
- want |= Typeface.ITALIC;
- }
+ || ((oldStyle & Typeface.ITALIC) != 0)) {
+ want |= Typeface.ITALIC;
+ }
want |= Typeface.ITALIC;
}

if (family != null) {
typeface = ReactFontManager.getInstance().getTypeface(family, want, weight, assetManager);
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactViewGroup.kt b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactViewGroup.kt
index f92580c..9809d88 100644
index f92580c..04cf256 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactViewGroup.kt
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactViewGroup.kt
@@ -4,4 +4,4 @@ import com.facebook.react.views.view.ReactViewBackgroundDrawable
@@ -1,7 +1,15 @@
package com.reactnativenavigation.utils

-import com.facebook.react.views.view.ReactViewBackgroundDrawable
+import com.facebook.react.uimanager.LengthPercentage
+import com.facebook.react.uimanager.drawable.CSSBackgroundDrawable
import com.facebook.react.views.view.ReactViewGroup

val ReactViewGroup.borderRadius: Float
- get() = (background as? ReactViewBackgroundDrawable)?.fullBorderRadius ?: 0f
\ No newline at end of file
+ get() = 0f
+ get() {
+ val uniform: LengthPercentage = (background as? CSSBackgroundDrawable)?.borderRadius?.uniform
+ ?: return 0f
+
+ return uniform.resolve(
+ width.toFloat(), height.toFloat()
+ )
+ }
\ No newline at end of file
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/LayoutDirectionApplier.kt b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/LayoutDirectionApplier.kt
index 89216ae..20f3ffa 100644
index 89216ae..de104e2 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/LayoutDirectionApplier.kt
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/LayoutDirectionApplier.kt
@@ -3,13 +3,15 @@ package com.reactnativenavigation.viewcontrollers.viewcontroller
@@ -1,15 +1,19 @@
package com.reactnativenavigation.viewcontrollers.viewcontroller

+import android.annotation.SuppressLint
import com.facebook.react.ReactInstanceManager
import com.facebook.react.modules.i18nmanager.I18nUtil
import com.reactnativenavigation.options.Options
+import com.facebook.react.bridge.ReactContext

class LayoutDirectionApplier {
+ @SuppressLint("WrongConstant")
fun apply(root: ViewController<*>, options: Options, instanceManager: ReactInstanceManager) {
- if (options.layout.direction.hasValue() && instanceManager.currentReactContext != null) {
+ val reactContext = instanceManager.currentReactContext as? ReactContext
+ if (options.layout.direction.hasValue() && reactContext != null) {
root.activity.window.decorView.layoutDirection = options.layout.direction.get()
- root.activity.window.decorView.layoutDirection = options.layout.direction.get()
- I18nUtil.getInstance().allowRTL(instanceManager.currentReactContext, options.layout.direction.isRtl)
- I18nUtil.getInstance().forceRTL(instanceManager.currentReactContext, options.layout.direction.isRtl)
+ I18nUtil.getInstance().allowRTL(reactContext, options.layout.direction.isRtl)
+ I18nUtil.getInstance().forceRTL(reactContext, options.layout.direction.isRtl)
+ if (options.layout.direction.hasValue()) {
+ instanceManager.currentReactContext?.let { context ->
+ root.activity.window.decorView.layoutDirection = options.layout.direction.get()
+ I18nUtil.getInstance().allowRTL(context, options.layout.direction.isRtl)
+ I18nUtil.getInstance().forceRTL(context, options.layout.direction.isRtl)
+ }
}
}
}
\ No newline at end of file
diff --git a/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt b/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt
index ea8516f..ca02c01 100644
index ea8516f..17a60fc 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt
+++ b/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt
@@ -8,8 +8,7 @@ import com.facebook.react.uimanager.*
import com.facebook.react.uimanager.events.EventDispatcher
import com.facebook.react.views.view.ReactViewGroup

-
-class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
+class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView {
private var hasAdjustedSize = false
private var viewWidth = 0
private var viewHeight = 0
@@ -21,6 +20,7 @@ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
viewHeight = h
this.updateFirstChildView()
}
+
private fun updateFirstChildView() {
if (this.childCount > 0) {
hasAdjustedSize = false
@@ -29,12 +29,12 @@ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
override fun runGuarded() {
val uiManager = [email protected]().getNativeModule(
- UIManagerModule::class.java
+ UIManagerModule::class.java
) as UIManagerModule
uiManager.updateNodeSize(
- viewTag,
- [email protected],
- [email protected]
+ viewTag,
+ [email protected],
+ [email protected]
)
}
})
@@ -49,22 +49,32 @@ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
@@ -49,22 +49,24 @@ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
updateFirstChildView()
}
}
+
override fun onChildStartedNativeGesture(child: View, androidEvent: MotionEvent?) {
- mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
+ androidEvent?.let {
+ mJSTouchDispatcher.onChildStartedNativeGesture(it, this.getEventDispatcher()!!)
+ }
- override fun onChildStartedNativeGesture(child: View, androidEvent: MotionEvent?) {
+ override fun onChildStartedNativeGesture(child: View, androidEvent: MotionEvent) {
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
}
- override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
+
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
- mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
+ androidEvent?.let {
+ mJSTouchDispatcher.onChildStartedNativeGesture(it, this.getEventDispatcher()!!)
+ }
+ @Deprecated("Deprecated in Java")
+ override fun onChildStartedNativeGesture(androidEvent: MotionEvent) {
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
}
+
override fun onChildEndedNativeGesture(child: View, androidEvent: MotionEvent?) {
- mJSTouchDispatcher.onChildEndedNativeGesture(androidEvent, this.getEventDispatcher())
+ androidEvent?.let {
+ mJSTouchDispatcher.onChildEndedNativeGesture(it, this.getEventDispatcher()!!)
+ }
- override fun onChildEndedNativeGesture(child: View, androidEvent: MotionEvent?) {
+ override fun onChildEndedNativeGesture(child: View, androidEvent: MotionEvent) {
mJSTouchDispatcher.onChildEndedNativeGesture(androidEvent, this.getEventDispatcher())
}
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
- private fun getEventDispatcher(): EventDispatcher? {
+
private fun getEventDispatcher(): EventDispatcher? {
+ private fun getEventDispatcher(): EventDispatcher {
val reactContext: ReactContext = this.getReactContext()
- return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
+ return reactContext.getNativeModule(UIManagerModule::class.java)?.eventDispatcher
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
}

-
override fun handleException(t: Throwable?) {
getReactContext().handleException(RuntimeException(t))
}
@@ -74,14 +84,17 @@ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
@@ -73,12 +75,12 @@ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
return this.context as ReactContext
}

override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
- mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
+ event?.let {
+ mJSTouchDispatcher.handleTouchEvent(it, getEventDispatcher()!!)
+ }
- override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
+ override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
return super.onInterceptTouchEvent(event)
}

override fun onTouchEvent(event: MotionEvent?): Boolean {
- mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
+ event?.let {
+ mJSTouchDispatcher.handleTouchEvent(it, getEventDispatcher()!!)
+ }
- override fun onTouchEvent(event: MotionEvent?): Boolean {
+ override fun onTouchEvent(event: MotionEvent): Boolean {
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
super.onTouchEvent(event)
return true
}
-
}
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8854,6 +8854,7 @@ __metadata:
axios: ^1.6.8
babel-plugin-module-resolver: ^4.0.0
patch-package: ^8.0.0
postinstall-postinstall: ^2.1.0
react: 18.3.1
react-native: 0.75.4
react-native-crash-tester: 0.2.3
Expand Down Expand Up @@ -15504,6 +15505,13 @@ __metadata:
languageName: node
linkType: hard

"postinstall-postinstall@npm:^2.1.0":
version: 2.1.0
resolution: "postinstall-postinstall@npm:2.1.0"
checksum: e1d34252cf8d2c5641c7d2db7426ec96e3d7a975f01c174c68f09ef5b8327bc8d5a9aa2001a45e693db2cdbf69577094d3fe6597b564ad2d2202b65fba76134b
languageName: node
linkType: hard

"pprof-format@npm:^2.1.0":
version: 2.1.0
resolution: "pprof-format@npm:2.1.0"
Expand Down

0 comments on commit 2c3ed01

Please sign in to comment.