react-native-navigation 7.33.3-hotfix.1 → 7.33.3-hotfix.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (13) hide show
  1. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/MotionEvent.kt +17 -3
  2. package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleAndButtonsContainer.kt +4 -0
  3. package/lib/android/app/src/reactNative51/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  4. package/lib/android/app/src/reactNative55/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  5. package/lib/android/app/src/reactNative56/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  6. package/lib/android/app/src/reactNative57/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  7. package/lib/android/app/src/reactNative57_5/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  8. package/lib/android/app/src/reactNative60/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  9. package/lib/android/app/src/reactNative62/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  10. package/lib/android/app/src/reactNative63/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  11. package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  12. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +10 -71
  13. package/package.json +1 -1
@@ -3,11 +3,25 @@ package com.reactnativenavigation.utils
3
3
  import android.graphics.Rect
4
4
  import android.view.MotionEvent
5
5
  import android.view.View
6
+ import android.view.ViewGroup
7
+ import com.reactnativenavigation.BuildConfig
6
8
 
7
9
  val hitRect = Rect()
8
10
 
9
11
  fun MotionEvent.coordinatesInsideView(view: View?): Boolean {
10
- view ?: return false
11
- view.getHitRect(hitRect)
12
- return hitRect.contains(x.toInt(), y.toInt())
12
+ if (BuildConfig.REACT_NATVE_VERSION_MINOR < 71) {
13
+ view ?: return false
14
+ view.getHitRect(hitRect)
15
+ return hitRect.contains(x.toInt(), y.toInt())
16
+ } else {
17
+ val viewGroup = (view as? ViewGroup)?.getChildAt(0) as? ViewGroup ?: return false
18
+
19
+ return if (viewGroup.childCount > 0) {
20
+ val content = viewGroup.getChildAt(0)
21
+ content.getHitRect(hitRect)
22
+ hitRect.contains(x.toInt(), y.toInt())
23
+ } else {
24
+ false
25
+ }
26
+ }
13
27
  }
@@ -153,6 +153,10 @@ class TitleAndButtonsContainer(context: Context) : ViewGroup(context) {
153
153
  val isCenter = titleComponentAlignment == Alignment.Center
154
154
  val titleHeightMeasureSpec = MeasureSpec.makeMeasureSpec(containerHeight, MeasureSpec.AT_MOST)
155
155
  val titleWidthMeasureSpec = makeTitleAtMostWidthMeasureSpec(containerWidth, rightBarWidth, leftBarWidth, isCenter)
156
+ if (titleComponent is TitleBarReactView) {
157
+ titleComponent.centered = isCenter
158
+ }
159
+
156
160
  titleComponent.measure(titleWidthMeasureSpec, titleHeightMeasureSpec)
157
161
  }
158
162
 
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -11,78 +11,17 @@ import com.reactnativenavigation.react.ReactView
11
11
  @SuppressLint("ViewConstructor")
12
12
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
13
13
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
14
+ var centered: Boolean = false
14
15
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
15
- super.onMeasure(interceptReactRootViewMeasureSpecWidth(widthMeasureSpec), interceptReactRootViewMeasureSpecHeight(heightMeasureSpec))
16
- }
17
-
18
- private fun interceptReactRootViewMeasureSpecWidth(widthMeasureSpec: Int): Int {
19
- // This is a HACK.
20
- // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
21
- // It's causing infinite measurements, that hung up the UI.
22
- // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
23
- // See for more details https://github.com/wix/react-native-navigation/pull/7096
24
- val measuredWidth = this.getLastRootViewChildMaxWidth()
25
-
26
- return if (measuredWidth != null) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
27
- widthMeasureSpec
28
- }
29
-
30
- private fun interceptReactRootViewMeasureSpecHeight(heightMeasureSpec: Int): Int {
31
- // This is a HACK.
32
- // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
33
- // It's causing infinite measurements, that hung up the UI.
34
- // Intercepting largest child by height, and use its height as (parent) ReactRootView width fixed that.
35
- // See for more details https://github.com/wix/react-native-navigation/pull/7096
36
- val measuredHeight = this.getLastRootViewChildMaxHeight()
37
-
38
- return if (measuredHeight != null) MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY) else
39
- heightMeasureSpec
40
- }
41
-
42
- private fun getLastRootViewChildMaxWidth(): Int {
43
- if (rootViewGroup.children.count() == 0) {
44
- return 0
45
- }
46
- var maxWidth = rootViewGroup.width
47
- var next = rootViewGroup as Any
48
- while(next is ViewGroup) { //try {
49
- if (next.width > maxWidth) {
50
- maxWidth = next.width
51
- }
52
- if (next.children.count() == 0) break
53
- next.children.first().also { next = it }
54
- }
55
- return maxWidth
56
- }
57
-
58
- private fun getLastRootViewChildMaxHeight(): Int {
59
- if (rootViewGroup.children.count() == 0) {
60
- return 0
61
- }
62
- var maxHeight = rootViewGroup.height
63
- var next = rootViewGroup as Any
64
- while(next is ViewGroup) { //try {
65
- if (next.height > maxHeight) {
66
- maxHeight = next.height
67
- }
68
- if (next.children.count() == 0) break
69
- next.children.first().also { next = it }
70
- }
71
- return maxHeight
72
- }
73
-
74
- private fun getLastRootViewChild(): View? {
75
- if (rootViewGroup.children.count() == 0) {
76
- return null
77
- }
78
- var rootViewGroupLastChild: View = rootViewGroup
79
- var next = rootViewGroup as Any
80
- while(next is ViewGroup) { //try {
81
- rootViewGroupLastChild = next
82
- if (next.children.count() == 0) break
83
- next.children.first().also { next = it }
16
+ var titleHeightMeasureSpec: Int
17
+ var titleWidthMeasureSpec: Int
18
+ if (centered) {
19
+ titleHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
20
+ titleWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
21
+ } else {
22
+ titleHeightMeasureSpec = heightMeasureSpec
23
+ titleWidthMeasureSpec = widthMeasureSpec
84
24
  }
85
- @Suppress("UNREACHABLE_CODE")
86
- return rootViewGroupLastChild
25
+ super.onMeasure(titleWidthMeasureSpec, titleHeightMeasureSpec)
87
26
  }
88
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.33.3-hotfix.1",
3
+ "version": "7.33.3-hotfix.3",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,