ADD: show selected coins summary on CoinControl screen

This commit is contained in:
Ivan Vershigora 2022-01-24 13:28:03 +03:00
parent 942d99b52b
commit 50910067fb
2 changed files with 17 additions and 5 deletions

View file

@ -625,6 +625,7 @@
"cc": {
"change": "Change",
"coins_selected": "Coins Selected ({number})",
"selected_summ": "{value} selected",
"empty": "This wallet doesnt have any coins at the moment.",
"freeze": "Freeze",
"freezeLabel": "Freeze",

View file

@ -299,12 +299,23 @@ const CoinControl = () => {
});
const tipCoins = () => {
if (utxo.length === 0) return null;
let text = loc.cc.tip;
if (selected.length > 0) {
// show summ of coins if any selected
const summ = selected.reduce((prev, curr) => {
return prev + utxo.find(({ txid, vout }) => `${txid}:${vout}` === curr).value;
}, 0);
const value = formatBalance(summ, wallet.getPreferredBalanceUnit(), true);
text = loc.formatString(loc.cc.selected_summ, { value });
}
return (
utxo.length >= 1 && (
<View style={[styles.tip, stylesHook.tip]}>
<Text style={{ color: colors.foregroundColor }}>{loc.cc.tip}</Text>
</View>
)
<View style={[styles.tip, stylesHook.tip]}>
<Text style={{ color: colors.foregroundColor }}>{text}</Text>
</View>
);
};