-
-
Notifications
You must be signed in to change notification settings - Fork 644
Expand file tree
/
Copy pathgetDefaultHeaderHeight.tsx
More file actions
43 lines (38 loc) · 1.25 KB
/
getDefaultHeaderHeight.tsx
File metadata and controls
43 lines (38 loc) · 1.25 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Platform } from 'react-native';
import { StackPresentationTypes } from '../../types';
type Layout = { width: number; height: number };
const formSheetModalHeight = 56;
export default function getDefaultHeaderHeight(
layout: Layout,
statusBarHeight: number,
stackPresentation: StackPresentationTypes,
isLargeHeader = false,
): number {
// default header heights
let headerHeight = Platform.OS === 'android' ? 56 : 64;
if (Platform.OS === 'ios') {
const isLandscape = layout.width > layout.height;
const isFormSheetModal =
stackPresentation === 'modal' ||
stackPresentation === 'formSheet' ||
stackPresentation === 'pageSheet';
if (isFormSheetModal && !isLandscape) {
// `modal`, `formSheet` and `pageSheet` presentations do not take whole screen, so should not take the inset.
statusBarHeight = 0;
}
if (Platform.isPad || Platform.isTV) {
headerHeight = isFormSheetModal ? formSheetModalHeight : 50;
} else {
if (isLandscape) {
headerHeight = 32;
} else {
if (isFormSheetModal) {
headerHeight = formSheetModalHeight;
} else {
headerHeight = isLargeHeader ? 96 : 44;
}
}
}
}
return headerHeight + statusBarHeight;
}