fix(i18n): properly format floating point numbers

- the percentage/changes were left untreated
This commit is contained in:
Lukáš Tinkl 2023-02-17 17:51:34 +01:00 committed by Lukáš Tinkl
parent a23726ffa1
commit b8f6cbcfa1
2 changed files with 17 additions and 20 deletions

View File

@ -20,7 +20,7 @@ import shared.stores 1.0
Item {
id: root
property var token: {}
property var token: ({})
/*required*/ property string address: ""
QtObject {
@ -290,31 +290,31 @@ Item {
Layout.fillWidth: true
}
InformationTile {
readonly property string changePctHour: token ? token.changePctHour.toFixed(2) : ""
readonly property double changePctHour: token ? token.changePctHour : 0
maxWidth: parent.width
primaryText: qsTr("Hour")
secondaryText: changePctHour ? "%1%".arg(changePctHour) : "---"
secondaryLabel.color: Math.sign(Number(changePctHour)) === 0 ? Theme.palette.directColor1 :
Math.sign(Number(changePctHour)) === -1 ? Theme.palette.dangerColor1 :
Theme.palette.successColor1
secondaryText: changePctHour ? "%1%".arg(LocaleUtils.numberToLocaleString(changePctHour, 2)) : "---"
secondaryLabel.color: Math.sign(changePctHour) === 0 ? Theme.palette.directColor1 :
Math.sign(changePctHour) === -1 ? Theme.palette.dangerColor1 :
Theme.palette.successColor1
}
InformationTile {
readonly property string changePctDay: token ? token.changePctDay.toFixed(2) : ""
readonly property double changePctDay: token ? token.changePctDay : 0
maxWidth: parent.width
primaryText: qsTr("Day")
secondaryText: changePctDay ? "%1%".arg(changePctDay) : "---"
secondaryLabel.color: Math.sign(Number(changePctDay)) === 0 ? Theme.palette.directColor1 :
Math.sign(Number(changePctDay)) === -1 ? Theme.palette.dangerColor1 :
Theme.palette.successColor1
secondaryText: changePctDay ? "%1%".arg(LocaleUtils.numberToLocaleString(changePctDay, 2)) : "---"
secondaryLabel.color: Math.sign(changePctDay) === 0 ? Theme.palette.directColor1 :
Math.sign(changePctDay) === -1 ? Theme.palette.dangerColor1 :
Theme.palette.successColor1
}
InformationTile {
readonly property string changePct24hour: token ? token.changePct24hour.toFixed(2) : ""
readonly property double changePct24hour: token ? token.changePct24hour : 0
maxWidth: parent.width
primaryText: qsTr("24 Hours")
secondaryText: changePct24hour ? "%1%".arg(changePct24hour) : "---"
secondaryLabel.color: Math.sign(Number(changePct24hour)) === 0 ? Theme.palette.directColor1 :
Math.sign(Number(changePct24hour)) === -1 ? Theme.palette.dangerColor1 :
Theme.palette.successColor1
secondaryText: changePct24hour ? "%1%".arg(LocaleUtils.numberToLocaleString(changePct24hour, 2)) : "---"
secondaryLabel.color: Math.sign(changePct24hour) === 0 ? Theme.palette.directColor1 :
Math.sign(changePct24hour) === -1 ? Theme.palette.dangerColor1 :
Theme.palette.successColor1
}
}

View File

@ -34,7 +34,6 @@ StatusListItem {
id: localeCurrencyBalance
anchors.right: parent.right
font.pixelSize: 15
font.strikeout: false
text: LocaleUtils.currencyAmountToLocaleString(enabledNetworkCurrencyBalance)
}
Row {
@ -43,7 +42,6 @@ StatusListItem {
StatusTextWithLoadingState {
id: change24HourText
font.pixelSize: 15
font.strikeout: false
customColor: root.textColor
text: LocaleUtils.currencyAmountToLocaleString(currencyPrice)
}
@ -55,9 +53,8 @@ StatusListItem {
StatusTextWithLoadingState {
id: change24HourPercentageText
font.pixelSize: 15
font.strikeout: false
customColor: root.textColor
text: changePct24hour !== "" ? changePct24hour.toFixed(2) + "%" : "---"
text: changePct24hour !== "" ? "%1%".arg(LocaleUtils.numberToLocaleString(changePct24hour, 2)) : "---"
}
}
}