aboutsummaryrefslogtreecommitdiff
path: root/src/utils/statusBarHeight.ts
blob: dd4a67acfa4b7440a65ddfea508c20ffd9174692 (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
import {useHeaderHeight} from '@react-navigation/stack';
import {Platform, StatusBar} from 'react-native';
import {AVATAR_DIM} from '../constants';
import {SCREEN_WIDTH, SCREEN_HEIGHT} from './screenDimensions';

const X_WIDTH = 375;
const X_HEIGHT = 812;
const XSMAX_WIDTH = 414;
const XSMAX_HEIGHT = 896;

const isIPhoneX = () =>
  Platform.OS === 'ios' && !Platform.isPad && !Platform.isTVOS
    ? (SCREEN_WIDTH === X_WIDTH && SCREEN_HEIGHT === X_HEIGHT) ||
      (SCREEN_WIDTH === XSMAX_WIDTH && SCREEN_HEIGHT === XSMAX_HEIGHT)
    : false;

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

export const headerBarHeightWithImage = () => {
  return Math.max(useHeaderHeight() + 14, AVATAR_DIM + StatusBarHeight + 14);
};