From ed4215ac2a9c8521bf854879d79c8fb5a26d0e97 Mon Sep 17 00:00:00 2001 From: marcosrdz Date: Tue, 1 Dec 2020 16:38:18 -0500 Subject: [PATCH] ADD: CoinControl displays balances with user's preferred unit --- screen/send/coinControl.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/screen/send/coinControl.js b/screen/send/coinControl.js index 656b2a893..36bdd8bb3 100644 --- a/screen/send/coinControl.js +++ b/screen/send/coinControl.js @@ -16,7 +16,7 @@ import { } from 'react-native'; import { useRoute, useTheme, useNavigation } from '@react-navigation/native'; -import loc, { formatBalanceWithoutSuffix } from '../../loc'; +import loc, { formatBalance } from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; import { BlueNavigationStyle, SafeBlueArea, BlueSpacing10, BlueSpacing20, BlueButton, BlueListItem } from '../../BlueComponents'; import BottomModal from '../../components/BottomModal'; @@ -35,7 +35,15 @@ const debounce = (func, wait) => { }; }; -const Output = ({ item: { address, txid, value, vout }, oMemo, frozen, change = false, full = false, onPress }) => { +const Output = ({ + item: { address, txid, value, vout }, + balanceUnit = BitcoinUnit.BTC, + oMemo, + frozen, + change = false, + full = false, + onPress, +}) => { const { colors } = useTheme(); const { txMetadata } = useContext(BlueStorageContext); const cs = useColorScheme(); @@ -43,7 +51,7 @@ const Output = ({ item: { address, txid, value, vout }, oMemo, frozen, change = const fullId = `${txid}:${vout}`; const shortId = `${address.substring(0, 9)}...${address.substr(address.length - 9)}`; const color = `#${txid.substring(0, 6)}`; - const amount = formatBalanceWithoutSuffix(value, BitcoinUnit.BTC, true); + const amount = formatBalance(value, balanceUnit, true); const oStyles = StyleSheet.create({ containerFull: { paddingHorizontal: 0 }, @@ -102,6 +110,7 @@ Output.propTypes = { value: PropTypes.number.isRequired, vout: PropTypes.number.isRequired, }), + balanceUnit: PropTypes.string, oMemo: PropTypes.string, frozen: PropTypes.bool, change: PropTypes.bool, @@ -148,7 +157,7 @@ const OutputModalContent = ({ output, wallet, onUseCoin }) => { return ( <> - + { const renderItem = p => { const { memo, frozen } = wallet.getUTXOMetadata(p.item.txid, p.item.vout); const change = wallet.addressIsChange(p.item.address); - return handleChoose(p.item)} />; + return ( + handleChoose(p.item)} + /> + ); }; if (loading) {