(Android) 'statusBarTranslucent' prop not working properly
See original GitHub issuePlatforms
Android (emulator, Galaxy Fold 2)
Versions
- react-native-modal: 12.0.2
- react-native: 0.64.1
- react: 17.0.1
Description
When set ‘statusBarTranslucent’ prop, backdrop doesn’ fill the screen full.
This is the legacy Modal component with statusBarTranslucent = true
And this is React Native Modal with statusBarTranslucent = true
I guess that this happens when device has safe area.
This bug can be fixed with modifying
701th line,
height: this.getDeviceHeight(),
to
height: '100%',
(But I cannot ensure whether or not side-effects exist)
Reproducible Demo
import React from 'react';
import {View, SafeAreaView, StatusBar, Text, StyleSheet} from 'react-native';
import Modal from 'react-native-modal';
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
titleText: {
fontSize: 30,
fontWeight: 'bold',
textAlign: 'center',
marginBottom: 50,
},
dialogStyle: {
width: 200,
height: 100,
backgroundColor: '#FFFFFF',
alignItems: 'center',
justifyContent: 'center'
}
});
const App = () => {
const [visible, setVisible] = React.useState(true);
return (
<>
<StatusBar barStyle="dark-content" backgroundColor="#FFFFFF" />
<SafeAreaView style={styles.container}>
<Text style={styles.titleText}>
Modal Test
</Text>
<Modal
isVisible={visible}
onBackdropPress={() => {
setVisible(false);
}}
statusBarTranslucent
style={{
alignItems: 'center'
}}
>
<View style={styles.dialogStyle}>
<Text>React Native Modal</Text>
<Text>MODAL CONTENT</Text>
</View>
</Modal>
</SafeAreaView>
</>
);
};
export default App;
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
How to hide the statusBar when react-native modal shown?
Use statusBarTranslucent. If your status bar is translucent , you can set statusBarTranslucent to the modal . Added since React Native 0.62
Read more >Modal - React Native
Android. . The statusBarTranslucent prop determines whether your modal should go under the system statusbar.
Read more >react-native-modal - npm
The modal background doesn't animate properly. Are you sure you named the isVisible prop correctly? Make sure it is spelled correctly: isVisible ...
Read more >Configuring the status bar - Expo Documentation
Configuring the status bar while app is loading (Android only). This type of configuration is currently only available on Android. On iOS, it...
Read more >React Native Modal Component - GeeksforGeeks
It is only for android devices. onDismiss: This prop allows passing a function that will be called once the modal has been dismissed....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
customBackdrop
andDimensions.get('screen')
solved this problem.Alternatively, you can just set the deviceHeight prop to ‘100%’. However, it’s type is null. Maybe, this is a bug too?