Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency with navigationBarColor Transparency on react-native-screens versions >= 3.30.0" #2122

Open
yunarch opened this issue May 8, 2024 · 5 comments · May be fixed by #2152
Open
Assignees
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android

Comments

@yunarch
Copy link

yunarch commented May 8, 2024

Description

Before version 3.30.0, when the navigationBarColor was set to transparent on a Stack navigator, the navigation bar would preserve transparency, adopting the color defined on SafeAreaView. However, in version 3.30.0 and onwards, this behavior has changed: the navigation bar no longer maintains transparency but instead defaults to a white color (or black if navigationBarColor is not explicitly defined).

Steps to reproduce

Setting a stack navigator with navigationBarColor set as transparent:

const Stack = createNativeStackNavigator();

....

<Stack.Navigator
      screenOptions={{
        ...
        navigationBarColor: "transparent",
      }}
    >
...
</Stack.Navigator>

Snack or a link to a repository

https://github.com/software-mansion/react-native-screens

Screens version

>= 3.30.0

React Native version

0.74.1

Platforms

Android

JavaScript runtime

None

Workflow

Expo managed workflow

Architecture

None

Build type

None

Device

Android emulator

Device model

Pixel_3a_API_34

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Missing repro This issue need minimum repro scenario labels May 8, 2024
Copy link

github-actions bot commented May 8, 2024

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@klethonio
Copy link

klethonio commented May 10, 2024

I'm facing the same problem, after expo upgrade, the navigation bar is not longer transparent using that approach.

A way you can turn around that is to use npx expo install expo-navigation-bar, check expo docs about it, but to make this works now you have to set up this:

  import * as NavigationBar from 'expo-navigation-bar';

  // App.js
  NavigationBar.setPositionAsync('absolute');
  NavigationBar.setBackgroundColorAsync('#ffffff00');

Although I would prefer to do not have absolute position there, because I have to change all my screens that doesn't take that into account.

@yunarch
Copy link
Author

yunarch commented May 10, 2024

@klethonio NavigationBar.setPositionAsync('absolute'); is not the same as setting navigationBarHidden: true on the stack navigator?

I didn't test it but by reading the documentation it looks like maybe the same result?

On my case i do not want to use navigationBarHidden: true as it floats the navigation bar above the content, and our designs are to shrink the screen to inline the navigation bar.

@yunarch
Copy link
Author

yunarch commented May 10, 2024

@klethonio I just test your solution and works great as a workaround, i thought it was the same result as using navigationBarHidden but is not.

I as well would prefer to not have absolute position there, but the solution works nice.

One thing i detected is that ios is not affected, setting navigationBarColor: "transparent" works just fine, also setting setPositionAsync only works for android:

// App.tsx
if (Platform.OS === "android") {
  NavigationBar.setPositionAsync("absolute");
}

There is no need for setting transparent color with setBackgroundColorAsync as by just setting the navigationBar absolute correctly gets the transparent color defined on the navigator.

@klethonio
Copy link

Yeah, navigationBarHidden: true will, hide the navigation bar and the user has to swipe from bottom to top to show it again. The absolute position will basically put the navigation bar above your app and if it's transparent, there you have it.

I don't know what was the structure before, because it seemed to work like that but dynamically, always taking into account the bar height. Now it looks like the navigation bar being set as transparent, without absolute, its working, but below we have a black/white background, or it's not that, anyway, I'm lost. That's out of my league at the moment.

For example, I have a FAB and previously the bottom padding was related to the top of the navigation bar, and the bar was transparent and the content of the app was behind it, it was perfect. After the update the bar was opaque and after applying absolute my FAB has the margin bottom related to the bottom of the screen, it's taking the space of the bar.

Summing up... I think this should just work as before!

By the way, thank you for your thoughts.

@alduzy alduzy self-assigned this May 20, 2024
@alduzy alduzy linked a pull request May 21, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants