react-native-navigation 7.33.0-alpha.3 → 7.33.0-alpha.4

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.
@@ -2,6 +2,7 @@ package com.reactnativenavigation.views.stack.topbar.titlebar
2
2
 
3
3
  import android.annotation.SuppressLint
4
4
  import android.content.Context
5
+ import android.view.View
5
6
  import android.view.ViewGroup
6
7
  import androidx.core.view.children
7
8
  import com.facebook.react.ReactInstanceManager
@@ -20,13 +21,9 @@ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceMa
20
21
  // It's causing infinite measurements, that hung up the UI.
21
22
  // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
22
23
  // See for more details https://github.com/wix/react-native-navigation/pull/7096
23
- var measuredWidth = 0
24
+ val measuredWidth = this.getRootViewFirstChild()?.width
24
25
 
25
- if (rootViewGroup.children.count() > 0) {
26
- measuredWidth = (((rootViewGroup.children.first() as ViewGroup).children.first() as ViewGroup).children.first() as ViewGroup).width
27
- }
28
-
29
- return if (measuredWidth > 0) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
26
+ return if (measuredWidth != null) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
30
27
  widthMeasureSpec
31
28
  }
32
29
 
@@ -36,13 +33,23 @@ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceMa
36
33
  // It's causing infinite measurements, that hung up the UI.
37
34
  // Intercepting largest child by height, and use its height as (parent) ReactRootView width fixed that.
38
35
  // See for more details https://github.com/wix/react-native-navigation/pull/7096
39
- var measuredHeight = 0
36
+ val measuredHeight = this.getRootViewFirstChild()?.height
40
37
 
38
+ return if (measuredHeight != null) MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY) else
39
+ heightMeasureSpec
40
+ }
41
+
42
+ private fun getRootViewFirstChild(): View? {
41
43
  if (rootViewGroup.children.count() > 0) {
42
- measuredHeight = (((rootViewGroup.children.first() as ViewGroup).children.first() as ViewGroup).children.first() as ViewGroup).height
44
+ return null
43
45
  }
44
-
45
- return if (measuredHeight > 0) MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY) else
46
- heightMeasureSpec
46
+ var rootViewGroupFirstChild: View = rootViewGroup.children.first()
47
+ while(true) try {
48
+ (rootViewGroupFirstChild as ViewGroup).children.first().also { rootViewGroupFirstChild = it }
49
+ } catch (e: Exception) {
50
+ //
51
+ }
52
+ @Suppress("UNREACHABLE_CODE")
53
+ return rootViewGroupFirstChild
47
54
  }
48
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.33.0-alpha.3",
3
+ "version": "7.33.0-alpha.4",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,