unioil-loyalty-rn-app/app/components/safeArea.component.js

35 lines
860 B
JavaScript

import React, { useEffect, useState } from 'react';
import { StyleSheet, SafeAreaView,Platform} from 'react-native';
import { Dimensions } from 'react-native'
const { height } = Dimensions.get('window');
const CustomSafeArea = ({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);
}
}
},[])
return (
<SafeAreaView style={[styles.customSafeArea,{marginTop:isIphone11?-5:0}]}>
{children}
</SafeAreaView>
);
};
const styles = StyleSheet.create({
customSafeArea:{
flex: 1
}
});
export default CustomSafeArea;