mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-20 02:09:10 +01:00
ADD: CoinControl displays balances with user's preferred unit
This commit is contained in:
parent
27c9bf3fff
commit
ed4215ac2a
@ -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 (
|
||||
<>
|
||||
<Output item={output} full />
|
||||
<Output item={output} balanceUnit={wallet.getPreferredBalanceUnit()} full />
|
||||
<BlueSpacing20 />
|
||||
<TextInput
|
||||
testID="OutputMemo"
|
||||
@ -223,7 +232,16 @@ const CoinControl = () => {
|
||||
const renderItem = p => {
|
||||
const { memo, frozen } = wallet.getUTXOMetadata(p.item.txid, p.item.vout);
|
||||
const change = wallet.addressIsChange(p.item.address);
|
||||
return <Output item={p.item} oMemo={memo} frozen={frozen} change={change} onPress={() => handleChoose(p.item)} />;
|
||||
return (
|
||||
<Output
|
||||
balanceUnit={wallet.getPreferredBalanceUnit()}
|
||||
item={p.item}
|
||||
oMemo={memo}
|
||||
frozen={frozen}
|
||||
change={change}
|
||||
onPress={() => handleChoose(p.item)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
|
Loading…
Reference in New Issue
Block a user