From 20dea7c2c9567ff9a645880098faf9ae8571d596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Tue, 24 Oct 2023 05:26:32 -0300 Subject: [PATCH 1/6] Rename file to TSX --- src/components/{BigNumberPad.js => BigNumberPad.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/components/{BigNumberPad.js => BigNumberPad.tsx} (100%) diff --git a/src/components/BigNumberPad.js b/src/components/BigNumberPad.tsx similarity index 100% rename from src/components/BigNumberPad.js rename to src/components/BigNumberPad.tsx From 63559ae0a6ff3d98ef179f32b91e8745f3842eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Tue, 24 Oct 2023 06:40:05 -0300 Subject: [PATCH 2/6] Starts migration of BigNumberPad --- src/components/BigNumberPad.tsx | 57 +++++++++++++++------------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/components/BigNumberPad.tsx b/src/components/BigNumberPad.tsx index 5587808a09fd..aeadce2c3025 100644 --- a/src/components/BigNumberPad.tsx +++ b/src/components/BigNumberPad.tsx @@ -1,29 +1,22 @@ import React, {useState} from 'react'; import {View} from 'react-native'; -import _ from 'underscore'; -import PropTypes from 'prop-types'; +import useWindowDimensions from '../hooks/useWindowDimensions'; +import ControlSelection from '../libs/ControlSelection'; import styles from '../styles/styles'; import Button from './Button'; -import ControlSelection from '../libs/ControlSelection'; -import withLocalize, {withLocalizePropTypes} from './withLocalize'; -import useWindowDimensions from '../hooks/useWindowDimensions'; +import withLocalize from './withLocalize'; -const propTypes = { +type BigNumberPadProps = { /** Callback to inform parent modal with key pressed */ - numberPressed: PropTypes.func.isRequired, + numberPressed: (key: string) => void; /** Callback to inform parent modal whether user is long pressing the "<" (backspace) button */ - longPressHandlerStateChanged: PropTypes.func, + longPressHandlerStateChanged?: (isUserLongPressingBackspace: boolean) => void; /** Used to locate this view from native classes. */ - nativeID: PropTypes.string, + nativeID?: string; - ...withLocalizePropTypes, -}; - -const defaultProps = { - longPressHandlerStateChanged: () => {}, - nativeID: 'numPadView', + // TODO: Add withLocalize props (withLocalizePropTypes) }; const padNumbers = [ @@ -33,57 +26,61 @@ const padNumbers = [ ['.', '0', '<'], ]; -function BigNumberPad(props) { - const [timer, setTimer] = useState(null); +function BigNumberPad({numberPressed, longPressHandlerStateChanged = () => {}, nativeID = 'numPadView'}: BigNumberPadProps) { + const [timer, setTimer] = useState(null); const {isExtraSmallScreenHeight} = useWindowDimensions(); /** * Handle long press key on number pad. * Only handles the '<' key and starts the continuous input timer. - * - * @param {String} key */ - const handleLongPress = (key) => { + const handleLongPress = (key: string) => { if (key !== '<') { return; } - props.longPressHandlerStateChanged(true); + longPressHandlerStateChanged(true); const newTimer = setInterval(() => { - props.numberPressed(key); + numberPressed(key); }, 100); + setTimer(newTimer); }; return ( - {_.map(padNumbers, (row, rowIndex) => ( + {padNumbers.map((row, rowIndex) => ( - {_.map(row, (column, columnIndex) => { + {row.map((column, columnIndex) => { // Adding margin between buttons except first column to // avoid unccessary space before the first column. const marginLeft = columnIndex > 0 ? styles.ml3 : {}; + return (