aboutsummaryrefslogtreecommitdiff
path: root/src/utils/layouts.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/layouts.ts')
-rw-r--r--src/utils/layouts.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utils/layouts.ts b/src/utils/layouts.ts
new file mode 100644
index 00000000..fbe32189
--- /dev/null
+++ b/src/utils/layouts.ts
@@ -0,0 +1,31 @@
+import {Platform, StatusBar} from 'react-native';
+import {Dimensions} from 'react-native';
+
+export const {width: SCREEN_WIDTH, height: SCREEN_HEIGHT} = Dimensions.get(
+ 'window',
+);
+
+/**
+ * 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;