react-native-surveys
Version:
Build your own forms, surveys and polls for your React Native apps.
25 lines (21 loc) • 757 B
JavaScript
import { Dimensions, Platform, StatusBar } from "react-native";
const X_WIDTH = 375;
const X_HEIGHT = 812;
const XSMAX_WIDTH = 414;
const XSMAX_HEIGHT = 896;
const { height: W_HEIGHT, width: W_WIDTH } = Dimensions.get("window");
let isIPhoneX = false;
if (Platform.OS === "ios" && !Platform.isPad && !Platform.isTVOS) {
isIPhoneX =
(W_WIDTH === X_WIDTH && W_HEIGHT === X_HEIGHT) ||
(W_WIDTH === XSMAX_WIDTH && W_HEIGHT === XSMAX_HEIGHT);
}
const getExpoRoot = () => global.Expo || global.__expo || global.__exponent;
export const isExpo = () => getExpoRoot() !== undefined;
export function getStatusBarHeight() {
return Platform.select({
ios: isIPhoneX ? 44 : 20,
android: isExpo ? StatusBar.currentHeight : 0,
default: 0
});
}