From 46a0ff8a6c03195a5f74aa28cc131ca939065ff4 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Wed, 5 Apr 2023 12:17:43 -0400 Subject: [PATCH] Component: Amount Input --- components/AmountInput.tsx | 192 ++++++++++++++++++++++++++++++++++++ components/Conversion.tsx | 36 ++----- views/LnurlPay/LnurlPay.tsx | 125 +++++------------------ views/OpenChannel.tsx | 133 ++++--------------------- views/PaymentRequest.tsx | 140 ++++---------------------- views/Receive.tsx | 156 +++++------------------------ views/Send.tsx | 133 +++++++++---------------- 7 files changed, 333 insertions(+), 582 deletions(-) create mode 100644 components/AmountInput.tsx diff --git a/components/AmountInput.tsx b/components/AmountInput.tsx new file mode 100644 index 000000000..fa24ed95e --- /dev/null +++ b/components/AmountInput.tsx @@ -0,0 +1,192 @@ +import * as React from 'react'; +import { Text, TouchableOpacity, View } from 'react-native'; +import { inject, observer } from 'mobx-react'; +import BigNumber from 'bignumber.js'; + +import Amount from './Amount'; +import TextInput from './TextInput'; + +import { themeColor } from '../utils/ThemeUtils'; + +import Stores from '../stores/Stores'; +import FiatStore from '../stores/FiatStore'; +import SettingsStore from '../stores/SettingsStore'; +import UnitsStore, { SATS_PER_BTC } from '../stores/UnitsStore'; + +interface AmountInputProps { + onAmountChange: (amount: string, satAmount: string | number) => void; + amount?: string; + locked?: boolean; + title: string; + hideConversion?: boolean; + FiatStore?: FiatStore; + SettingsStore?: SettingsStore; + UnitsStore?: UnitsStore; +} + +interface AmountInputState { + satAmount: string | number; +} + +const getSatAmount = (amount: string | number) => { + const { fiatStore, settingsStore, unitsStore } = Stores; + const { fiatRates } = fiatStore; + const { settings } = settingsStore; + const { fiat } = settings; + const { units } = unitsStore; + + const value = amount || '0'; + + const fiatEntry = + fiat && fiatRates && fiatRates.filter + ? fiatRates.filter((entry: any) => entry.code === fiat)[0] + : null; + + const rate = + fiat && fiat !== 'Disabled' && fiatRates && fiatEntry + ? fiatEntry.rate + : 0; + + let satAmount: string | number; + switch (units) { + case 'sats': + satAmount = value; + break; + case 'BTC': + satAmount = new BigNumber(value || 0) + .multipliedBy(SATS_PER_BTC) + .toNumber(); + break; + case 'fiat': + satAmount = rate + ? new BigNumber(value.toString().replace(/,/g, '.')) + .dividedBy(rate) + .multipliedBy(SATS_PER_BTC) + .toNumber() + .toFixed(0) + : 0; + break; + } + + return satAmount; +}; + +@inject('FiatStore', 'SettingsStore', 'UnitsStore') +@observer +export default class AmountInput extends React.Component< + AmountInputProps, + AmountInputState +> { + constructor(props: any) { + super(props); + + this.state = { + satAmount: '0' + }; + } + + componentWillReceiveProps(nextProps: Readonly): void { + const { amount } = nextProps; + if (amount) { + const satAmount = getSatAmount(amount); + this.setState({ satAmount }); + } + } + + onChangeUnits = () => { + const { amount, onAmountChange, UnitsStore }: any = this.props; + UnitsStore.changeUnits(); + const satAmount = getSatAmount(amount); + onAmountChange(amount, satAmount); + this.setState({ satAmount }); + }; + + render() { + const { satAmount } = this.state; + const { + amount, + onAmountChange, + title, + locked, + hideConversion, + FiatStore, + UnitsStore, + SettingsStore + } = this.props; + const { units }: any = UnitsStore; + const { getRate, getSymbol }: any = FiatStore; + const { settings }: any = SettingsStore; + const { fiat } = settings; + + return ( + + {title && ( + this.onChangeUnits()}> + + {title} + + + )} + { + const satAmount = getSatAmount(text); + onAmountChange(text, satAmount); + this.setState({ satAmount }); + }} + locked={locked} + prefix={ + units !== 'sats' && + (units === 'BTC' + ? '₿' + : !getSymbol().rtl + ? getSymbol().symbol + : null) + } + suffix={ + units === 'sats' + ? units + : getSymbol().rtl && + units === 'fiat' && + getSymbol().symbol + } + toggleUnits={this.onChangeUnits} + /> + {!hideConversion && ( + this.onChangeUnits()}> + + {fiat !== 'Disabled' && units !== 'fiat' && ( + + )} + {fiat !== 'Disabled' && ( + + {getRate(units === 'sats')} + + )} + {units !== 'sats' && ( + + )} + {units !== 'BTC' && ( + + )} + + + )} + + ); + } +} + +export { getSatAmount }; diff --git a/components/Conversion.tsx b/components/Conversion.tsx index c85e55bdb..a954a3989 100644 --- a/components/Conversion.tsx +++ b/components/Conversion.tsx @@ -5,9 +5,10 @@ import { inject, observer } from 'mobx-react'; import Amount from '../components/Amount'; import { Row } from '../components/layout/Row'; +import { getSatAmount } from '../components/AmountInput'; import FiatStore from '../stores/UnitsStore'; -import UnitsStore, { SATS_PER_BTC } from '../stores/UnitsStore'; +import UnitsStore from '../stores/UnitsStore'; import SettingsStore, { DEFAULT_FIAT } from '../stores/SettingsStore'; import { themeColor } from '../utils/ThemeUtils'; @@ -59,38 +60,13 @@ export default class Conversion extends React.Component< const { settings } = SettingsStore; const { fiat } = settings; - const { fiatRates, getRate }: any = FiatStore; - - // calculate fiat rate - const fiatEntry = - fiat && fiatRates && fiatRates.filter - ? fiatRates.filter((entry: any) => entry.code === fiat)[0] - : null; - - const rate = - fiat && fiat !== 'Disabled' && fiatRates && fiatEntry - ? fiatEntry.rate - : 0; + const { getRate }: any = FiatStore; let satAmount: string | number; - if (amount) { - const amountStr = amount.toString(); - switch (units) { - case 'sats': - satAmount = amountStr; - break; - case 'BTC': - satAmount = Number(amountStr) * SATS_PER_BTC; - break; - case 'fiat': - satAmount = Number( - (Number(amountStr.replace(/,/g, '.')) / Number(rate)) * - Number(SATS_PER_BTC) - ).toFixed(0); - break; - } - } else if (sats) { + if (sats) { satAmount = sats; + } else { + satAmount = getSatAmount(amount); } if (!fiat || fiat === DEFAULT_FIAT || (!amount && !sats)) return; diff --git a/views/LnurlPay/LnurlPay.tsx b/views/LnurlPay/LnurlPay.tsx index e3b572146..b18444b99 100644 --- a/views/LnurlPay/LnurlPay.tsx +++ b/views/LnurlPay/LnurlPay.tsx @@ -1,50 +1,40 @@ import url from 'url'; import * as React from 'react'; import ReactNativeBlobUtil from 'react-native-blob-util'; -import { Alert, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; +import { Alert, StyleSheet, Text, View } from 'react-native'; import { inject, observer } from 'mobx-react'; import { Header, Icon } from 'react-native-elements'; import querystring from 'querystring-es3'; -import Amount from './../../components/Amount'; -import Button from './../../components/Button'; -import Screen from './../../components/Screen'; -import TextInput from './../../components/TextInput'; -import { Row } from './../..//components/layout/Row'; +import Amount from '../../components/Amount'; +import AmountInput from '../../components/AmountInput'; +import Button from '../../components/Button'; +import Screen from '../../components/Screen'; +import TextInput from '../../components/TextInput'; +import { Row } from '../..//components/layout/Row'; -import InvoicesStore from './../../stores/InvoicesStore'; -import LnurlPayStore from './../../stores/LnurlPayStore'; -import SettingsStore from './../../stores/SettingsStore'; -import FiatStore from './../../stores/FiatStore'; -import UnitsStore, { SATS_PER_BTC } from './../../stores/UnitsStore'; +import InvoicesStore from '../../stores/InvoicesStore'; +import LnurlPayStore from '../../stores/LnurlPayStore'; import LnurlPayMetadata from './Metadata'; -import { localeString } from './../../utils/LocaleUtils'; -import { themeColor } from './../../utils/ThemeUtils'; +import { localeString } from '../../utils/LocaleUtils'; +import { themeColor } from '../../utils/ThemeUtils'; interface LnurlPayProps { navigation: any; InvoicesStore: InvoicesStore; LnurlPayStore: LnurlPayStore; - FiatStore: FiatStore; - UnitsStore: UnitsStore; - SettingsStore: SettingsStore; } interface LnurlPayState { amount: string; + satAmount: string | number; domain: string; comment: string; } -@inject( - 'FiatStore', - 'InvoicesStore', - 'SettingsStore', - 'LnurlPayStore', - 'UnitsStore' -) +@inject('InvoicesStore', 'LnurlPayStore') @observer export default class LnurlPay extends React.Component< LnurlPayProps, @@ -58,6 +48,7 @@ export default class LnurlPay extends React.Component< } catch (err) { this.state = { amount: '', + satAmount: '', domain: '', comment: '' }; @@ -169,38 +160,8 @@ export default class LnurlPay extends React.Component< } render() { - const { navigation, SettingsStore, UnitsStore, FiatStore } = this.props; - const { amount, domain, comment } = this.state; - const { settings } = SettingsStore; - const { fiat } = settings; - const { units, changeUnits } = UnitsStore; - const { fiatRates, getSymbol } = FiatStore; - - const fiatEntry = - fiat && fiatRates && fiatRates.filter - ? fiatRates.filter((entry: any) => entry.code === fiat)[0] - : null; - - const rate = - fiat && fiat !== 'Disabled' && fiatRates && fiatEntry - ? fiatEntry.rate - : 0; - - let satAmount: string | number; - switch (units) { - case 'sats': - satAmount = amount; - break; - case 'BTC': - satAmount = Number(amount) * SATS_PER_BTC; - break; - case 'fiat': - satAmount = Number( - (Number(amount.replace(/,/g, '.')) / Number(rate)) * - Number(SATS_PER_BTC) - ).toFixed(0); - break; - } + const { navigation } = this.props; + const { amount, satAmount, domain, comment } = this.state; const lnurl = navigation.getParam('lnurlParams'); @@ -289,55 +250,23 @@ export default class LnurlPay extends React.Component< )} - { - this.setState({ amount: text }); - }} + { + this.setState({ + amount, + satAmount + }); + }} /> - {fiat !== 'Disabled' && units !== 'fiat' && ( - - )} - {fiat !== 'Disabled' && ( - changeUnits()}> - - {FiatStore.getRate(units === 'sats')} - - - )} - {units !== 'sats' && ( - - )} - {units !== 'BTC' && ( - - )} {lnurl.commentAllowed > 0 ? ( <> entry.code === fiat)[0] - : null; - - const rate = - fiat && fiat !== 'Disabled' && fiatRates && fiatEntry - ? fiatEntry.rate - : 0; - - // conversion - let satAmount: string | number; - switch (units) { - case 'sats': - satAmount = local_funding_amount; - break; - case 'BTC': - satAmount = Number(local_funding_amount) * SATS_PER_BTC; - break; - case 'fiat': - satAmount = Number( - (Number(local_funding_amount.replace(/,/g, '.')) / - Number(rate)) * - Number(SATS_PER_BTC) - ).toFixed(0); - break; - } - const BackButton = () => ( - { + this.setState({ + local_funding_amount: amount, + satAmount + }); }} - > - {localeString('views.OpenChannel.localAmt')} - - - this.setState({ local_funding_amount: text }) - } - locked={openingChannel} - prefix={ - units !== 'sats' && - (units === 'BTC' - ? '₿' - : !getSymbol().rtl - ? getSymbol().symbol - : null) - } - suffix={ - units === 'sats' - ? units - : getSymbol().rtl && - units === 'fiat' && - getSymbol().symbol - } - toggleUnits={changeUnits} + hideConversion={local_funding_amount === 'all'} /> - {local_funding_amount !== 'all' && ( - - {fiat !== 'Disabled' && units !== 'fiat' && ( - - )} - {fiat !== 'Disabled' && ( - changeUnits()} - > - - {FiatStore.getRate( - units === 'sats' - )} - - - )} - {units !== 'sats' && ( - - )} - {units !== 'BTC' && ( - - )} - - )} {local_funding_amount === 'all' && ( diff --git a/views/PaymentRequest.tsx b/views/PaymentRequest.tsx index 231f3f82d..7b7822f7a 100644 --- a/views/PaymentRequest.tsx +++ b/views/PaymentRequest.tsx @@ -12,6 +12,7 @@ import { inject, observer } from 'mobx-react'; import { Header, Icon } from 'react-native-elements'; import Amount from '../components/Amount'; +import AmountInput from '../components/AmountInput'; import Button from '../components/Button'; import HopPicker from '../components/HopPicker'; import KeyValue from '../components/KeyValue'; @@ -21,10 +22,9 @@ import Switch from '../components/Switch'; import TextInput from '../components/TextInput'; import ChannelsStore from '../stores/ChannelsStore'; -import FiatStore from '../stores/FiatStore'; import InvoicesStore from '../stores/InvoicesStore'; import TransactionsStore, { SendPaymentReq } from '../stores/TransactionsStore'; -import UnitsStore, { SATS_PER_BTC } from '../stores/UnitsStore'; +import UnitsStore from '../stores/UnitsStore'; import SettingsStore from '../stores/SettingsStore'; import FeeUtils from '../utils/FeeUtils'; @@ -45,11 +45,11 @@ interface InvoiceProps { UnitsStore: UnitsStore; ChannelsStore: ChannelsStore; SettingsStore: SettingsStore; - FiatStore: FiatStore; } interface InvoiceState { customAmount: string; + satAmount: string | number; enableMultiPathPayment: boolean; enableAtomicMultiPathPayment: boolean; maxParts: string; @@ -63,7 +63,6 @@ interface InvoiceState { } @inject( - 'FiatStore', 'InvoicesStore', 'TransactionsStore', 'UnitsStore', @@ -78,6 +77,7 @@ export default class PaymentRequest extends React.Component< listener: any; state = { customAmount: '', + satAmount: '', enableMultiPathPayment: true, enableAtomicMultiPathPayment: false, maxParts: '16', @@ -206,7 +206,6 @@ export default class PaymentRequest extends React.Component< render() { const { InvoicesStore, - FiatStore, UnitsStore, ChannelsStore, SettingsStore, @@ -223,6 +222,7 @@ export default class PaymentRequest extends React.Component< outgoingChanId, lastHopPubkey, customAmount, + satAmount, settingsToggle } = this.state; const { @@ -235,10 +235,6 @@ export default class PaymentRequest extends React.Component< feeEstimate, clearPayReq } = InvoicesStore; - const { units, changeUnits } = UnitsStore; - const { fiatRates, getSymbol } = FiatStore; - const { settings } = SettingsStore; - const { fiat } = settings; const requestAmount = pay_req && pay_req.getRequestAmount; const expiry = pay_req && pay_req.expiry; @@ -248,33 +244,6 @@ export default class PaymentRequest extends React.Component< const payment_hash = pay_req && pay_req.payment_hash; const timestamp = pay_req && pay_req.timestamp; - const fiatEntry = - fiat && fiatRates && fiatRates.filter - ? fiatRates.filter((entry: any) => entry.code === fiat)[0] - : null; - - const rate = - fiat && fiat !== 'Disabled' && fiatRates && fiatEntry - ? fiatEntry.rate - : 0; - - // conversion - let satAmount: string | number; - switch (units) { - case 'sats': - satAmount = customAmount; - break; - case 'BTC': - satAmount = Number(customAmount) * SATS_PER_BTC; - break; - case 'fiat': - satAmount = Number( - (Number(customAmount.replace(/,/g, '.')) / Number(rate)) * - Number(SATS_PER_BTC) - ).toFixed(0); - break; - } - // handle fee percents that use commas const maxFeePercentFormatted = maxFeePercent.replace(/,/g, '.'); @@ -367,92 +336,21 @@ export default class PaymentRequest extends React.Component< <> {isNoAmountInvoice ? ( - <> - - {localeString( - 'views.PaymentRequest.customAmt' - )} - - - this.setState({ - customAmount: text - }) - } - numberOfLines={1} - style={{ - ...styles.textInput, - color: themeColor('text') - }} - placeholderTextColor="gray" - prefix={ - units !== 'sats' && - (units === 'BTC' - ? '₿' - : !getSymbol().rtl - ? getSymbol().symbol - : null) - } - suffix={ - units === 'sats' - ? units - : getSymbol().rtl && - units === 'fiat' && - getSymbol().symbol - } - toggleUnits={changeUnits} - /> - {fiat !== 'Disabled' && - units !== 'fiat' && ( - - )} - {fiat !== 'Disabled' && ( - changeUnits()} - > - - {FiatStore.getRate( - units === 'sats' - )} - - - )} - {units !== 'sats' && ( - - )} - {units !== 'BTC' && ( - + + onAmountChange={( + amount: string, + satAmount: string | number + ) => { + this.setState({ + customAmount: amount, + satAmount + }); + }} + /> ) : ( { const { navigation, InvoicesStore } = this.props; const { createUnifiedInvoice } = InvoicesStore; - const amount = this.getSatAmount(navigation.getParam('amount')); + const amount = getSatAmount(navigation.getParam('amount')); handleAnything(text, amount.toString()) .then((response) => { @@ -554,66 +553,20 @@ export default class Receive extends React.Component< }); }; - getSatAmount = (amount?: string) => { - const { FiatStore, SettingsStore, UnitsStore } = this.props; - const { fiatRates } = FiatStore; - const { settings } = SettingsStore; - const { fiat } = settings; - const { units } = UnitsStore; - - const value = amount || this.state.value; - - const fiatEntry = - fiat && fiatRates && fiatRates.filter - ? fiatRates.filter((entry: any) => entry.code === fiat)[0] - : null; - - const rate = - fiat && fiat !== 'Disabled' && fiatRates && fiatEntry - ? fiatEntry.rate - : 0; - - let satAmount: string | number; - switch (units) { - case 'sats': - satAmount = value; - break; - case 'BTC': - satAmount = Number( - new BigNumber(value).multipliedBy(SATS_PER_BTC) - ); - break; - case 'fiat': - satAmount = Number( - new BigNumber(value.replace(/,/g, '.')) - .dividedBy(rate) - .multipliedBy(SATS_PER_BTC) - ).toFixed(0); - break; - } - - return satAmount; - }; - render() { - const { - InvoicesStore, - SettingsStore, - UnitsStore, - FiatStore, - navigation - } = this.props; + const { InvoicesStore, SettingsStore, UnitsStore, navigation } = + this.props; const { selectedIndex, addressType, memo, value, + satAmount, expiry, ampInvoice, routeHints } = this.state; - const { units, changeUnits, getAmount } = UnitsStore; - const { getSymbol }: any = FiatStore; + const { getAmount } = UnitsStore; const { createUnifiedInvoice, @@ -639,8 +592,6 @@ export default class Receive extends React.Component< settings.pos.confirmationPreference && settings.pos.confirmationPreference === 'lnOnly'; - const satAmount = this.getSatAmount(); - const lnurl: LNURLWithdrawParams | undefined = navigation.getParam('lnurlParams'); @@ -1073,21 +1024,12 @@ export default class Receive extends React.Component< }} /> - changeUnits()} - > - - {localeString( - 'views.Receive.amount' - )} - {lnurl && + - - { - this.setState({ value: text }); - }} + : '' + }`} locked={ lnurl && lnurl.minWithdrawable === @@ -1114,51 +1048,16 @@ export default class Receive extends React.Component< ? true : false } - prefix={ - units !== 'sats' && - (units === 'BTC' - ? '₿' - : !getSymbol().rtl - ? getSymbol().symbol - : null) - } - suffix={ - units === 'sats' - ? units - : getSymbol().rtl && - units === 'fiat' && - getSymbol().symbol - } - toggleUnits={changeUnits} + onAmountChange={( + amount: string, + satAmount: string | number + ) => { + this.setState({ + value: amount, + satAmount + }); + }} /> - {units !== 'sats' && ( - - )} - {units !== 'BTC' && ( - - )} - {units === 'fiat' && ( - changeUnits()} - > - - {FiatStore.getRate()} - - - )} {implementation !== 'lndhub' && ( <> @@ -1167,8 +1066,7 @@ export default class Receive extends React.Component< ...styles.secondaryText, color: themeColor( 'secondaryText' - ), - paddingTop: 10 + ) }} > {localeString( diff --git a/views/Send.tsx b/views/Send.tsx index b912e9674..c471d8f98 100644 --- a/views/Send.tsx +++ b/views/Send.tsx @@ -20,32 +20,32 @@ import NfcManager, { Ndef } from 'react-native-nfc-manager'; -import handleAnything, { isClipboardValue } from './../utils/handleAnything'; - -import InvoicesStore from './../stores/InvoicesStore'; -import NodeInfoStore from './../stores/NodeInfoStore'; -import TransactionsStore from './../stores/TransactionsStore'; -import BalanceStore from './../stores/BalanceStore'; -import UTXOsStore from './../stores/UTXOsStore'; -import SettingsStore from './../stores/SettingsStore'; -import UnitsStore, { SATS_PER_BTC } from './../stores/UnitsStore'; -import FiatStore from './../stores/FiatStore'; - -import Amount from './../components/Amount'; -import Conversion from './../components/Conversion'; -import Button from './../components/Button'; -import { ErrorMessage } from './../components/SuccessErrorMessage'; -import Screen from './../components/Screen'; -import Switch from './../components/Switch'; -import TextInput from './../components/TextInput'; -import UTXOPicker from './../components/UTXOPicker'; - -import BackendUtils from './../utils/BackendUtils'; -import NFCUtils from './../utils/NFCUtils'; -import { localeString } from './../utils/LocaleUtils'; -import { themeColor } from './../utils/ThemeUtils'; - -import Scan from './../assets/images/SVG/Scan.svg'; +import handleAnything, { isClipboardValue } from '../utils/handleAnything'; + +import InvoicesStore from '../stores/InvoicesStore'; +import NodeInfoStore from '../stores/NodeInfoStore'; +import TransactionsStore from '../stores/TransactionsStore'; +import BalanceStore from '../stores/BalanceStore'; +import UTXOsStore from '../stores/UTXOsStore'; +import SettingsStore from '../stores/SettingsStore'; +import UnitsStore from '../stores/UnitsStore'; +import FiatStore from '../stores/FiatStore'; + +import Amount from '../components/Amount'; +import AmountInput from '../components/AmountInput'; +import Button from '../components/Button'; +import { ErrorMessage } from '../components/SuccessErrorMessage'; +import Screen from '../components/Screen'; +import Switch from '../components/Switch'; +import TextInput from '../components/TextInput'; +import UTXOPicker from '../components/UTXOPicker'; + +import BackendUtils from '../utils/BackendUtils'; +import NFCUtils from '../utils/NFCUtils'; +import { localeString } from '../utils/LocaleUtils'; +import { themeColor } from '../utils/ThemeUtils'; + +import Scan from '../assets/images/SVG/Scan.svg'; interface SendProps { exitSetup: any; @@ -65,6 +65,7 @@ interface SendState { transactionType: string | null; destination: string; amount: string; + satAmount: string | number; fee: string; error_msg: string; utxos: Array; @@ -108,6 +109,7 @@ export default class Send extends React.Component { transactionType, destination: destination || '', amount: amount || '', + satAmount: '', fee: '2', utxos: [], utxoBalance: 0, @@ -364,6 +366,7 @@ export default class Send extends React.Component { transactionType, destination, amount, + satAmount, fee, confirmationTarget, utxoBalance, @@ -380,33 +383,7 @@ export default class Send extends React.Component { const { fiat, privacy } = settings; const enableMempoolRates = privacy && privacy.enableMempoolRates; const { units, changeUnits } = UnitsStore; - const { fiatRates, getSymbol } = FiatStore; - - const fiatEntry = - fiat && fiatRates && fiatRates.filter - ? fiatRates.filter((entry: any) => entry.code === fiat)[0] - : null; - - const rate = - fiat && fiat !== 'Disabled' && fiatRates && fiatEntry - ? fiatEntry.rate - : 0; - - let satAmount: string | number; - switch (units) { - case 'sats': - satAmount = amount; - break; - case 'BTC': - satAmount = Number(amount) * SATS_PER_BTC; - break; - case 'fiat': - satAmount = Number( - (Number(amount.replace(/,/g, '.')) / Number(rate)) * - Number(SATS_PER_BTC) - ).toFixed(0); - break; - } + const { getSymbol } = FiatStore; const BackButton = () => ( { {transactionType === 'On-chain' && BackendUtils.supportsOnchainSends() && ( - changeUnits()}> - - {localeString('views.Send.amount')} - - - - this.setState({ amount: text }) - } - style={styles.textInput} - prefix={ - units !== 'sats' && - (units === 'BTC' - ? '₿' - : !getSymbol().rtl - ? getSymbol().symbol - : null) - } - suffix={ - units === 'sats' - ? units - : getSymbol().rtl && - units === 'fiat' && - getSymbol().symbol - } - toggleUnits={changeUnits} + { + this.setState({ + amount, + satAmount + }); + }} + hideConversion={amount === 'all'} /> + - {amount === 'all' && ( <> { : confirmedBlockchainBalance } fixedUnits="BTC" - toggleable /> { : confirmedBlockchainBalance } fixedUnits="sats" - toggleable /> )}