-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: android navigation bar color is not displaying correctly (#5928)
Co-authored-by: Diego Mello <[email protected]>
- Loading branch information
1 parent
acc0301
commit 6e789c6
Showing
9 changed files
with
85 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
diff --git a/node_modules/react-native-navigation-bar-color/android/src/main/java/com/thebylito/navigationbarcolor/NavigationBarColorModule.java b/node_modules/react-native-navigation-bar-color/android/src/main/java/com/thebylito/navigationbarcolor/NavigationBarColorModule.java | ||
index b3edac7..23174bd 100644 | ||
--- a/node_modules/react-native-navigation-bar-color/android/src/main/java/com/thebylito/navigationbarcolor/NavigationBarColorModule.java | ||
+++ b/node_modules/react-native-navigation-bar-color/android/src/main/java/com/thebylito/navigationbarcolor/NavigationBarColorModule.java | ||
@@ -11,6 +11,7 @@ import android.app.Activity; | ||
import android.view.View; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
+import android.view.WindowInsetsController; | ||
import androidx.annotation.UiThread; | ||
import com.facebook.react.bridge.Arguments; | ||
import com.facebook.react.bridge.Promise; | ||
@@ -44,15 +45,28 @@ public class NavigationBarColorModule extends ReactContextBaseJavaModule { | ||
} | ||
|
||
public void setNavigationBarTheme(Activity activity, Boolean light) { | ||
- if (activity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
- Window window = activity.getWindow(); | ||
- int flags = window.getDecorView().getSystemUiVisibility(); | ||
- if (light) { | ||
- flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; | ||
- } else { | ||
- flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; | ||
+ if (activity != null) { | ||
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { | ||
+ Window window = activity.getWindow(); | ||
+ int flags = window.getDecorView().getSystemUiVisibility(); | ||
+ if (light) { | ||
+ flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; | ||
+ } else { | ||
+ flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; | ||
+ } | ||
+ window.getDecorView().setSystemUiVisibility(flags); | ||
+ } | ||
+ | ||
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
+ int flag; | ||
+ if (light) { | ||
+ flag = WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; | ||
+ } else { | ||
+ flag = 0; | ||
+ } | ||
+ final WindowInsetsController insetsController = activity.getWindow().getInsetsController(); | ||
+ insetsController.setSystemBarsAppearance(flag, WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS); | ||
} | ||
- window.getDecorView().setSystemUiVisibility(flags); | ||
} | ||
} | ||
|
||
diff --git a/node_modules/react-native-navigation-bar-color/src/index.js b/node_modules/react-native-navigation-bar-color/src/index.js | ||
index eeab32f..d4d8a2c 100644 | ||
--- a/node_modules/react-native-navigation-bar-color/src/index.js | ||
+++ b/node_modules/react-native-navigation-bar-color/src/index.js | ||
@@ -9,7 +9,7 @@ const changeNavigationBarColor = ( | ||
) => { | ||
if (Platform.OS === 'android') { | ||
const LightNav = light ? true : false; | ||
- NavigationBarColor.changeNavigationBarColor(color, LightNav, animated); | ||
+ return NavigationBarColor.changeNavigationBarColor(color, LightNav, animated); | ||
} | ||
}; | ||
const hideNavigationBar = () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11999,10 +11999,10 @@ [email protected]: | |
prop-types "^15.6.2" | ||
react-native-animatable "1.3.3" | ||
|
||
[email protected].1: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/react-native-navigation-bar-color/-/react-native-navigation-bar-color-2.0.1.tgz#ee2be25cc37105f7da355717b0a9a32c9c059ae6" | ||
integrity sha512-1kE/oxWt+HYjRxdZdvke9tJ365xaee5n3+euOQA1En8zQuSbOxiE4SYEGM7TeaWnmLJ0l37mRnPHaB2H4mGh0A== | ||
react-native-navigation-bar-color@^2.0.2: | ||
version "2.0.2" | ||
resolved "https://registry.yarnpkg.com/react-native-navigation-bar-color/-/react-native-navigation-bar-color-2.0.2.tgz#2e14ca79a656d81d5b4b7433ae43966ef5206444" | ||
integrity sha512-ZmpLWRocyme1au11e5ZuecMS/UCi57nlzgnioi03Q6ERMbeUOqqbWgNBaNB7SsCeqBV6fZPjo3+A64zEIpzw4w== | ||
|
||
[email protected]: | ||
version "5.1.0" | ||
|
@@ -12080,10 +12080,10 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.2.0.tgz#06113c6b208f982d68ab5c3cebd199ca93db6941" | ||
integrity sha512-k2Nty4PwSnrg9HwrYeeE+EYqViYJoOFwEy9LxL5RIRfoqxAq/uQXNGwpUg2/u4gnKpBbEPa9eRh15KKMe/VHkA== | ||
|
||
react-native-screens@3.29.0: | ||
version "3.29.0" | ||
resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.29.0.tgz#1dee0326defbc1d4ef4e68287abb32a8e6b76b29" | ||
integrity sha512-yB1GoAMamFAcYf4ku94uBPn0/ani9QG7NdI98beJ5cet2YFESYYzuEIuU+kt+CNRcO8qqKeugxlfgAa3HyTqlg== | ||
react-native-screens@3.31.1: | ||
version "3.31.1" | ||
resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.31.1.tgz#909a890f669e32b0fb1b1410278b71ad2f8238f6" | ||
integrity sha512-8fRW362pfZ9y4rS8KY5P3DFScrmwo/vu1RrRMMx0PNHbeC9TLq0Kw1ubD83591yz64gLNHFLTVkTJmWeWCXKtQ== | ||
dependencies: | ||
react-freeze "^1.0.0" | ||
warn-once "^0.1.0" | ||
|