mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-21 11:59:28 +00:00
a12a6a4894
TLDR: later this should form a basic building block for a new TokenSelector picker component, potentially replacing the current HoldingSelector* and TokenListView components (support for collectibles TBD as part of https://github.com/status-im/status-desktop/issues/15121) - create reusable `TokenSelectorAssetDelegate` and `TokenSelectorView` - add corresponding SB page, showcasing the flow/integration and the separation of concerns between the view, adaptor and delegate layers - add QML testcase for TokenSelectorView - don't display crypto symbol for token balances per chain tags - update the stores and SB pages - add some missing formatter functions to LocaleUtils and CurrenciesStore Fixes #14716
48 lines
1.5 KiB
QML
48 lines
1.5 KiB
QML
import QtQuick 2.15
|
|
|
|
import StatusQ.Core 0.1
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
|
|
|
QtObject {
|
|
id: root
|
|
|
|
readonly property string currentCurrency: "USD"
|
|
property string currentCurrencySymbol: "$"
|
|
|
|
function formatCurrencyAmount(amount, symbol, options = null, locale = null) {
|
|
if (isNaN(amount)) {
|
|
return "N/A"
|
|
}
|
|
var currencyAmount = getCurrencyAmount(amount, symbol)
|
|
return LocaleUtils.currencyAmountToLocaleString(currencyAmount, options, locale)
|
|
}
|
|
|
|
function formatCurrencyAmountFromBigInt(balance, symbol, decimals, options = null) {
|
|
let bigIntBalance = SQUtils.AmountsArithmetic.fromString(balance)
|
|
let decimalBalance = SQUtils.AmountsArithmetic.toNumber(bigIntBalance, decimals)
|
|
return formatCurrencyAmount(decimalBalance, symbol, options)
|
|
}
|
|
|
|
function getFiatValue(balance, cryptoSymbol) {
|
|
return balance
|
|
}
|
|
|
|
function getCurrencyAmount(amount, symbol) {
|
|
return ({
|
|
amount: amount,
|
|
symbol: symbol ? symbol.toUpperCase() : root.currentCurrency,
|
|
displayDecimals: 2,
|
|
stripTrailingZeroes: false
|
|
})
|
|
}
|
|
|
|
function getCurrentCurrencyAmount(amount) {
|
|
return ({
|
|
amount: amount,
|
|
symbol: root.currentCurrency,
|
|
displayDecimals: 2,
|
|
stripTrailingZeroes: false
|
|
})
|
|
}
|
|
}
|