Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Fix "Syntax Error: cannot use import statement outside a module" issue #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dimensions, Platform, StatusBar } from 'react-native';
const { Dimensions, Platform, StatusBar } = require('react-native');

export function isIphoneX() {
function isIphoneX() {
const dimen = Dimensions.get('window');
return (
Platform.OS === 'ios' &&
Expand All @@ -14,21 +14,23 @@ export function isIphoneX() {
);
}

export function ifIphoneX(iphoneXStyle, regularStyle) {
function ifIphoneX(iphoneXStyle, regularStyle) {
if (isIphoneX()) {
return iphoneXStyle;
}
return regularStyle;
}

export function getStatusBarHeight(safe) {
function getStatusBarHeight(safe) {
return Platform.select({
ios: ifIphoneX(safe ? 44 : 30, 20),
android: StatusBar.currentHeight,
default: 0
});
}

export function getBottomSpace() {
function getBottomSpace() {
return isIphoneX() ? 34 : 0;
}

module.exports = {isIphoneX, ifIphoneX, getStatusBarHeight, getBottomSpace}