mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 06:52:41 +01:00
FIX: Added withFormatting option
This commit is contained in:
parent
00845ef838
commit
5876b9e9ef
5 changed files with 11 additions and 10 deletions
|
@ -1168,8 +1168,9 @@ export class BlueBitcoinAmount extends Component {
|
|||
<View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}>
|
||||
<Text style={{ fontSize: 18, color: '#d4d4d4', fontWeight: '600' }}>
|
||||
{loc.formatBalance(
|
||||
this.props.unit === BitcoinUnit.BTC ? amount || 0 : loc.formatBalanceWithoutSuffix(amount || 0, BitcoinUnit.BTC),
|
||||
this.props.unit === BitcoinUnit.BTC ? amount || 0 : loc.formatBalanceWithoutSuffix(amount || 0, BitcoinUnit.BTC, false),
|
||||
BitcoinUnit.LOCAL_CURRENCY,
|
||||
false,
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>216</string>
|
||||
<string>217</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
|
|
@ -100,7 +100,7 @@ function removeTrailingZeros(value) {
|
|||
* @param toUnit {String} Value from models/bitcoinUnits.js
|
||||
* @returns {string}
|
||||
*/
|
||||
strings.formatBalance = (balance, toUnit) => {
|
||||
strings.formatBalance = (balance, toUnit, withFormatting = false) => {
|
||||
if (toUnit === undefined) {
|
||||
return balance + ' ' + BitcoinUnit.BTC;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ strings.formatBalance = (balance, toUnit) => {
|
|||
return balance + ' ' + BitcoinUnit.BTC;
|
||||
} else if (toUnit === BitcoinUnit.SATS) {
|
||||
const value = new BigNumber(balance).multipliedBy(100000000);
|
||||
return new Intl.NumberFormat().format(value.toString()) + ' ' + BitcoinUnit.SATS;
|
||||
return withFormatting ? new Intl.NumberFormat().format(value.toString()) : balance + ' ' + BitcoinUnit.SATS;
|
||||
} else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) {
|
||||
return currency.BTCToLocalCurrency(balance);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ strings.formatBalance = (balance, toUnit) => {
|
|||
* @param toUnit {String} Value from models/bitcoinUnits.js
|
||||
* @returns {string}
|
||||
*/
|
||||
strings.formatBalanceWithoutSuffix = (balance, toUnit) => {
|
||||
strings.formatBalanceWithoutSuffix = (balance, toUnit, withFormatting = false) => {
|
||||
if (toUnit === undefined) {
|
||||
return balance;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ strings.formatBalanceWithoutSuffix = (balance, toUnit) => {
|
|||
const value = new BigNumber(balance).dividedBy(100000000).toFixed(8);
|
||||
return removeTrailingZeros(value);
|
||||
} else if (toUnit === BitcoinUnit.SATS) {
|
||||
return new Intl.NumberFormat().format(balance);
|
||||
return withFormatting ? new Intl.NumberFormat().format(balance) : balance;
|
||||
} else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) {
|
||||
return currency.satoshiToLocalCurrency(balance);
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ export default class SendDetails extends Component {
|
|||
.then(response => {
|
||||
this.setState({
|
||||
address: response.address,
|
||||
amount: loc.formatBalanceWithoutSuffix(response.amount, BitcoinUnit.BTC),
|
||||
amount: loc.formatBalanceWithoutSuffix(response.amount, BitcoinUnit.BTC, false),
|
||||
memo: response.memo,
|
||||
fee: response.fee,
|
||||
bip70TransactionExpiration: response.expires,
|
||||
|
|
|
@ -311,16 +311,16 @@ export default class WalletTransactions extends Component {
|
|||
const invoiceExpiration = item.timestamp + item.expire_time;
|
||||
|
||||
if (invoiceExpiration > now) {
|
||||
return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit()).toString();
|
||||
return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit(), true).toString();
|
||||
} else if (invoiceExpiration < now) {
|
||||
if (item.ispaid) {
|
||||
return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit()).toString();
|
||||
return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit(), true).toString();
|
||||
} else {
|
||||
return loc.lnd.expired;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit()).toString();
|
||||
return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit(), true).toString();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue