thebylito / react-native-navigation-bar-color

React Native component to change bottom bar/navigation bar color on Android
MIT License
275 stars 50 forks source link

Looks like setting buttons color does not work #3

Closed ivan133 closed 5 years ago

ivan133 commented 6 years ago

I'm trying to set white natigation bar color with dark buttons:

import changeNavigationBarColor from 'react-native-navigation-bar-color';
...
changeNavigationBarColor('#ffffff', false);

But looks like it does not work - the buttons are always white. screenshot_1527586464

Just in case I've tried to set changeNavigationBarColor('#ffffff', true); Nothing changed.

I've tested it on androids from 6 to 8.

thebylito commented 6 years ago

hi, "#ffffff" is white :)

try changeNavigationBarColor('#000000', true);

ivan133 commented 6 years ago

Sorry I probably didn't explain it right. I want to use the white background for navbar. I thought if I set changeNavigationBarColor('#ffffff', false); the buttons themself should become dark

ivan133 commented 6 years ago

Like this download 4

thebylito commented 6 years ago

Ah yes. This is the result that should be expected. I just did a test and it worked as expected.

When it set to white, did it work as expected? the problem is just the same buttons?

ivan133 commented 6 years ago

Yes, the problem is the button color for me they did not change color no matter what I pass as the second argument.

thebylito commented 6 years ago

Please, let me see your package version in package.json

ivan133 commented 6 years ago

Sure

"dependencies": { "react": "^16.3.0", "react-native": "^0.55.0", "react-native-appsflyer": "1.1.9", "react-native-document-scanner": "^1.4.1", "react-native-gifted-chat": "^0.4.3", "react-native-meteor": "^1.2.0", "react-native-navigation-bar-color": "0.0.6", "react-native-onesignal": "github:BlackTies/react-native-onesignal#7ecedccf20a26fc9ce8a5d9ff44c7fb57bfd2e17", "react-native-smart-splash-screen": "^2.3.5", "react-native-vector-icons": "^4.4.2", "react-native-webview-android": "github:pmogollons/react-native-webview-android#209fa6f6f2a9ccb0d84a0302836c95ece3ebcef3", "react-native-wkwebview-reborn": "^1.16.0" },

thebylito commented 6 years ago

ok, i'm work in this

ivan133 commented 6 years ago

Hi! Any news about this one?

thebylito commented 6 years ago

Unfortunately I could not find a solution. We will have to wait for someone to help us: /

thebylito commented 6 years ago

Take a test: not setting to light when setting the color, maybe solve. changeNavigationBarColor('#000000');

ivan133 commented 6 years ago

Sadly it just crates back background with white buttons

image

notmike101 commented 5 years ago

There you guys go. Pull request #6

thebylito commented 5 years ago

Nice, please test merged version, npm i -s react-native-navigation-bar-color@0.0.8

joe-lz commented 5 years ago
"react-native-navigation-bar-color": "^0.0.8" still not working
notmike101 commented 5 years ago

@jeodiong What version of Android are you testing on and what code are you using to test?

thebylito commented 5 years ago

I'm trying to set white natigation bar color with dark buttons:

import changeNavigationBarColor from 'react-native-navigation-bar-color';
...
changeNavigationBarColor('#ffffff', false);

But looks like it does not work - the buttons are always white. screenshot_1527586464

Just in case I've tried to set changeNavigationBarColor('#ffffff', true); Nothing changed.

I've tested it on androids from 6 to 8.

Tested and working:

image

"react-native-navigation-bar-color": "^0.0.8" changeNavigationBarColor('#ffffff', true);

joe-lz commented 5 years ago

it works when I remove <StatusBar barStyle="dark-content" backgroundColor="white" />

joe-lz commented 5 years ago

but I need StatusBar in dark-content, they can not work the same time now

joe-lz commented 5 years ago

add setTimeout(() => { changeNavigationBarColor('white', true); }, 1000); works fine

notmike101 commented 5 years ago

That might be an issue directly related to your code then, especially if it's working when you delay setting the navigation bar color.

On Tue, Oct 16, 2018 at 6:54 PM Joe notifications@github.com wrote:

add setTimeout(() => { changeNavigationBarColor('white', true); }, 1000); works fine

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/thebylito/react-native-navigation-bar-color/issues/3#issuecomment-430461475, or mute the thread https://github.com/notifications/unsubscribe-auth/AG3WbPGZwmwTlV2ceXkg7ycfvAkKbB7fks5ulo2wgaJpZM4URJr3 .

joe-lz commented 5 years ago

tried with new project, it comes again maybe you can try add changeNavigationBarColor('white', true); <StatusBar barStyle="dark-content" backgroundColor="white" /> the same time, you may facing the same problem

notmike101 commented 5 years ago

@jeodiong Why not just style your StatusBar accordingly instead of expecting something that's not targeting the statusbar to do it? That just confirms that the issue is on your end.

You might wanna open up a separate issue for that since this was resolved.

notmike101 commented 5 years ago

Closing due to inactivity and confirmation of issue being resolved by others.

dtroydev commented 1 year ago

On API 33 if theme is changed (ie. light to dark or dark to light), while the app is open in the background, the navigation bar color scheme isn't being picked up as far as button foreground color is concerned when the app is brought to foreground... (I think this behaviour likely started with API 30+ because that's when SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR got deprecated)

When I update setNavigationBarTheme function as follows it seems to work better (ie. app picks up light <-> dark theme changes as far as button color is concerned without needing to be restarted):

 public void setNavigationBarTheme(Activity activity, Boolean light) {
        if (activity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            Window window = activity.getWindow();
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
                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);
            } 
            else {
                WindowInsetsController insetsController = window.getInsetsController();
                if (light) {
                    insetsController.setSystemBarsAppearance(
                        WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
                        WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
                    );
                }
                else {
                    insetsController.setSystemBarsAppearance(
                        0,
                        WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
                    );
                }
            }
        }
    }

Maybe it's worthwhile updating the package with something similar to the above ?