Transfer: convert and display entered amount in fiat currency

This commit is contained in:
xiphon 2019-11-13 08:02:19 +00:00
parent 7f7a39292c
commit e9cdaf4dbe
4 changed files with 28 additions and 7 deletions

View File

@ -238,7 +238,7 @@ Rectangle {
font.pixelSize: 16
text: {
if (persistentSettings.fiatPriceEnabled && persistentSettings.fiatPriceToggle) {
return persistentSettings.fiatPriceCurrency == "xmrusd" ? "USD" : "EUR"
return appWindow.fiatApiCurrencySymbol();
} else {
return "XMR"
}

View File

@ -53,6 +53,8 @@ Item {
property alias inlineButtonText: inlineButtonId.text
property alias inlineIcon: inlineIcon.visible
property bool copyButton: false
property alias copyButtonText: copyButtonId.text
property alias copyButtonEnabled: copyButtonId.enabled
property bool borderDisabled: false
property string borderColor: {

View File

@ -1241,17 +1241,32 @@ ApplicationWindow {
Prices.getJSON(url);
}
function fiatApiUpdateBalance(balance){
// update balance card
function fiatApiCurrencySymbol() {
switch (persistentSettings.fiatPriceCurrency) {
case "xmrusd":
return "USD";
case "xmreur":
return "EUR";
default:
console.error("unsupported currency", persistentSettings.fiatPriceCurrency);
return "UNSUPPORTED";
}
}
function fiatApiConvertToFiat(amount) {
var ticker = persistentSettings.fiatPriceCurrency === "xmrusd" ? appWindow.fiatPriceXMRUSD : appWindow.fiatPriceXMREUR;
if(ticker <= 0){
console.log(fiatApiError("Could not update balance card; invalid ticker value"));
leftPanel.balanceFiatString = "?.??";
return;
console.log(fiatApiError("Invalid ticker value: " + ticker));
return "?.??";
}
return (amount * ticker).toFixed(2);
}
function fiatApiUpdateBalance(balance){
// update balance card
var bFiat = "?.??"
if (!hideBalanceForced && !persistentSettings.hideBalance) {
bFiat = (balance * ticker).toFixed(2);
bFiat = fiatApiConvertToFiat(balance);
}
leftPanel.balanceFiatString = bFiat;
}

View File

@ -168,6 +168,10 @@ Rectangle {
labelText: qsTr("<style type='text/css'>a {text-decoration: none; color: #858585; font-size: 14px;}</style>\
Amount <font size='2'> ( </font> <a href='#'>Change account</a><font size='2'> )</font>")
+ translationManager.emptyString
copyButton: persistentSettings.fiatPriceEnabled
copyButtonText: fiatApiCurrencySymbol() + " ~" + fiatApiConvertToFiat(amountLine.text)
copyButtonEnabled: false
onLabelLinkActivated: {
middlePanel.accountView.selectAndSend = true;
appWindow.showPageRequest("Account")