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

Commit

Permalink
Added support for notch of iphone xr/xs/xsmax
Browse files Browse the repository at this point in the history
  • Loading branch information
gersomvg committed Nov 1, 2018
1 parent d1512dd commit d5c79b9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/utils/getSafeHeight.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import RN from 'react-native';
import {isIphoneX} from './isIphoneX';
import { isIphoneWithNotch } from './isIphoneWithNotch';

const getSafeTopHeight = ({skipAndroid = true} = {}) => {
const getSafeTopHeight = ({ skipAndroid = true } = {}) => {
if (RN.Platform.OS === 'ios') {
return isIphoneX() ? 44 : 20;
return isIphoneWithNotch() ? 44 : 20;
}

if (skipAndroid) {
Expand All @@ -14,7 +14,7 @@ const getSafeTopHeight = ({skipAndroid = true} = {}) => {
};

const getSafeBottomHeight = () => {
return isIphoneX() ? 16 : 0;
return isIphoneWithNotch() ? 16 : 0;
};

export {getSafeTopHeight, getSafeBottomHeight};
export { getSafeTopHeight, getSafeBottomHeight };
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './getSafeHeight';
export * from './isIphoneX';
export * from './isIphoneWithNotch';
export * from './logger';
export * from './makeCancelable';
export * from './fetcher';
Expand Down
16 changes: 16 additions & 0 deletions src/utils/isIphoneWithNotch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Dimensions, Platform } from 'react-native';

const isIphoneWithNotch = () => {
const dimensions = Dimensions.get('window');
return (
Platform.OS === 'ios' &&
!Platform.isPad &&
!Platform.isTVOS &&
(dimensions.height === 812 ||
dimensions.width === 812 ||
dimensions.height === 896 ||
dimensions.width === 896)
);
};

export { isIphoneWithNotch };
13 changes: 0 additions & 13 deletions src/utils/isIphoneX.js

This file was deleted.

0 comments on commit d5c79b9

Please sign in to comment.