feat: add support for isNavigationBarTranslucentAndroid#6431
Merged
maciekstosio merged 5 commits intomainfrom Sep 18, 2024
Merged
Conversation
Contributor
|
I have a patch in my app to do this (but without the config parameter part). I think you might also need to adjust the value here for when using the keyboard height. |
Contributor
Author
|
@janicduplessis Nice catch, thanks! Fixed in 80531ea. |
|
Waiting on this for my project, might use this branch for now, good job! |
r0h0gg6
pushed a commit
to r0h0gg6/react-native-reanimated
that referenced
this pull request
Jul 28, 2025
…sion#6431) ## Summary Resolves software-mansion#6043. For StatusBar we have a flag that removes top padding when we want to render RN stuff "under" StatusBar. A similar problem was raised in software-mansion#6043, but for NavigationBar, so I added another flag `isNavigationBarTranslucentAndroid` that removes bottom padding as well. Currently, I see no way to make it automatic. I tried one approach to remove the flags in software-mansion#5889, but it doesn't seem to be the performant solution. ## Preview |Before|After without flag|After with flag| |-|-|-| |<img width="602" alt="before" src="https://github.com/user-attachments/assets/0032efbe-342a-4e06-81ee-f7351bb032f7">|<img width="602" alt="after-without-flag" src="https://github.com/user-attachments/assets/6f259329-9bf4-4bbb-8ce4-32d671e65a5a">|<img width="602" alt="after-with-flag" src="https://github.com/user-attachments/assets/81c43052-f3b3-4a3b-a9cb-bd974e851c43">| ## Test plan Testing is a bit tricky, because an example from the issue uses a navigation bar package from Expo, which requires Expo and our example app doesn't have Expo. What I did: <details> <summary>Steps</summary> ```bash # clone reanimated from current branch git clone https://github.com/software-mansion/react-native-reanimated.git # checkout current branch git checkout @maciekstosio/Add-support-for-isNavigationBarTranslucentAndroid # install yarn && yarn build # build npm package cd packages/react-native-reanimated ./createNPMPackage.sh --fresh # next, create simple expo project npx create-expo-stack # install library for navigation bar npx expo install expo-navigation-bar # install reanimated npx expo install react-native-reanimated # replace in package.json path to locally-build package i.e.: "react-native-reanimated": "file:react-native-reanimated.tgz" # yarn install # npx expo run:android ``` </details> <details> <summary>App.tsx to test</summary> ```jsx import * as NavigationBar from 'expo-navigation-bar'; import React, { useEffect } from 'react'; import Animated, { useAnimatedKeyboard, useAnimatedStyle, } from 'react-native-reanimated'; import { Platform, StatusBar, StyleSheet, TextInput, View, Text, Button, } from 'react-native'; export default function EmptyExample() { const keyboard = useAnimatedKeyboard({ isNavigationBarTranslucentAndroid: true, }); const animatedStyles = useAnimatedStyle(() => ({ transform: [{ translateY: -keyboard.height.value }], })); useEffect(() => { StatusBar.setBarStyle('dark-content'); NavigationBar.setBackgroundColorAsync('transparent'); }, []); return ( <Animated.View style={[ styles.container, animatedStyles, { justifyContent: 'flex-end', borderWidth: 5, borderColor: '#ff0' }, ]}> <View style={[ styles.center, { height: 200, backgroundColor: '#f0f', borderWidth: 5, borderColor: '#0ff', }, ]}> <Text>{`Android ${Platform.constants['Release']}`}</Text> <TextInput placeholder="Test" /> </View> </Animated.View> ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'rgba(255,0,255,0.2)' }, center: { justifyContent: 'center', alignItems: 'center' }, }); ``` </details>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #6043. For StatusBar we have a flag that removes top padding when we want to render RN stuff "under" StatusBar. A similar problem was raised in #6043, but for NavigationBar, so I added another flag
isNavigationBarTranslucentAndroidthat removes bottom padding as well. Currently, I see no way to make it automatic. I tried one approach to remove the flags in #5889, but it doesn't seem to be the performant solution.Preview
Test plan
Testing is a bit tricky, because an example from the issue uses a navigation bar package from Expo, which requires Expo and our example app doesn't have Expo.
What I did:
Steps
App.tsx to test