react-native-navigation 7.33.0-alpha.4 → 7.33.0-alpha.6
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.util.Log
|
|
5
6
|
import android.view.View
|
|
6
7
|
import android.view.ViewGroup
|
|
7
8
|
import androidx.core.view.children
|
|
@@ -21,7 +22,7 @@ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceMa
|
|
|
21
22
|
// It's causing infinite measurements, that hung up the UI.
|
|
22
23
|
// Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
|
|
23
24
|
// See for more details https://github.com/wix/react-native-navigation/pull/7096
|
|
24
|
-
val measuredWidth = this.
|
|
25
|
+
val measuredWidth = this.getLastRootViewChild()?.width
|
|
25
26
|
|
|
26
27
|
return if (measuredWidth != null) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
|
|
27
28
|
widthMeasureSpec
|
|
@@ -33,23 +34,26 @@ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceMa
|
|
|
33
34
|
// It's causing infinite measurements, that hung up the UI.
|
|
34
35
|
// Intercepting largest child by height, and use its height as (parent) ReactRootView width fixed that.
|
|
35
36
|
// See for more details https://github.com/wix/react-native-navigation/pull/7096
|
|
36
|
-
val measuredHeight = this.
|
|
37
|
+
val measuredHeight = this.getLastRootViewChild()?.height
|
|
37
38
|
|
|
38
39
|
return if (measuredHeight != null) MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY) else
|
|
39
40
|
heightMeasureSpec
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
private fun
|
|
43
|
-
if (rootViewGroup.children.count()
|
|
43
|
+
private fun getLastRootViewChild(): View? {
|
|
44
|
+
if (rootViewGroup.children.count() == 0) {
|
|
44
45
|
return null
|
|
45
46
|
}
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
var rootViewGroupLastChild: View = rootViewGroup
|
|
48
|
+
var next = rootViewGroup as Any
|
|
49
|
+
while(next is ViewGroup && next.childCount > 0) try {
|
|
50
|
+
rootViewGroupLastChild = next
|
|
51
|
+
next.children.first().also { next = it }
|
|
52
|
+
|
|
49
53
|
} catch (e: Exception) {
|
|
50
|
-
|
|
54
|
+
Log.i("TitleBarReactView", "getRootViewFirstChild: ${e.message}")
|
|
51
55
|
}
|
|
52
56
|
@Suppress("UNREACHABLE_CODE")
|
|
53
|
-
return
|
|
57
|
+
return rootViewGroupLastChild
|
|
54
58
|
}
|
|
55
|
-
}
|
|
59
|
+
}
|