From bbd873790e49fd96f1fe168cb1743b49c1ea78cf Mon Sep 17 00:00:00 2001 From: sarious Date: Wed, 1 Nov 2023 02:22:31 +0400 Subject: [PATCH] use aliases. get rid of useInitialWindowDimensions native file --- .../index.native.js | 58 ------------------- src/pages/EditRequestAmountPage.js | 2 +- src/pages/iou/MoneyRequestSelectorPage.js | 5 +- 3 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 src/hooks/useInitialWindowDimensions/index.native.js diff --git a/src/hooks/useInitialWindowDimensions/index.native.js b/src/hooks/useInitialWindowDimensions/index.native.js deleted file mode 100644 index d14ed322150f..000000000000 --- a/src/hooks/useInitialWindowDimensions/index.native.js +++ /dev/null @@ -1,58 +0,0 @@ -// eslint-disable-next-line no-restricted-imports -import {useState, useEffect} from 'react'; -import {Dimensions} from 'react-native'; -import {initialWindowMetrics} from "react-native-safe-area-context"; - -/** - * A convenience hook that provides initial size (width and height). - * An initial height allows to know the real height of window, - * while the standard useWindowDimensions hook return the height minus Virtual keyboard height - */ -export default function () { - const [dimensions, setDimensions] = useState(() => { - const window = Dimensions.get('window'); - const screen = Dimensions.get('screen'); - - return { - screenHeight: screen.height, - screenWidth: screen.width, - initialHeight: window.height, - initialWidth: window.width, - }; - }); - - useEffect(() => { - const onDimensionChange = (newDimensions) => { - const {window, screen} = newDimensions; - - setDimensions((oldState) => { - if (screen.width !== oldState.screenWidth || screen.height !== oldState.screenHeight || window.height > oldState.initialHeight) { - return { - initialHeight: window.height, - initialWidth: window.width, - screenHeight: screen.height, - screenWidth: screen.width, - }; - } - - return oldState; - }); - }; - - const dimensionsEventListener = Dimensions.addEventListener('change', onDimensionChange); - - return () => { - if (!dimensionsEventListener) { - return; - } - dimensionsEventListener.remove(); - }; - }, []); - - const bottomInset = initialWindowMetrics?.insets?.bottom ?? 0; - - return { - initialWidth: dimensions.initialWidth, - initialHeight: dimensions.initialHeight - bottomInset, - }; -} diff --git a/src/pages/EditRequestAmountPage.js b/src/pages/EditRequestAmountPage.js index f0e878ccbfba..5fb26e961fad 100644 --- a/src/pages/EditRequestAmountPage.js +++ b/src/pages/EditRequestAmountPage.js @@ -4,9 +4,9 @@ import React, {useCallback, useRef} from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import useLocalize from '@hooks/useLocalize'; +import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import CONST from '@src/CONST'; import MoneyRequestAmountForm from './iou/steps/MoneyRequestAmountForm'; -import * as DeviceCapabilities from '../libs/DeviceCapabilities'; const propTypes = { /** Transaction default amount value */ diff --git a/src/pages/iou/MoneyRequestSelectorPage.js b/src/pages/iou/MoneyRequestSelectorPage.js index 7b7992d28f4e..125a83cd0fd3 100644 --- a/src/pages/iou/MoneyRequestSelectorPage.js +++ b/src/pages/iou/MoneyRequestSelectorPage.js @@ -12,6 +12,7 @@ import TabSelector from '@components/TabSelector/TabSelector'; import useLocalize from '@hooks/useLocalize'; import usePrevious from '@hooks/usePrevious'; import compose from '@libs/compose'; +import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import * as IOUUtils from '@libs/IOUUtils'; import Navigation from '@libs/Navigation/Navigation'; import OnyxTabNavigator, {TopTab} from '@libs/Navigation/OnyxTabNavigator'; @@ -25,10 +26,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import NewDistanceRequestPage from './NewDistanceRequestPage'; import ReceiptSelector from './ReceiptSelector'; import NewRequestAmountPage from './steps/NewRequestAmountPage'; -import reportPropTypes from '@pages/reportPropTypes'; -import * as ReportUtils from '@libs/ReportUtils'; -import usePrevious from '@hooks/usePrevious'; -import * as DeviceCapabilities from '@libs/DeviceCapabilities'; const propTypes = { /** React Navigation route */