react-native-navigation 7.32.1 → 7.33.0-alpha.10

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 (23) hide show
  1. package/lib/Mock/Layouts/ComponentNode.ts +27 -31
  2. package/lib/android/app/src/reactNative55/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +42 -0
  3. package/lib/android/app/src/reactNative55/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +31 -0
  4. package/lib/android/app/src/reactNative56/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +42 -0
  5. package/lib/android/app/src/reactNative56/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +31 -0
  6. package/lib/android/app/src/reactNative57/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +42 -0
  7. package/lib/android/app/src/reactNative57/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +31 -0
  8. package/lib/android/app/src/reactNative57_5/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +42 -0
  9. package/lib/android/app/src/reactNative57_5/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +31 -0
  10. package/lib/android/app/src/reactNative60/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +42 -0
  11. package/lib/android/app/src/reactNative60/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +31 -0
  12. package/lib/android/app/src/reactNative62/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +42 -0
  13. package/lib/android/app/src/reactNative62/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +31 -0
  14. package/lib/android/app/src/reactNative63/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +42 -0
  15. package/lib/android/app/src/reactNative63/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +31 -0
  16. package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +42 -0
  17. package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +31 -0
  18. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +57 -0
  19. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +71 -0
  20. package/lib/dist/Mock/Layouts/ComponentNode.js +19 -23
  21. package/package.json +2 -2
  22. /package/lib/android/app/src/{main → reactNative51}/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegate.kt +0 -0
  23. /package/lib/android/app/src/{main → reactNative51}/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +0 -0
@@ -18,47 +18,43 @@ export default class ComponentNode extends ParentNode {
18
18
 
19
19
  public componentDidAppear() {
20
20
  if (this.componentDidMountOnce) {
21
- setTimeout(() => {
22
- events.invokeComponentWillAppear({
23
- componentName: this.data.name,
24
- componentId: this.nodeId,
25
- componentType: 'Component',
26
- });
27
- events.invokeComponentDidAppear({
28
- componentName: this.data.name,
29
- componentId: this.nodeId,
30
- componentType: 'Component',
31
- });
32
-
33
- this.buttonsDidAppear(
34
- _.concat(
35
- this.data.options.topBar?.rightButtons || [],
36
- this.data.options.topBar?.leftButtons || []
37
- )
38
- );
39
- this.titleChanged(undefined, this.data.options.topBar?.title);
40
- }, 0);
41
- } else {
42
- this.componentDidAppearPending = true;
43
- }
44
- }
45
-
46
- public componentDidDisappear() {
47
- setTimeout(() => {
48
- events.invokeComponentDidDisappear({
21
+ events.invokeComponentWillAppear({
22
+ componentName: this.data.name,
23
+ componentId: this.nodeId,
24
+ componentType: 'Component',
25
+ });
26
+ events.invokeComponentDidAppear({
49
27
  componentName: this.data.name,
50
28
  componentId: this.nodeId,
51
29
  componentType: 'Component',
52
30
  });
53
31
 
54
- this.buttonsDidDisappear(
32
+ this.buttonsDidAppear(
55
33
  _.concat(
56
34
  this.data.options.topBar?.rightButtons || [],
57
35
  this.data.options.topBar?.leftButtons || []
58
36
  )
59
37
  );
60
- this.titleChanged(this.data.options.topBar?.title);
61
- }, 0);
38
+ this.titleChanged(undefined, this.data.options.topBar?.title);
39
+ } else {
40
+ this.componentDidAppearPending = true;
41
+ }
42
+ }
43
+
44
+ public componentDidDisappear() {
45
+ events.invokeComponentDidDisappear({
46
+ componentName: this.data.name,
47
+ componentId: this.nodeId,
48
+ componentType: 'Component',
49
+ });
50
+
51
+ this.buttonsDidDisappear(
52
+ _.concat(
53
+ this.data.options.topBar?.rightButtons || [],
54
+ this.data.options.topBar?.leftButtons || []
55
+ )
56
+ );
57
+ this.titleChanged(this.data.options.topBar?.title);
62
58
  }
63
59
 
64
60
  titleChanged(oldTitle: any, newTitle?: any) {
@@ -0,0 +1,42 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ import android.content.Context
4
+ import android.view.View
5
+ import android.view.ViewGroup
6
+ import androidx.annotation.RestrictTo
7
+ import androidx.core.view.get
8
+ import com.reactnativenavigation.utils.isDebug
9
+ import java.util.*
10
+
11
+ open class YellowBoxDelegate(private val context: Context, private val yellowBoxHelper: YellowBoxHelper = YellowBoxHelper()) {
12
+ constructor(context: Context) : this(context, YellowBoxHelper())
13
+
14
+ var parent: ViewGroup? = null
15
+ private set
16
+ @get:RestrictTo(RestrictTo.Scope.TESTS)
17
+ val yellowBoxes: List<View>
18
+ get() = yellowBoxViews
19
+
20
+ private var isDestroyed = false
21
+ private val yellowBoxViews = ArrayList<View>()
22
+
23
+ open fun onChildViewAdded(parent: View, child: View?) {
24
+ if (!context.isDebug()) return
25
+ if (yellowBoxHelper.isYellowBox(parent, child)) onYellowBoxAdded(parent)
26
+ }
27
+
28
+ fun onYellowBoxAdded(parent: View) {
29
+ if (isDestroyed) return
30
+ this.parent = parent as ViewGroup
31
+ for (i in 1 until parent.childCount) {
32
+ yellowBoxViews.add(parent[i])
33
+ parent.removeView(parent[i])
34
+ parent.addView(View(context), i)
35
+ }
36
+ }
37
+
38
+ fun destroy() {
39
+ isDestroyed = true
40
+ if (yellowBoxViews.isNotEmpty()) yellowBoxViews.forEach { parent?.addView(it) }
41
+ }
42
+ }
@@ -0,0 +1,31 @@
1
+ package com.reactnativenavigation.views.stack.topbar.titlebar
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import androidx.core.view.children
6
+ import com.facebook.react.ReactInstanceManager
7
+ import com.reactnativenavigation.react.ReactView
8
+
9
+ @SuppressLint("ViewConstructor")
10
+ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
+ componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
+ super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
+ }
15
+
16
+ private fun interceptReactRootViewMeasureSpec(widthMeasureSpec: Int): Int {
17
+ // This is a HACK.
18
+ // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
19
+ // It's causing infinite measurements, that hung up the UI.
20
+ // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
21
+ // See for more details https://github.com/wix/react-native-navigation/pull/7096
22
+ var measuredWidth = 0;
23
+ this.children.forEach {
24
+ if (it.measuredWidth > measuredWidth) {
25
+ measuredWidth = it.measuredWidth
26
+ }
27
+ }
28
+ return if (measuredWidth > 0) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
29
+ widthMeasureSpec
30
+ }
31
+ }
@@ -0,0 +1,42 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ import android.content.Context
4
+ import android.view.View
5
+ import android.view.ViewGroup
6
+ import androidx.annotation.RestrictTo
7
+ import androidx.core.view.get
8
+ import com.reactnativenavigation.utils.isDebug
9
+ import java.util.*
10
+
11
+ open class YellowBoxDelegate(private val context: Context, private val yellowBoxHelper: YellowBoxHelper = YellowBoxHelper()) {
12
+ constructor(context: Context) : this(context, YellowBoxHelper())
13
+
14
+ var parent: ViewGroup? = null
15
+ private set
16
+ @get:RestrictTo(RestrictTo.Scope.TESTS)
17
+ val yellowBoxes: List<View>
18
+ get() = yellowBoxViews
19
+
20
+ private var isDestroyed = false
21
+ private val yellowBoxViews = ArrayList<View>()
22
+
23
+ open fun onChildViewAdded(parent: View, child: View?) {
24
+ if (!context.isDebug()) return
25
+ if (yellowBoxHelper.isYellowBox(parent, child)) onYellowBoxAdded(parent)
26
+ }
27
+
28
+ fun onYellowBoxAdded(parent: View) {
29
+ if (isDestroyed) return
30
+ this.parent = parent as ViewGroup
31
+ for (i in 1 until parent.childCount) {
32
+ yellowBoxViews.add(parent[i])
33
+ parent.removeView(parent[i])
34
+ parent.addView(View(context), i)
35
+ }
36
+ }
37
+
38
+ fun destroy() {
39
+ isDestroyed = true
40
+ if (yellowBoxViews.isNotEmpty()) yellowBoxViews.forEach { parent?.addView(it) }
41
+ }
42
+ }
@@ -0,0 +1,31 @@
1
+ package com.reactnativenavigation.views.stack.topbar.titlebar
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import androidx.core.view.children
6
+ import com.facebook.react.ReactInstanceManager
7
+ import com.reactnativenavigation.react.ReactView
8
+
9
+ @SuppressLint("ViewConstructor")
10
+ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
+ componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
+ super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
+ }
15
+
16
+ private fun interceptReactRootViewMeasureSpec(widthMeasureSpec: Int): Int {
17
+ // This is a HACK.
18
+ // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
19
+ // It's causing infinite measurements, that hung up the UI.
20
+ // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
21
+ // See for more details https://github.com/wix/react-native-navigation/pull/7096
22
+ var measuredWidth = 0;
23
+ this.children.forEach {
24
+ if (it.measuredWidth > measuredWidth) {
25
+ measuredWidth = it.measuredWidth
26
+ }
27
+ }
28
+ return if (measuredWidth > 0) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
29
+ widthMeasureSpec
30
+ }
31
+ }
@@ -0,0 +1,42 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ import android.content.Context
4
+ import android.view.View
5
+ import android.view.ViewGroup
6
+ import androidx.annotation.RestrictTo
7
+ import androidx.core.view.get
8
+ import com.reactnativenavigation.utils.isDebug
9
+ import java.util.*
10
+
11
+ open class YellowBoxDelegate(private val context: Context, private val yellowBoxHelper: YellowBoxHelper = YellowBoxHelper()) {
12
+ constructor(context: Context) : this(context, YellowBoxHelper())
13
+
14
+ var parent: ViewGroup? = null
15
+ private set
16
+ @get:RestrictTo(RestrictTo.Scope.TESTS)
17
+ val yellowBoxes: List<View>
18
+ get() = yellowBoxViews
19
+
20
+ private var isDestroyed = false
21
+ private val yellowBoxViews = ArrayList<View>()
22
+
23
+ open fun onChildViewAdded(parent: View, child: View?) {
24
+ if (!context.isDebug()) return
25
+ if (yellowBoxHelper.isYellowBox(parent, child)) onYellowBoxAdded(parent)
26
+ }
27
+
28
+ fun onYellowBoxAdded(parent: View) {
29
+ if (isDestroyed) return
30
+ this.parent = parent as ViewGroup
31
+ for (i in 1 until parent.childCount) {
32
+ yellowBoxViews.add(parent[i])
33
+ parent.removeView(parent[i])
34
+ parent.addView(View(context), i)
35
+ }
36
+ }
37
+
38
+ fun destroy() {
39
+ isDestroyed = true
40
+ if (yellowBoxViews.isNotEmpty()) yellowBoxViews.forEach { parent?.addView(it) }
41
+ }
42
+ }
@@ -0,0 +1,31 @@
1
+ package com.reactnativenavigation.views.stack.topbar.titlebar
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import androidx.core.view.children
6
+ import com.facebook.react.ReactInstanceManager
7
+ import com.reactnativenavigation.react.ReactView
8
+
9
+ @SuppressLint("ViewConstructor")
10
+ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
+ componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
+ super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
+ }
15
+
16
+ private fun interceptReactRootViewMeasureSpec(widthMeasureSpec: Int): Int {
17
+ // This is a HACK.
18
+ // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
19
+ // It's causing infinite measurements, that hung up the UI.
20
+ // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
21
+ // See for more details https://github.com/wix/react-native-navigation/pull/7096
22
+ var measuredWidth = 0;
23
+ this.children.forEach {
24
+ if (it.measuredWidth > measuredWidth) {
25
+ measuredWidth = it.measuredWidth
26
+ }
27
+ }
28
+ return if (measuredWidth > 0) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
29
+ widthMeasureSpec
30
+ }
31
+ }
@@ -0,0 +1,42 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ import android.content.Context
4
+ import android.view.View
5
+ import android.view.ViewGroup
6
+ import androidx.annotation.RestrictTo
7
+ import androidx.core.view.get
8
+ import com.reactnativenavigation.utils.isDebug
9
+ import java.util.*
10
+
11
+ open class YellowBoxDelegate(private val context: Context, private val yellowBoxHelper: YellowBoxHelper = YellowBoxHelper()) {
12
+ constructor(context: Context) : this(context, YellowBoxHelper())
13
+
14
+ var parent: ViewGroup? = null
15
+ private set
16
+ @get:RestrictTo(RestrictTo.Scope.TESTS)
17
+ val yellowBoxes: List<View>
18
+ get() = yellowBoxViews
19
+
20
+ private var isDestroyed = false
21
+ private val yellowBoxViews = ArrayList<View>()
22
+
23
+ open fun onChildViewAdded(parent: View, child: View?) {
24
+ if (!context.isDebug()) return
25
+ if (yellowBoxHelper.isYellowBox(parent, child)) onYellowBoxAdded(parent)
26
+ }
27
+
28
+ fun onYellowBoxAdded(parent: View) {
29
+ if (isDestroyed) return
30
+ this.parent = parent as ViewGroup
31
+ for (i in 1 until parent.childCount) {
32
+ yellowBoxViews.add(parent[i])
33
+ parent.removeView(parent[i])
34
+ parent.addView(View(context), i)
35
+ }
36
+ }
37
+
38
+ fun destroy() {
39
+ isDestroyed = true
40
+ if (yellowBoxViews.isNotEmpty()) yellowBoxViews.forEach { parent?.addView(it) }
41
+ }
42
+ }
@@ -0,0 +1,31 @@
1
+ package com.reactnativenavigation.views.stack.topbar.titlebar
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import androidx.core.view.children
6
+ import com.facebook.react.ReactInstanceManager
7
+ import com.reactnativenavigation.react.ReactView
8
+
9
+ @SuppressLint("ViewConstructor")
10
+ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
+ componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
+ super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
+ }
15
+
16
+ private fun interceptReactRootViewMeasureSpec(widthMeasureSpec: Int): Int {
17
+ // This is a HACK.
18
+ // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
19
+ // It's causing infinite measurements, that hung up the UI.
20
+ // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
21
+ // See for more details https://github.com/wix/react-native-navigation/pull/7096
22
+ var measuredWidth = 0;
23
+ this.children.forEach {
24
+ if (it.measuredWidth > measuredWidth) {
25
+ measuredWidth = it.measuredWidth
26
+ }
27
+ }
28
+ return if (measuredWidth > 0) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
29
+ widthMeasureSpec
30
+ }
31
+ }
@@ -0,0 +1,42 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ import android.content.Context
4
+ import android.view.View
5
+ import android.view.ViewGroup
6
+ import androidx.annotation.RestrictTo
7
+ import androidx.core.view.get
8
+ import com.reactnativenavigation.utils.isDebug
9
+ import java.util.*
10
+
11
+ open class YellowBoxDelegate(private val context: Context, private val yellowBoxHelper: YellowBoxHelper = YellowBoxHelper()) {
12
+ constructor(context: Context) : this(context, YellowBoxHelper())
13
+
14
+ var parent: ViewGroup? = null
15
+ private set
16
+ @get:RestrictTo(RestrictTo.Scope.TESTS)
17
+ val yellowBoxes: List<View>
18
+ get() = yellowBoxViews
19
+
20
+ private var isDestroyed = false
21
+ private val yellowBoxViews = ArrayList<View>()
22
+
23
+ open fun onChildViewAdded(parent: View, child: View?) {
24
+ if (!context.isDebug()) return
25
+ if (yellowBoxHelper.isYellowBox(parent, child)) onYellowBoxAdded(parent)
26
+ }
27
+
28
+ fun onYellowBoxAdded(parent: View) {
29
+ if (isDestroyed) return
30
+ this.parent = parent as ViewGroup
31
+ for (i in 1 until parent.childCount) {
32
+ yellowBoxViews.add(parent[i])
33
+ parent.removeView(parent[i])
34
+ parent.addView(View(context), i)
35
+ }
36
+ }
37
+
38
+ fun destroy() {
39
+ isDestroyed = true
40
+ if (yellowBoxViews.isNotEmpty()) yellowBoxViews.forEach { parent?.addView(it) }
41
+ }
42
+ }
@@ -0,0 +1,31 @@
1
+ package com.reactnativenavigation.views.stack.topbar.titlebar
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import androidx.core.view.children
6
+ import com.facebook.react.ReactInstanceManager
7
+ import com.reactnativenavigation.react.ReactView
8
+
9
+ @SuppressLint("ViewConstructor")
10
+ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
+ componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
+ super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
+ }
15
+
16
+ private fun interceptReactRootViewMeasureSpec(widthMeasureSpec: Int): Int {
17
+ // This is a HACK.
18
+ // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
19
+ // It's causing infinite measurements, that hung up the UI.
20
+ // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
21
+ // See for more details https://github.com/wix/react-native-navigation/pull/7096
22
+ var measuredWidth = 0;
23
+ this.children.forEach {
24
+ if (it.measuredWidth > measuredWidth) {
25
+ measuredWidth = it.measuredWidth
26
+ }
27
+ }
28
+ return if (measuredWidth > 0) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
29
+ widthMeasureSpec
30
+ }
31
+ }
@@ -0,0 +1,42 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ import android.content.Context
4
+ import android.view.View
5
+ import android.view.ViewGroup
6
+ import androidx.annotation.RestrictTo
7
+ import androidx.core.view.get
8
+ import com.reactnativenavigation.utils.isDebug
9
+ import java.util.*
10
+
11
+ open class YellowBoxDelegate(private val context: Context, private val yellowBoxHelper: YellowBoxHelper = YellowBoxHelper()) {
12
+ constructor(context: Context) : this(context, YellowBoxHelper())
13
+
14
+ var parent: ViewGroup? = null
15
+ private set
16
+ @get:RestrictTo(RestrictTo.Scope.TESTS)
17
+ val yellowBoxes: List<View>
18
+ get() = yellowBoxViews
19
+
20
+ private var isDestroyed = false
21
+ private val yellowBoxViews = ArrayList<View>()
22
+
23
+ open fun onChildViewAdded(parent: View, child: View?) {
24
+ if (!context.isDebug()) return
25
+ if (yellowBoxHelper.isYellowBox(parent, child)) onYellowBoxAdded(parent)
26
+ }
27
+
28
+ fun onYellowBoxAdded(parent: View) {
29
+ if (isDestroyed) return
30
+ this.parent = parent as ViewGroup
31
+ for (i in 1 until parent.childCount) {
32
+ yellowBoxViews.add(parent[i])
33
+ parent.removeView(parent[i])
34
+ parent.addView(View(context), i)
35
+ }
36
+ }
37
+
38
+ fun destroy() {
39
+ isDestroyed = true
40
+ if (yellowBoxViews.isNotEmpty()) yellowBoxViews.forEach { parent?.addView(it) }
41
+ }
42
+ }
@@ -0,0 +1,31 @@
1
+ package com.reactnativenavigation.views.stack.topbar.titlebar
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import androidx.core.view.children
6
+ import com.facebook.react.ReactInstanceManager
7
+ import com.reactnativenavigation.react.ReactView
8
+
9
+ @SuppressLint("ViewConstructor")
10
+ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
+ componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
+ super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
+ }
15
+
16
+ private fun interceptReactRootViewMeasureSpec(widthMeasureSpec: Int): Int {
17
+ // This is a HACK.
18
+ // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
19
+ // It's causing infinite measurements, that hung up the UI.
20
+ // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
21
+ // See for more details https://github.com/wix/react-native-navigation/pull/7096
22
+ var measuredWidth = 0;
23
+ this.children.forEach {
24
+ if (it.measuredWidth > measuredWidth) {
25
+ measuredWidth = it.measuredWidth
26
+ }
27
+ }
28
+ return if (measuredWidth > 0) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
29
+ widthMeasureSpec
30
+ }
31
+ }
@@ -0,0 +1,42 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ import android.content.Context
4
+ import android.view.View
5
+ import android.view.ViewGroup
6
+ import androidx.annotation.RestrictTo
7
+ import androidx.core.view.get
8
+ import com.reactnativenavigation.utils.isDebug
9
+ import java.util.*
10
+
11
+ open class YellowBoxDelegate(private val context: Context, private val yellowBoxHelper: YellowBoxHelper = YellowBoxHelper()) {
12
+ constructor(context: Context) : this(context, YellowBoxHelper())
13
+
14
+ var parent: ViewGroup? = null
15
+ private set
16
+ @get:RestrictTo(RestrictTo.Scope.TESTS)
17
+ val yellowBoxes: List<View>
18
+ get() = yellowBoxViews
19
+
20
+ private var isDestroyed = false
21
+ private val yellowBoxViews = ArrayList<View>()
22
+
23
+ open fun onChildViewAdded(parent: View, child: View?) {
24
+ if (!context.isDebug()) return
25
+ if (yellowBoxHelper.isYellowBox(parent, child)) onYellowBoxAdded(parent)
26
+ }
27
+
28
+ fun onYellowBoxAdded(parent: View) {
29
+ if (isDestroyed) return
30
+ this.parent = parent as ViewGroup
31
+ for (i in 1 until parent.childCount) {
32
+ yellowBoxViews.add(parent[i])
33
+ parent.removeView(parent[i])
34
+ parent.addView(View(context), i)
35
+ }
36
+ }
37
+
38
+ fun destroy() {
39
+ isDestroyed = true
40
+ if (yellowBoxViews.isNotEmpty()) yellowBoxViews.forEach { parent?.addView(it) }
41
+ }
42
+ }
@@ -0,0 +1,31 @@
1
+ package com.reactnativenavigation.views.stack.topbar.titlebar
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import androidx.core.view.children
6
+ import com.facebook.react.ReactInstanceManager
7
+ import com.reactnativenavigation.react.ReactView
8
+
9
+ @SuppressLint("ViewConstructor")
10
+ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
+ componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
+ super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
+ }
15
+
16
+ private fun interceptReactRootViewMeasureSpec(widthMeasureSpec: Int): Int {
17
+ // This is a HACK.
18
+ // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
19
+ // It's causing infinite measurements, that hung up the UI.
20
+ // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
21
+ // See for more details https://github.com/wix/react-native-navigation/pull/7096
22
+ var measuredWidth = 0;
23
+ this.children.forEach {
24
+ if (it.measuredWidth > measuredWidth) {
25
+ measuredWidth = it.measuredWidth
26
+ }
27
+ }
28
+ return if (measuredWidth > 0) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
29
+ widthMeasureSpec
30
+ }
31
+ }
@@ -0,0 +1,42 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ import android.content.Context
4
+ import android.view.View
5
+ import android.view.ViewGroup
6
+ import androidx.annotation.RestrictTo
7
+ import androidx.core.view.get
8
+ import com.reactnativenavigation.utils.isDebug
9
+ import java.util.*
10
+
11
+ open class YellowBoxDelegate(private val context: Context, private val yellowBoxHelper: YellowBoxHelper = YellowBoxHelper()) {
12
+ constructor(context: Context) : this(context, YellowBoxHelper())
13
+
14
+ var parent: ViewGroup? = null
15
+ private set
16
+ @get:RestrictTo(RestrictTo.Scope.TESTS)
17
+ val yellowBoxes: List<View>
18
+ get() = yellowBoxViews
19
+
20
+ private var isDestroyed = false
21
+ private val yellowBoxViews = ArrayList<View>()
22
+
23
+ open fun onChildViewAdded(parent: View, child: View?) {
24
+ if (!context.isDebug()) return
25
+ if (yellowBoxHelper.isYellowBox(parent, child)) onYellowBoxAdded(parent)
26
+ }
27
+
28
+ fun onYellowBoxAdded(parent: View) {
29
+ if (isDestroyed) return
30
+ this.parent = parent as ViewGroup
31
+ for (i in 1 until parent.childCount) {
32
+ yellowBoxViews.add(parent[i])
33
+ parent.removeView(parent[i])
34
+ parent.addView(View(context), i)
35
+ }
36
+ }
37
+
38
+ fun destroy() {
39
+ isDestroyed = true
40
+ if (yellowBoxViews.isNotEmpty()) yellowBoxViews.forEach { parent?.addView(it) }
41
+ }
42
+ }
@@ -0,0 +1,31 @@
1
+ package com.reactnativenavigation.views.stack.topbar.titlebar
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import androidx.core.view.children
6
+ import com.facebook.react.ReactInstanceManager
7
+ import com.reactnativenavigation.react.ReactView
8
+
9
+ @SuppressLint("ViewConstructor")
10
+ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
+ componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
+ super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
+ }
15
+
16
+ private fun interceptReactRootViewMeasureSpec(widthMeasureSpec: Int): Int {
17
+ // This is a HACK.
18
+ // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
19
+ // It's causing infinite measurements, that hung up the UI.
20
+ // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
21
+ // See for more details https://github.com/wix/react-native-navigation/pull/7096
22
+ var measuredWidth = 0;
23
+ this.children.forEach {
24
+ if (it.measuredWidth > measuredWidth) {
25
+ measuredWidth = it.measuredWidth
26
+ }
27
+ }
28
+ return if (measuredWidth > 0) MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY) else
29
+ widthMeasureSpec
30
+ }
31
+ }
@@ -0,0 +1,57 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ import android.content.Context
4
+ import android.util.Log
5
+ import android.view.View
6
+ import android.view.ViewGroup
7
+ import androidx.annotation.RestrictTo
8
+ import androidx.core.view.get
9
+ import com.reactnativenavigation.utils.isDebug
10
+ import java.util.*
11
+
12
+ open class YellowBoxDelegate(private val context: Context, private val yellowBoxHelper: YellowBoxHelper = YellowBoxHelper()) {
13
+ constructor(context: Context) : this(context, YellowBoxHelper())
14
+
15
+ var parent: ViewGroup? = null
16
+ private set
17
+ @get:RestrictTo(RestrictTo.Scope.TESTS)
18
+ val yellowBoxes: List<View>
19
+ get() = yellowBoxViews
20
+
21
+ private var isDestroyed = false
22
+ private val yellowBoxViews = ArrayList<View>()
23
+ private val tempViews = ArrayList<View>()
24
+
25
+ open fun onChildViewAdded(parent: View, child: View?) {
26
+ if (!context.isDebug()) return
27
+ onYellowBoxAdded(child)
28
+ }
29
+
30
+ fun onYellowBoxAdded(parent: View?) {
31
+ if (isDestroyed) return
32
+
33
+ this.parent = parent as ViewGroup
34
+
35
+ parent.setOnHierarchyChangeListener(object : ViewGroup.OnHierarchyChangeListener {
36
+ override fun onChildViewAdded(parent: View, child: View) {
37
+ if (!yellowBoxHelper.isYellowBox(parent, child) && (isDestroyed || tempViews.contains(child))) return
38
+ parent as ViewGroup
39
+ for (i in 1 until parent.childCount) {
40
+ yellowBoxViews.add(parent[i])
41
+ parent.removeView(parent[i])
42
+ var tempView = View(context)
43
+ tempViews.add(tempView)
44
+ parent.addView(tempView, i)
45
+ }
46
+ }
47
+
48
+ override fun onChildViewRemoved(parent: View?, child: View?) {
49
+ }
50
+ })
51
+ }
52
+
53
+ fun destroy() {
54
+ isDestroyed = true
55
+ if (yellowBoxViews.isNotEmpty()) yellowBoxViews.forEach { parent?.addView(it) }
56
+ }
57
+ }
@@ -0,0 +1,71 @@
1
+ package com.reactnativenavigation.views.stack.topbar.titlebar
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import android.view.View
6
+ import android.view.ViewGroup
7
+ import androidx.core.view.children
8
+ import com.facebook.react.ReactInstanceManager
9
+ import com.reactnativenavigation.react.ReactView
10
+
11
+ @SuppressLint("ViewConstructor")
12
+ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
13
+ componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
14
+ 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 MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY)
27
+ }
28
+
29
+ private fun interceptReactRootViewMeasureSpecHeight(heightMeasureSpec: Int): Int {
30
+ // This is a HACK.
31
+ // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
32
+ // It's causing infinite measurements, that hung up the UI.
33
+ // Intercepting largest child by height, and use its height as (parent) ReactRootView width fixed that.
34
+ // See for more details https://github.com/wix/react-native-navigation/pull/7096
35
+ val measuredHeight = this.getLastRootViewChild()?.height
36
+
37
+ return if (measuredHeight != null) MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY) else
38
+ heightMeasureSpec
39
+ }
40
+
41
+ private fun getLastRootViewChildMaxWidth(): Int {
42
+ if (rootViewGroup.children.count() == 0) {
43
+ return 0
44
+ }
45
+ var maxWidth = rootViewGroup.width
46
+ var next = rootViewGroup as Any
47
+ while(next is ViewGroup) { //try {
48
+ if (next.width > maxWidth) {
49
+ maxWidth = next.width
50
+ }
51
+ if (next.children.count() == 0) break
52
+ next.children.first().also { next = it }
53
+ }
54
+ return maxWidth
55
+ }
56
+
57
+ private fun getLastRootViewChild(): View? {
58
+ if (rootViewGroup.children.count() == 0) {
59
+ return null
60
+ }
61
+ var rootViewGroupLastChild: View = rootViewGroup
62
+ var next = rootViewGroup as Any
63
+ while(next is ViewGroup) { //try {
64
+ rootViewGroupLastChild = next
65
+ if (next.children.count() == 0) break
66
+ next.children.first().also { next = it }
67
+ }
68
+ @Suppress("UNREACHABLE_CODE")
69
+ return rootViewGroupLastChild
70
+ }
71
+ }
@@ -16,35 +16,31 @@ class ComponentNode extends ParentNode_1.default {
16
16
  }
17
17
  componentDidAppear() {
18
18
  if (this.componentDidMountOnce) {
19
- setTimeout(() => {
20
- EventsStore_1.events.invokeComponentWillAppear({
21
- componentName: this.data.name,
22
- componentId: this.nodeId,
23
- componentType: 'Component',
24
- });
25
- EventsStore_1.events.invokeComponentDidAppear({
26
- componentName: this.data.name,
27
- componentId: this.nodeId,
28
- componentType: 'Component',
29
- });
30
- this.buttonsDidAppear(lodash_1.default.concat(this.data.options.topBar?.rightButtons || [], this.data.options.topBar?.leftButtons || []));
31
- this.titleChanged(undefined, this.data.options.topBar?.title);
32
- }, 0);
19
+ EventsStore_1.events.invokeComponentWillAppear({
20
+ componentName: this.data.name,
21
+ componentId: this.nodeId,
22
+ componentType: 'Component',
23
+ });
24
+ EventsStore_1.events.invokeComponentDidAppear({
25
+ componentName: this.data.name,
26
+ componentId: this.nodeId,
27
+ componentType: 'Component',
28
+ });
29
+ this.buttonsDidAppear(lodash_1.default.concat(this.data.options.topBar?.rightButtons || [], this.data.options.topBar?.leftButtons || []));
30
+ this.titleChanged(undefined, this.data.options.topBar?.title);
33
31
  }
34
32
  else {
35
33
  this.componentDidAppearPending = true;
36
34
  }
37
35
  }
38
36
  componentDidDisappear() {
39
- setTimeout(() => {
40
- EventsStore_1.events.invokeComponentDidDisappear({
41
- componentName: this.data.name,
42
- componentId: this.nodeId,
43
- componentType: 'Component',
44
- });
45
- this.buttonsDidDisappear(lodash_1.default.concat(this.data.options.topBar?.rightButtons || [], this.data.options.topBar?.leftButtons || []));
46
- this.titleChanged(this.data.options.topBar?.title);
47
- }, 0);
37
+ EventsStore_1.events.invokeComponentDidDisappear({
38
+ componentName: this.data.name,
39
+ componentId: this.nodeId,
40
+ componentType: 'Component',
41
+ });
42
+ this.buttonsDidDisappear(lodash_1.default.concat(this.data.options.topBar?.rightButtons || [], this.data.options.topBar?.leftButtons || []));
43
+ this.titleChanged(this.data.options.topBar?.title);
48
44
  }
49
45
  titleChanged(oldTitle, newTitle) {
50
46
  if (oldTitle && oldTitle.component) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.32.1",
3
+ "version": "7.33.0-alpha.10",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,
@@ -148,7 +148,7 @@
148
148
  "simulator": {
149
149
  "type": "ios.simulator",
150
150
  "device": {
151
- "type": "iPhone 11"
151
+ "type": "iPhone 13 Pro Max"
152
152
  }
153
153
  },
154
154
  "genymotion.emulator.name": {