fix(@wallet): fix amount input send modal

fixes #9207
This commit is contained in:
Anthony Laibe 2023-01-27 10:41:18 +01:00 committed by Anthony Laibe
parent 289005c0e6
commit 64d6c484b2
2 changed files with 13 additions and 4 deletions

View File

@ -29,8 +29,11 @@ QtObject {
function numberFromLocaleString(num, locale = null) { function numberFromLocaleString(num, locale = null) {
locale = locale || Qt.locale() locale = locale || Qt.locale()
try {
return Number.fromLocaleString(locale, num) return Number.fromLocaleString(locale, num)
} catch (_) {
return parseFloat(num)
}
} }
function currencyAmountToLocaleString(currencyAmount, options = null, locale = null) { function currencyAmountToLocaleString(currencyAmount, options = null, locale = null) {

View File

@ -23,14 +23,20 @@ ColumnLayout {
Binding { Binding {
target: root target: root
property: "cryptoValueToSend" property: "cryptoValueToSend"
value: root.selectedAsset, !inputIsFiat ? getCryptoCurrencyAmount(LocaleUtils.numberFromLocaleString(topAmountToSendInput.text)) : getCryptoValue(fiatValueToSend ? fiatValueToSend.amount : 0.0) value: {
const value = !inputIsFiat ? getCryptoCurrencyAmount(LocaleUtils.numberFromLocaleString(topAmountToSendInput.text)) : getCryptoValue(fiatValueToSend ? fiatValueToSend.amount : 0.0)
return root.selectedAsset, value
}
delayed: true delayed: true
} }
property var fiatValueToSend property var fiatValueToSend
Binding { Binding {
target: root target: root
property: "fiatValueToSend" property: "fiatValueToSend"
value: root.selectedAsset, inputIsFiat ? getFiatCurrencyAmount(LocaleUtils.numberFromLocaleString(topAmountToSendInput.text)) : getFiatValue(cryptoValueToSend ? cryptoValueToSend.amount : 0.0) value: {
const value = inputIsFiat ? getFiatCurrencyAmount(LocaleUtils.numberFromLocaleString(topAmountToSendInput.text)) : getFiatValue(cryptoValueToSend ? cryptoValueToSend.amount : 0.0)
return root.selectedAsset, value
}
delayed: true delayed: true
} }
property string currentCurrency property string currentCurrency