56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
import React, { useEffect, useState } from 'react';
|
|
import {
|
|
Platform,
|
|
SafeAreaView,
|
|
StyleSheet,
|
|
View,
|
|
NativeModules
|
|
} from 'react-native';
|
|
import { Dimensions } from 'react-native'
|
|
import Theme from '../components/theme.style.js';
|
|
|
|
const { height } = Dimensions.get('window');
|
|
const { StatusBarManager } = NativeModules;
|
|
const statusBarHeight = StatusBarManager.HEIGHT;
|
|
const OS = Platform.OS;
|
|
|
|
const CustomSafeArea = ({customStatusBar, children}) => {
|
|
const [isIphone11,setIsIphone11] = useState(false);
|
|
|
|
useEffect(() =>{
|
|
const majorVersionIOS = parseInt(Platform.Version, 10);
|
|
if (majorVersionIOS <= 15) {
|
|
console.log(height)
|
|
if(height == 896 || height == 844){
|
|
setIsIphone11(true);
|
|
}
|
|
}
|
|
},[])
|
|
|
|
if(customStatusBar && OS === "ios") {
|
|
return (
|
|
<View style={[styles.customSafeArea, {marginTop:isIphone11?-5:0}]}>
|
|
<View style={styles.statusBarHeight} />
|
|
{children}
|
|
</View>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<SafeAreaView style={[styles.customSafeArea,{marginTop:isIphone11?-5:0}]}>
|
|
{children}
|
|
</SafeAreaView>
|
|
);
|
|
};
|
|
|
|
const styles = StyleSheet.create({
|
|
customSafeArea:{
|
|
flex: 1
|
|
},
|
|
statusBarHeight: {
|
|
height: statusBarHeight,
|
|
backgroundColor: Theme.colors.primary,
|
|
width: '100%'
|
|
}
|
|
});
|
|
export default CustomSafeArea; |