react-native-navigation 8.8.5-snapshot.2556 → 8.8.5-snapshot.2563

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.
@@ -79,7 +79,7 @@ object SystemUiUtils {
79
79
  @JvmStatic
80
80
  fun setupSystemBarBackgrounds(activity: Activity, contentLayout: ViewGroup) {
81
81
  setupStatusBarBackground(activity)
82
- setupNavigationBarBackground(contentLayout)
82
+ setupNavigationBarBackground(activity.window, contentLayout)
83
83
  }
84
84
 
85
85
  private fun setupStatusBarBackground(activity: Activity) {
@@ -117,10 +117,10 @@ object SystemUiUtils {
117
117
  return view
118
118
  }
119
119
 
120
- private fun setupNavigationBarBackground(contentLayout: ViewGroup) {
120
+ private fun setupNavigationBarBackground(window: Window?, contentLayout: ViewGroup) {
121
121
  if (navBarBackgroundView != null) return
122
122
  val view = View(contentLayout.context).apply {
123
- setBackgroundColor(Color.BLACK)
123
+ setBackgroundColor(getNavigationBarBackgroundColor(window))
124
124
  }
125
125
  val params = FrameLayout.LayoutParams(
126
126
  FrameLayout.LayoutParams.MATCH_PARENT, 0, Gravity.BOTTOM
@@ -134,7 +134,7 @@ object SystemUiUtils {
134
134
  val wasThreeButton = isThreeButtonNav
135
135
  isThreeButtonNav = tappableHeight > 0
136
136
  if (isThreeButtonNav != wasThreeButton) {
137
- val color = lastExplicitNavBarColor ?: getDefaultNavBarColor()
137
+ val color = lastExplicitNavBarColor ?: getNavigationBarBackgroundColor(v)
138
138
  v.setBackgroundColor(color)
139
139
  }
140
140
  val lp = v.layoutParams
@@ -147,6 +147,17 @@ object SystemUiUtils {
147
147
  view.requestApplyInsets()
148
148
  }
149
149
 
150
+ private fun getNavigationBarBackgroundColor(window: Window?): Int {
151
+ lastExplicitNavBarColor?.let { return it }
152
+ @Suppress("DEPRECATION")
153
+ return window?.navigationBarColor ?: getDefaultNavBarColor()
154
+ }
155
+
156
+ private fun getNavigationBarBackgroundColor(view: View): Int {
157
+ lastExplicitNavBarColor?.let { return it }
158
+ return (view.background as? ColorDrawable)?.color ?: getDefaultNavBarColor()
159
+ }
160
+
150
161
  /**
151
162
  * Returns the default navigation bar color, applying 80% opacity for 3-button navigation.
152
163
  * Gesture navigation gets a fully opaque color since the bar is minimal.
@@ -321,9 +332,8 @@ object SystemUiUtils {
321
332
  window?.let {
322
333
  WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightNavigationBars = lightColor
323
334
  }
324
- if (isEdgeToEdgeActive) {
325
- navBarBackgroundView?.setBackgroundColor(color)
326
- } else {
335
+ navBarBackgroundView?.setBackgroundColor(color)
336
+ if (!isEdgeToEdgeActive) {
327
337
  @Suppress("DEPRECATION")
328
338
  window?.navigationBarColor = color
329
339
  }
@@ -1,16 +1,28 @@
1
1
  package com.reactnativenavigation.utils
2
2
 
3
3
  import android.graphics.Color
4
+ import android.graphics.drawable.ColorDrawable
5
+ import android.view.View
4
6
  import android.view.Window
7
+ import android.widget.FrameLayout
8
+ import androidx.appcompat.app.AppCompatActivity
5
9
  import com.reactnativenavigation.BaseRobolectricTest
6
10
  import com.reactnativenavigation.utils.SystemUiUtils.STATUS_BAR_HEIGHT_TRANSLUCENCY
11
+ import org.assertj.core.api.Java6Assertions.assertThat
12
+ import org.junit.After
7
13
  import org.junit.Test
8
14
  import org.mockito.Mockito
9
15
  import org.mockito.kotlin.verify
16
+ import org.robolectric.Robolectric
10
17
  import kotlin.math.ceil
11
18
 
12
19
  class SystemUiUtilsTest : BaseRobolectricTest() {
13
20
 
21
+ @After
22
+ fun afterEach() {
23
+ SystemUiUtils.tearDown()
24
+ }
25
+
14
26
  @Test
15
27
  fun `setStatusBarColor - should change color considering alpha`() {
16
28
  val window = Mockito.mock(Window::class.java)
@@ -24,4 +36,55 @@ class SystemUiUtilsTest : BaseRobolectricTest() {
24
36
 
25
37
  verify(window).statusBarColor = Color.argb(ceil(STATUS_BAR_HEIGHT_TRANSLUCENCY*255).toInt(), 22, 255, 255)
26
38
  }
27
- }
39
+
40
+ @Test
41
+ fun `setupSystemBarBackgrounds - initializes navigation bar background from resolved color`() {
42
+ val activity = Robolectric.setupActivity(AppCompatActivity::class.java)
43
+ val contentLayout = FrameLayout(activity)
44
+ val initialColor = Color.RED
45
+ SystemUiUtils.setNavigationBarBackgroundColor(activity.window, initialColor, false)
46
+
47
+ SystemUiUtils.setupSystemBarBackgrounds(activity, contentLayout)
48
+
49
+ assertThat(getBackgroundColor(getNavigationBarBackground(contentLayout))).isEqualTo(initialColor)
50
+ }
51
+
52
+ @Test
53
+ fun `setNavigationBarBackgroundColor - updates view and window color when edge-to-edge is inactive`() {
54
+ val activity = Robolectric.setupActivity(AppCompatActivity::class.java)
55
+ val contentLayout = FrameLayout(activity)
56
+ @Suppress("DEPRECATION")
57
+ activity.window.navigationBarColor = Color.BLACK
58
+ SystemUiUtils.setupSystemBarBackgrounds(activity, contentLayout)
59
+
60
+ SystemUiUtils.setNavigationBarBackgroundColor(activity.window, Color.WHITE, true)
61
+
62
+ assertThat(getBackgroundColor(getNavigationBarBackground(contentLayout))).isEqualTo(Color.WHITE)
63
+ assertThat(activity.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR)
64
+ .isEqualTo(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR)
65
+ }
66
+
67
+ @Test
68
+ fun `setNavigationBarBackgroundColor - updates view and icon appearance when edge-to-edge is active`() {
69
+ val activity = Robolectric.setupActivity(AppCompatActivity::class.java)
70
+ val contentLayout = FrameLayout(activity)
71
+ val initialColor = Color.RED
72
+ SystemUiUtils.setNavigationBarBackgroundColor(activity.window, initialColor, false)
73
+ SystemUiUtils.setupSystemBarBackgrounds(activity, contentLayout)
74
+ SystemUiUtils.activateEdgeToEdge()
75
+
76
+ SystemUiUtils.setNavigationBarBackgroundColor(activity.window, Color.WHITE, true)
77
+
78
+ assertThat(getBackgroundColor(getNavigationBarBackground(contentLayout))).isEqualTo(Color.WHITE)
79
+ assertThat(activity.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR)
80
+ .isEqualTo(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR)
81
+ }
82
+
83
+ private fun getNavigationBarBackground(contentLayout: FrameLayout): View {
84
+ return contentLayout.getChildAt(contentLayout.childCount - 1)
85
+ }
86
+
87
+ private fun getBackgroundColor(view: View): Int {
88
+ return (view.background as ColorDrawable).color
89
+ }
90
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "8.8.5-snapshot.2556",
3
+ "version": "8.8.5-snapshot.2563",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,