mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 09:50:15 +01:00
FIX: Tap to change unit
This commit is contained in:
parent
6681f79be1
commit
de276d064c
11
loc/index.js
11
loc/index.js
@ -80,7 +80,7 @@ strings.formatBalance = (balance, unit) => {
|
||||
if (!Number.isInteger(balance)) {
|
||||
return balance + ' ' + BitcoinUnit.BTC;
|
||||
}
|
||||
return b.times(conversion).toString() + ' ' + BitcoinUnit.BTC;
|
||||
return b.div(conversion).toString() + ' ' + BitcoinUnit.BTC;
|
||||
} else if (unit === BitcoinUnit.SATS) {
|
||||
return (b.times(conversion).toString() + ' ' + BitcoinUnit.SATS).replace(/\./g, '');
|
||||
} else if (unit === BitcoinUnit.LOCAL_CURRENCY) {
|
||||
@ -92,20 +92,19 @@ strings.formatBalance = (balance, unit) => {
|
||||
};
|
||||
|
||||
strings.formatBalanceWithoutSuffix = (balance, unit) => {
|
||||
const conversion = 100000000;
|
||||
let conversion = 100000000;
|
||||
if (balance !== 0) {
|
||||
let b = new BigNumber(balance);
|
||||
if (unit === BitcoinUnit.BTC) {
|
||||
if (!Number.isInteger(balance)) {
|
||||
return b.times(conversion).toString();
|
||||
}
|
||||
return b.times(conversion).toString();
|
||||
return b.dividedBy(conversion).toString();
|
||||
} else if (unit === BitcoinUnit.SATS) {
|
||||
conversion = 1;
|
||||
return b
|
||||
.times(conversion)
|
||||
.toString()
|
||||
.replace(/\./g, '');
|
||||
} else if (unit === BitcoinUnit.LOCAL_CURRENCY) {
|
||||
conversion = 1;
|
||||
return currency.satoshiToLocalCurrency(b.times(conversion).toNumber());
|
||||
}
|
||||
}
|
||||
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -10547,11 +10547,10 @@
|
||||
}
|
||||
},
|
||||
"react-native-camera": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/react-native-camera/-/react-native-camera-1.6.1.tgz",
|
||||
"integrity": "sha512-CqC+zXG2ocy6xrSTOh5HNWfrnQ/50PUTc0zrrZNHMvAEVJpxVdp2XPK+a1VrBQDX3fTG2sy0lGOlh/L39U5PXg==",
|
||||
"version": "1.6.3",
|
||||
"resolved": "https://registry.npmjs.org/react-native-camera/-/react-native-camera-1.6.3.tgz",
|
||||
"integrity": "sha512-j+uK3osT0womUv+9+bTWEfdNZW2pq9QKOrCuRdK/DMRneS+78YEwzKlEYKz9E6zAgCVTeLD0MsvmYNLZWt5/ow==",
|
||||
"requires": {
|
||||
"lodash": "^4.17.10",
|
||||
"prop-types": "^15.6.2"
|
||||
}
|
||||
},
|
||||
@ -10620,9 +10619,9 @@
|
||||
}
|
||||
},
|
||||
"react-native-gesture-handler": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-1.0.11.tgz",
|
||||
"integrity": "sha512-CNQqPXrLgAY/YsB0x7/1bDfRNEhKFo7cwWOLxA7Ug8iTanifek8cV4XvSFvixjbAz57cXpBhf79JwZsyc8XMHg==",
|
||||
"version": "1.0.12",
|
||||
"resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-1.0.12.tgz",
|
||||
"integrity": "sha512-Qp5FjRmqUFeCevSu2IYQG1Xw+YXZ9YOzqze/ZxaIvWzYAoKsRchlgHhNoxvCqElp/befrnVFIjAEQyUxcmBKJw==",
|
||||
"requires": {
|
||||
"hoist-non-react-statics": "^2.3.1",
|
||||
"invariant": "^2.2.2",
|
||||
|
@ -62,13 +62,13 @@
|
||||
"react": "^16.6.3",
|
||||
"react-localization": "^1.0.10",
|
||||
"react-native": "^0.57.8",
|
||||
"react-native-camera": "^1.6.1",
|
||||
"react-native-camera": "^1.6.3",
|
||||
"react-native-custom-qr-codes": "^1.0.2",
|
||||
"react-native-device-info": "^0.24.3",
|
||||
"react-native-elements": "^0.19.0",
|
||||
"react-native-flexi-radio-button": "^0.2.2",
|
||||
"react-native-fs": "^2.12.1",
|
||||
"react-native-gesture-handler": "^1.0.11",
|
||||
"react-native-gesture-handler": "^1.0.12",
|
||||
"react-native-google-analytics-bridge": "^6.1.2",
|
||||
"react-native-haptic-feedback": "^1.4.2",
|
||||
"react-native-level-fs": "^3.0.1",
|
||||
|
@ -462,11 +462,14 @@ export default class SendDetails extends Component {
|
||||
{' ' + BitcoinUnit.BTC}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}>
|
||||
<Text style={{ fontSize: 18, color: '#d4d4d4', fontWeight: '600' }}>
|
||||
{currency.satoshiToLocalCurrency(loc.formatBalanceWithoutSuffix(this.state.amount || 0, BitcoinUnit.SATOSHIS))}
|
||||
</Text>
|
||||
</View>
|
||||
{this.state.amount > 0 && (
|
||||
<View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}>
|
||||
<Text style={{ fontSize: 18, color: '#d4d4d4', fontWeight: '600' }}>
|
||||
{currency.satoshiToLocalCurrency(loc.formatBalanceWithoutSuffix(this.state.amount || 0, BitcoinUnit.SATS))}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<View
|
||||
style={{
|
||||
flexDirection: 'row',
|
||||
|
@ -22,7 +22,6 @@ import { BitcoinUnit } from '../../models/bitcoinUnits';
|
||||
|
||||
let BlueApp = require('../../BlueApp');
|
||||
let loc = require('../../loc');
|
||||
const BigNumber = require('bignumber.js');
|
||||
let EV = require('../../events');
|
||||
|
||||
export default class WalletTransactions extends Component {
|
||||
@ -182,8 +181,8 @@ export default class WalletTransactions extends Component {
|
||||
} else if (wallet.getPreferredBalanceUnit() === BitcoinUnit.LOCAL_CURRENCY) {
|
||||
wallet.setPreferredBalanceUnit(BitcoinUnit.BTC);
|
||||
}
|
||||
this.setState({ wallet: wallet }, async () => {
|
||||
await BlueApp.saveToDisk();
|
||||
this.setState({ wallet: wallet }, () => {
|
||||
BlueApp.saveToDisk();
|
||||
});
|
||||
}
|
||||
|
||||
@ -439,7 +438,7 @@ export default class WalletTransactions extends Component {
|
||||
}}
|
||||
hideChevron
|
||||
rightTitle={loc.formatBalanceWithoutSuffix(
|
||||
new BigNumber((rowData.item.value && rowData.item.value) || 0).dividedBy(100000000),
|
||||
(rowData.item.value && rowData.item.value) || 0,
|
||||
this.state.wallet.getPreferredBalanceUnit(),
|
||||
)}
|
||||
rightTitleStyle={{
|
||||
|
Loading…
Reference in New Issue
Block a user