Closed snicro closed 1 year ago
Hmmm, yes? Why would it be hidden?
Sorry, I was hasty in writing the issue and forgot to mention a critical step: using 'react-navigation' v6 and hiding the header/actionBar via react-navigation's { headerShown: false }
option. Also using the 'Theme.AppCompat.DayNight.NoActionBar' theme in styles.xml. This works fine with react-native-bars up until api level 30. Starting with level 31, hiding the actionBar doesn't work after adding react-native-bars.
I realize now that this is a compatibility issue and probably doesn't belong here. If you want to look into it or want other details let me know, but I'm fine with closing it.
It looks like react-native-screens (used by react-navigation) uses Toolbar (androidx.appcompat.widget.Toolbar) as ActionBar for header config. My Android knowledge is limited, so to workaround this for now I'm using this in my MainActiviy.java:
RNBars.init(MainActivity.this, "dark-content"); // <- initialize with initial bars styles (could be light-content)
RNBootSplash.init(MainActivity.this); // <- initialize the splash screen
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
ActionBar actionBar = getActionBar();
actionBar.hide();
}
Please let me know if you think there's a better way to handle this.
The example uses react-navigation and it doesn't occurs: https://github.com/zoontek/react-native-bars/blob/f0db2151e51650c3ff0b73de7b61eb480fd69cdb/example/App.tsx#L154
Be sure that you properly init all libs:
@Override
protected void onCreate(Bundle savedInstanceState) {
RNBootSplash.init(MainActivity.this); // bootsplash goes BEFORE super call
super.onCreate(null); // called with null (required for react-native-screens)
RNBars.init(this, "dark-content"); // bars goes AFTER super call
}
Yes, indeed, the order of init was the problem. I now feel silly for not catching this difference.
Thank you for taking the time! Awesome job with the library 👏. I suspect most of us felt the need for a library like this at one point or another.
Bug summary
With React Native 0.67.1, Android API level 33 and react-native-bars 1.3.0 the Android ActionBar is visible even though it was hidden via react-navigation and NoActionBar theme before adding react-native-bars.
Library version
1.3.0
Environment info
Steps to reproduce
{ headerShown: false }
option.Reproducible sample code