From 278761adfbd271f12cbb8877873aaff0824966d4 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Thu, 6 Feb 2025 18:08:02 +0100 Subject: [PATCH] Add support for negative amounts in BaseTextInputWithCurrencySymbol --- .../BaseTextInputWithCurrencySymbol.tsx | 6 ++++++ src/components/TextInputWithCurrencySymbol/types.ts | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/components/TextInputWithCurrencySymbol/BaseTextInputWithCurrencySymbol.tsx b/src/components/TextInputWithCurrencySymbol/BaseTextInputWithCurrencySymbol.tsx index 4c30b048c1af..652ed1bf9961 100644 --- a/src/components/TextInputWithCurrencySymbol/BaseTextInputWithCurrencySymbol.tsx +++ b/src/components/TextInputWithCurrencySymbol/BaseTextInputWithCurrencySymbol.tsx @@ -4,6 +4,7 @@ import AmountTextInput from '@components/AmountTextInput'; import CurrencySymbolButton from '@components/CurrencySymbolButton'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Text from '@src/components/Text'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; @@ -22,6 +23,7 @@ function BaseTextInputWithCurrencySymbol( isCurrencyPressable = true, hideCurrencySymbol = false, extraSymbol, + isNegative = false, style, ...rest }: BaseTextInputWithCurrencySymbolProps, @@ -67,9 +69,12 @@ function BaseTextInputWithCurrencySymbol( /> ); + const negativeSymbol = -; + if (isCurrencySymbolLTR) { return ( <> + {isNegative && negativeSymbol} {currencySymbolButton} {amountTextInput} {extraSymbol} @@ -79,6 +84,7 @@ function BaseTextInputWithCurrencySymbol( return ( <> + {isNegative && negativeSymbol} {amountTextInput} {currencySymbolButton} {extraSymbol} diff --git a/src/components/TextInputWithCurrencySymbol/types.ts b/src/components/TextInputWithCurrencySymbol/types.ts index 3988654584d0..eea33cadd4db 100644 --- a/src/components/TextInputWithCurrencySymbol/types.ts +++ b/src/components/TextInputWithCurrencySymbol/types.ts @@ -77,6 +77,9 @@ type BaseTextInputWithCurrencySymbolProps = { /** Hide the focus styles on TextInput */ hideFocusedState?: boolean; + + /** Whether the amount is negative */ + isNegative?: boolean; } & Pick; type TextInputWithCurrencySymbolProps = Omit & {