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
|
-
|
|
24
|
+
val measuredWidth = this.getRootViewFirstChild()?.width
|
|
24
25
|
|
|
25
|
-
if (
|
|
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
|
-
|
|
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
|
-
|
|
44
|
+
return null
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
}
|