From dfcf03ea2f9495f568dbe91ab0af43903917c16f Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Fri, 17 Nov 2023 10:28:45 +0100 Subject: [PATCH] remove KeyboardSpacer --- .../KeyboardSpacer/BaseKeyboardSpacer.js | 56 ------------------- .../BaseKeyboardSpacerPropTypes.js | 24 -------- .../KeyboardSpacer/index.android.js | 23 -------- src/components/KeyboardSpacer/index.ios.js | 24 -------- src/components/KeyboardSpacer/index.js | 11 ---- 5 files changed, 138 deletions(-) delete mode 100644 src/components/KeyboardSpacer/BaseKeyboardSpacer.js delete mode 100644 src/components/KeyboardSpacer/BaseKeyboardSpacerPropTypes.js delete mode 100644 src/components/KeyboardSpacer/index.android.js delete mode 100644 src/components/KeyboardSpacer/index.ios.js delete mode 100644 src/components/KeyboardSpacer/index.js diff --git a/src/components/KeyboardSpacer/BaseKeyboardSpacer.js b/src/components/KeyboardSpacer/BaseKeyboardSpacer.js deleted file mode 100644 index adab3e2ea66d..000000000000 --- a/src/components/KeyboardSpacer/BaseKeyboardSpacer.js +++ /dev/null @@ -1,56 +0,0 @@ -import React, {useCallback, useEffect, useState} from 'react'; -import {Dimensions, Keyboard, View} from 'react-native'; -import * as StyleUtils from '@styles/StyleUtils'; -import {defaultProps, propTypes} from './BaseKeyboardSpacerPropTypes'; - -function BaseKeyboardSpacer(props) { - const [keyboardSpace, setKeyboardSpace] = useState(0); - - /** - * Update the height of Keyboard View. - * - * @param {Object} [event] - A Keyboard Event. - */ - const updateKeyboardSpace = useCallback( - (event) => { - if (!event.endCoordinates) { - return; - } - - const screenHeight = Dimensions.get('window').height; - const space = screenHeight - event.endCoordinates.screenY + props.topSpacing; - setKeyboardSpace(space); - props.onToggle(true, space); - }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [], - ); - - /** - * Reset the height of Keyboard View. - * - * @param {Object} [event] - A Keyboard Event. - */ - const resetKeyboardSpace = useCallback(() => { - setKeyboardSpace(0); - props.onToggle(false, 0); - }, [setKeyboardSpace, props]); - - useEffect(() => { - const updateListener = props.keyboardShowMethod; - const resetListener = props.keyboardHideMethod; - const keyboardListeners = [Keyboard.addListener(updateListener, updateKeyboardSpace), Keyboard.addListener(resetListener, resetKeyboardSpace)]; - - return () => { - keyboardListeners.forEach((listener) => listener.remove()); - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - return ; -} - -BaseKeyboardSpacer.defaultProps = defaultProps; -BaseKeyboardSpacer.propTypes = propTypes; - -export default BaseKeyboardSpacer; diff --git a/src/components/KeyboardSpacer/BaseKeyboardSpacerPropTypes.js b/src/components/KeyboardSpacer/BaseKeyboardSpacerPropTypes.js deleted file mode 100644 index 23154da79e53..000000000000 --- a/src/components/KeyboardSpacer/BaseKeyboardSpacerPropTypes.js +++ /dev/null @@ -1,24 +0,0 @@ -import PropTypes from 'prop-types'; - -const propTypes = { - /** Top Spacing is used when there is a requirement of additional height to view. */ - topSpacing: PropTypes.number, - - /** Callback to update the value of keyboard status along with keyboard height + top spacing. */ - onToggle: PropTypes.func, - - /** Platform specific keyboard event to show keyboard https://reactnative.dev/docs/keyboard#addlistener */ - /** Pass keyboardShow event name as a param, since iOS and android both have different event names show keyboard. */ - keyboardShowMethod: PropTypes.string.isRequired, - - /** Platform specific keyboard event to hide keyboard https://reactnative.dev/docs/keyboard#addlistener */ - /** Pass keyboardHide event name as a param, since iOS and android both have different event names show keyboard. */ - keyboardHideMethod: PropTypes.string.isRequired, -}; - -const defaultProps = { - topSpacing: 0, - onToggle: () => null, -}; - -export {propTypes, defaultProps}; diff --git a/src/components/KeyboardSpacer/index.android.js b/src/components/KeyboardSpacer/index.android.js deleted file mode 100644 index d7c57f7d73c2..000000000000 --- a/src/components/KeyboardSpacer/index.android.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * On Android the keyboard covers the input fields on the bottom of the view. This component moves the - * view up with the keyboard allowing the user to see what they are typing. - */ -import React from 'react'; -import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions'; -import StatusBar from '@libs/StatusBar'; -import BaseKeyboardSpacer from './BaseKeyboardSpacer'; - -function KeyboardSpacer() { - return ( - - ); -} - -KeyboardSpacer.propTypes = windowDimensionsPropTypes; -KeyboardSpacer.displayName = 'KeyboardSpacer'; - -export default withWindowDimensions(KeyboardSpacer); diff --git a/src/components/KeyboardSpacer/index.ios.js b/src/components/KeyboardSpacer/index.ios.js deleted file mode 100644 index 612ef75c290f..000000000000 --- a/src/components/KeyboardSpacer/index.ios.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * On iOS the keyboard covers the input fields on the bottom of the view. This component moves the view up with the - * keyboard allowing the user to see what they are typing. - */ -import React from 'react'; -import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions'; -import * as StyleUtils from '@styles/StyleUtils'; -import CONST from '@src/CONST'; -import BaseKeyboardSpacer from './BaseKeyboardSpacer'; - -function KeyboardSpacer(props) { - return ( - - ); -} - -KeyboardSpacer.propTypes = windowDimensionsPropTypes; -KeyboardSpacer.displayName = 'KeyboardSpacer'; - -export default withWindowDimensions(KeyboardSpacer); diff --git a/src/components/KeyboardSpacer/index.js b/src/components/KeyboardSpacer/index.js deleted file mode 100644 index 77e1cc978337..000000000000 --- a/src/components/KeyboardSpacer/index.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * On non native platforms we do not need to implement a keyboard spacer, so we return a null component. - * - * @returns {null} - * @constructor - */ -function KeyboardSpacer() { - return null; -} - -export default KeyboardSpacer;