Skip to content

Instantly share code, notes, and snippets.

@andres-torres-marroquin
Created September 21, 2018 16:29
Show Gist options
  • Save andres-torres-marroquin/dc043d88f3683726662b7c6bcbd0d171 to your computer and use it in GitHub Desktop.
Save andres-torres-marroquin/dc043d88f3683726662b7c6bcbd0d171 to your computer and use it in GitHub Desktop.
{
Platform
} = require 'react-native'
getBottomTabsHeight = ->
if Platform.OS is 'android'
return 56
if Platform.OS is 'ios'
return if isIphoneX() then 84 else 50
module.exports = getBottomTabsHeight
# Based on https://github.com/ptelad/react-native-iphone-x-helper/blob/master/index.js
{
Dimensions
Platform
} = require 'react-native'
isIphoneX = ->
if Platform.OS isnt 'ios'
return no
if Platform.isPad or Platform.isTVOS
return no
dimensions = Dimensions.get 'window'
if (dimensions.height is 812 or dimensions.width is 812)
# iPhone X, XS
return yes
if (dimensions.height is 896 or dimensions.width is 896)
# iPhone XR, XS Max
return yes
return no
module.exports = isIphoneX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment