aboutsummaryrefslogtreecommitdiff
path: root/src/utils/statusBarHeight.ts
blob: c5509376239475d8f072048e3260a78de44aa10c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {Platform, StatusBar} from 'react-native';
import {SCREEN_HEIGHT, SCREEN_WIDTH} from './screenDimensions';

/**
 * Working as of Q1 2021, latest iPhone is 12
 * iPhone 8/SE has a logical screen ratio of about 1.77
 * Rest has a logical screen ratio of about 2.16
 */
export const isIPhoneX = () =>
  Platform.OS === 'ios' && !Platform.isPad && !Platform.isTVOS
    ? SCREEN_HEIGHT / SCREEN_WIDTH > 2
    : false;

// Taken from: https://github.com/react-navigation/react-navigation/issues/283
export const HeaderHeight = Platform.select({
  ios: 44,
  android: 56,
  default: 64,
});

export const StatusBarHeight = Platform.select({
  ios: isIPhoneX() ? 44 : 20,
  android: StatusBar.currentHeight,
  default: 0,
});

export const AvatarHeaderHeight = (HeaderHeight + StatusBarHeight) * 1.3;