From 09b88e341d05d9bf5abec74b1a58538defa4145c Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Thu, 4 Jan 2024 17:27:05 +0100 Subject: [PATCH] Refactor AmountTextInput types --- src/components/AmountTextInput.tsx | 29 ++++++++--------------------- src/libs/ComposerUtils/index.ts | 8 ++++++-- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/components/AmountTextInput.tsx b/src/components/AmountTextInput.tsx index d524bced5a2d..e1bbb7cdfbdd 100644 --- a/src/components/AmountTextInput.tsx +++ b/src/components/AmountTextInput.tsx @@ -1,18 +1,15 @@ -import type {ForwardedRef} from 'react'; import React from 'react'; -import type {StyleProp, TextInput, TextStyle, ViewStyle} from 'react-native'; +import type {StyleProp, TextStyle, ViewStyle} from 'react-native'; import useThemeStyles from '@hooks/useThemeStyles'; import CONST from '@src/CONST'; -import type TextInputSelection from '@src/types/utils/TextInputSelection'; -import TextInputComponent from './TextInput'; +import type {TextSelection} from './Composer/types'; +import TextInput from './TextInput'; +import type {BaseTextInputRef} from './TextInput/BaseTextInput/types'; type AmountTextInputProps = { /** Formatted amount in local currency */ formattedAmount: string; - /** A ref to forward to amount text input */ - forwardedRef?: ForwardedRef; - /** Function to call when amount in text input is changed */ onChangeAmount: (amount: string) => void; @@ -20,7 +17,7 @@ type AmountTextInputProps = { placeholder: string; /** Selection Object */ - selection?: TextInputSelection; + selection?: TextSelection; /** Function to call when selection in text input is changed */ onSelectionChange?: () => void; @@ -35,27 +32,17 @@ type AmountTextInputProps = { onKeyPress?: () => void; }; -function AmountTextInput({ - formattedAmount, - forwardedRef = undefined, - onChangeAmount, - placeholder, - selection = undefined, - onSelectionChange = () => {}, - style = {}, - containerStyles = {}, - onKeyPress = () => {}, -}: AmountTextInputProps) { +function AmountTextInput({formattedAmount, onChangeAmount, placeholder, selection, onSelectionChange, style, containerStyles, onKeyPress}: AmountTextInputProps, ref: BaseTextInputRef) { const styles = useThemeStyles(); return ( -