1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/ReactNativeClient/lib/components/SafeAreaView.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

import { View, Platform, SafeAreaView, StyleSheet /* , StatusBar */ } from 'react-native';
const React = require('react');
// import DeviceInfo from 'react-native-device-info';
2020-02-09 19:42:19 +02:00
// Untested! This should check if the device has a notch and, if it does, apply
// an extra padding on top of the screen.
const styles = StyleSheet.create({
AndroidSafeArea: {
// Disabled for now because it seems that even when there's a notch the system status bar
// covers it, and thus we should add our own gap.
// Can only test on emulator though
// Fixes: https://github.com/laurent22/joplin/issues/2694
// paddingTop: Platform.OS === 'android' && DeviceInfo.hasNotch() ? StatusBar.currentHeight : 0,
paddingTop: 0,
2020-02-09 19:42:19 +02:00
},
});
2020-02-09 17:48:09 +02:00
function JoplinSafeAreaView(props) {
if (Platform.OS === 'ios') {
return <SafeAreaView {...props}>{props.children}</SafeAreaView>;
} else {
2020-02-09 19:42:19 +02:00
const viewProps = Object.assign({}, props);
const style = [];
if (viewProps.style) {
style.push(viewProps.style);
delete viewProps.style;
}
style.push(styles.AndroidSafeArea);
return <View style={style} {...viewProps}>{props.children}</View>;
2020-02-09 17:48:09 +02:00
}
}
module.exports = JoplinSafeAreaView;