thebylito / react-native-navigation-bar-color

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

3-char hex color crash the app #27

Closed tomsotte closed 4 years ago

tomsotte commented 4 years ago

When I set the navbar color via 3-char hex color, like #fff, the app crashed with the error below (from logcat):

12-04 17:47:11.875 21186 21186 E AndroidRuntime: java.lang.IllegalArgumentException: Unknown color
12-04 17:47:11.875 21186 21186 E AndroidRuntime:    at android.graphics.Color.parseColor(Color.java:1391)
12-04 17:47:11.875 21186 21186 E AndroidRuntime:    at com.thebylito.navigationbarcolor.NavigationBarColorModule$1.run(NavigationBarColorModule.java:92)

It appears Android Color.parseColor does not support that kind of format for colors. https://developer.android.com/reference/android/graphics/Color#parseColor(java.lang.String)

notmike101 commented 4 years ago

I'd suggest using 6-char hex colors then. Is there any reason you MUST use 3-char?

tomsotte commented 4 years ago

Not in particular, but react native lets you use that 3-char format so I tried to use the same color variable I use everywhere else in the app and I couldn't figure out why it didn't work, my bad. A simple note on the README stating that 3-char colors aren't supported might be enough.

alainib commented 1 year ago

i got this issus in 2023 and spend half a day to figure out why, a little tips in readme as @tomsotte says would be nice.

thanks for your work