From e1e67aef6c3ddbb534a8f094b73a1d1471498a02 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Tue, 29 Aug 2023 12:03:30 +0200 Subject: [PATCH] [TS migration] Migrate 'getWindowHeightAdjustment' lib to TypeScript --- src/libs/getWindowHeightAdjustment/index.android.js | 4 ---- src/libs/getWindowHeightAdjustment/index.android.ts | 6 ++++++ src/libs/getWindowHeightAdjustment/index.js | 4 ---- src/libs/getWindowHeightAdjustment/index.ts | 6 ++++++ src/libs/getWindowHeightAdjustment/types.ts | 5 +++++ 5 files changed, 17 insertions(+), 8 deletions(-) delete mode 100644 src/libs/getWindowHeightAdjustment/index.android.js create mode 100644 src/libs/getWindowHeightAdjustment/index.android.ts delete mode 100644 src/libs/getWindowHeightAdjustment/index.js create mode 100644 src/libs/getWindowHeightAdjustment/index.ts create mode 100644 src/libs/getWindowHeightAdjustment/types.ts diff --git a/src/libs/getWindowHeightAdjustment/index.android.js b/src/libs/getWindowHeightAdjustment/index.android.js deleted file mode 100644 index b360467d31c1..000000000000 --- a/src/libs/getWindowHeightAdjustment/index.android.js +++ /dev/null @@ -1,4 +0,0 @@ -// On Android the window height does not include the status bar height, so we need to add it manually. -export default function getWindowHeightAdjustment(insets) { - return insets.top; -} diff --git a/src/libs/getWindowHeightAdjustment/index.android.ts b/src/libs/getWindowHeightAdjustment/index.android.ts new file mode 100644 index 000000000000..1a06e663d4e3 --- /dev/null +++ b/src/libs/getWindowHeightAdjustment/index.android.ts @@ -0,0 +1,6 @@ +import GetWindowHeightAdjustment from './types'; + +// On Android the window height does not include the status bar height, so we need to add it manually. +const getWindowHeightAdjustment: GetWindowHeightAdjustment = (insets) => insets?.top ?? 0; + +export default getWindowHeightAdjustment; diff --git a/src/libs/getWindowHeightAdjustment/index.js b/src/libs/getWindowHeightAdjustment/index.js deleted file mode 100644 index 9ddd1e7cefee..000000000000 --- a/src/libs/getWindowHeightAdjustment/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// Some platforms need to adjust the window height. -export default function getWindowHeightAdjustment() { - return 0; -} diff --git a/src/libs/getWindowHeightAdjustment/index.ts b/src/libs/getWindowHeightAdjustment/index.ts new file mode 100644 index 000000000000..9a768d00cd4d --- /dev/null +++ b/src/libs/getWindowHeightAdjustment/index.ts @@ -0,0 +1,6 @@ +import GetWindowHeightAdjustment from './types'; + +// Some platforms need to adjust the window height. +const getWindowHeightAdjustment: GetWindowHeightAdjustment = () => 0; + +export default getWindowHeightAdjustment; diff --git a/src/libs/getWindowHeightAdjustment/types.ts b/src/libs/getWindowHeightAdjustment/types.ts new file mode 100644 index 000000000000..ddb6723f6320 --- /dev/null +++ b/src/libs/getWindowHeightAdjustment/types.ts @@ -0,0 +1,5 @@ +import {EdgeInsets} from 'react-native-safe-area-context'; + +type GetWindowHeightAdjustment = (insets: EdgeInsets | null) => number; + +export default GetWindowHeightAdjustment;