react-native-navigation 8.4.1 → 8.4.2

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,7 +2,7 @@ package com.reactnativenavigation.utils
2
2
 
3
3
  import android.content.Context
4
4
  import android.content.res.Configuration
5
- import android.content.res.Configuration.UI_MODE_NIGHT_YES
5
+ import androidx.appcompat.app.AppCompatDelegate
6
6
  import com.facebook.react.ReactApplication
7
7
  import com.reactnativenavigation.NavigationApplication
8
8
 
@@ -10,6 +10,10 @@ fun Context.isDebug(): Boolean {
10
10
  return (applicationContext as ReactApplication).reactNativeHost.useDeveloperSupport
11
11
  }
12
12
  fun isDarkMode() = NavigationApplication.instance.isDarkMode()
13
- fun Context.isDarkMode(): Boolean =
14
- (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES
15
- fun Configuration.isDarkMode() = (uiMode and Configuration.UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES
13
+ fun Context.isDarkMode(): Boolean = when (AppCompatDelegate.getDefaultNightMode()) {
14
+ AppCompatDelegate.MODE_NIGHT_YES -> true
15
+ AppCompatDelegate.MODE_NIGHT_NO -> false
16
+ else -> resources.configuration.isDarkMode()
17
+ }
18
+ fun Configuration.isDarkMode() =
19
+ (uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
@@ -1,14 +1,21 @@
1
1
  package com.reactnativenavigation.views.touch
2
2
 
3
3
  import android.view.MotionEvent
4
+ import android.view.View
5
+ import android.view.ViewGroup
4
6
  import androidx.annotation.VisibleForTesting
7
+ import com.facebook.react.views.debuggingoverlay.DebuggingOverlay
5
8
  import com.reactnativenavigation.options.params.Bool
6
9
  import com.reactnativenavigation.options.params.NullBool
7
10
  import com.reactnativenavigation.react.ReactView
8
11
  import com.reactnativenavigation.utils.coordinatesInsideView
9
12
  import com.reactnativenavigation.views.component.ComponentLayout
13
+ import androidx.core.view.isVisible
10
14
 
11
- open class OverlayTouchDelegate(private val component: ComponentLayout, private val reactView: ReactView) {
15
+ open class OverlayTouchDelegate(
16
+ private val component: ComponentLayout,
17
+ private val reactView: ReactView
18
+ ) {
12
19
  var interceptTouchOutside: Bool = NullBool()
13
20
 
14
21
  fun onInterceptTouchEvent(event: MotionEvent): Boolean {
@@ -19,8 +26,38 @@ open class OverlayTouchDelegate(private val component: ComponentLayout, private
19
26
  }
20
27
 
21
28
  @VisibleForTesting
22
- open fun handleDown(event: MotionEvent) = when (event.coordinatesInsideView(reactView.getChildAt(0))) {
29
+ open fun handleDown(event: MotionEvent) = when (isInsideView(event)) {
23
30
  true -> component.superOnInterceptTouchEvent(event)
24
31
  false -> interceptTouchOutside.isFalse
25
32
  }
33
+
34
+ /**
35
+ * In new architecture, ReactView could have a DebugOverlay as a child that covers the entire screen.
36
+ * We need to check if the touch event is inside the actual React content. So we go over all children
37
+ * of the ReactView and check if the event is inside any of them except the DebugOverlay.
38
+ *
39
+ * Example of ReactView hierarchy:
40
+ * ```
41
+ * ReactView
42
+ * └── ReactSurfaceView
43
+ * ├── ReactViewGroup
44
+ * │ └── DebuggingOverlay (covers entire screen)
45
+ * └── ReactViewGroup (the content we care about)
46
+ * ```
47
+ */
48
+ private fun isInsideView(event: MotionEvent): Boolean {
49
+ val reactViewSurface = this.reactView.getChildAt(0) as ViewGroup
50
+ for (i in 0 until reactViewSurface.childCount) {
51
+ val childItem = reactViewSurface.getChildAt(i)
52
+
53
+ if (!debuggingOverlay(childItem) && childItem.isVisible && event.coordinatesInsideView(childItem)) {
54
+ return true
55
+ }
56
+ }
57
+ return false
58
+ }
59
+
60
+ private fun debuggingOverlay(childItem: View?): Boolean =
61
+ childItem is ViewGroup && childItem.getChildAt(0) is DebuggingOverlay
62
+
26
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "8.4.1",
3
+ "version": "8.4.2",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,