2021-10-05 20:50:22 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Core 0.1
|
2022-08-24 15:47:26 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-08-08 21:12:12 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
2022-07-13 12:29:38 +00:00
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../stores"
|
|
|
|
|
|
|
|
Item {
|
2022-08-08 21:12:12 +00:00
|
|
|
id: root
|
|
|
|
|
2022-03-25 08:46:47 +00:00
|
|
|
property var account
|
2022-08-08 21:12:12 +00:00
|
|
|
property bool assetDetailsLaunched: false
|
|
|
|
|
|
|
|
signal assetClicked(var token)
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
readonly property var alwaysVisible : ["ETH", "SNT", "DAI", "STT"]
|
|
|
|
property int selectedAssetIndex: -1
|
|
|
|
}
|
2022-03-25 08:46:47 +00:00
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
height: assetListView.height
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
|
|
|
id: assetListView
|
2022-08-08 10:07:29 +00:00
|
|
|
objectName: "assetViewStatusListView"
|
2022-08-08 21:12:12 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: account.assets
|
|
|
|
filters: [
|
|
|
|
ExpressionFilter {
|
|
|
|
expression: d.alwaysVisible.includes(symbol) || (networkVisible && enabledNetworkBalance > 0)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2022-08-24 15:47:26 +00:00
|
|
|
|
2022-08-08 21:12:12 +00:00
|
|
|
delegate: StatusListItem {
|
2022-08-18 17:51:18 +00:00
|
|
|
readonly property string balance: enabledNetworkBalance // Needed for the tests
|
2022-08-25 18:17:54 +00:00
|
|
|
objectName: "AssetView_TokenListItem_" + symbol
|
2022-08-08 21:12:12 +00:00
|
|
|
width: parent.width
|
|
|
|
title: name
|
2022-09-15 07:49:15 +00:00
|
|
|
subTitle: `${enabledNetworkBalance} ${symbol}`
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.name: symbol ? Style.png("tokens/" + symbol) : ""
|
|
|
|
asset.isImage: true
|
2022-08-08 21:12:12 +00:00
|
|
|
components: [
|
2022-08-24 15:47:26 +00:00
|
|
|
Column {
|
|
|
|
id: valueColumn
|
|
|
|
property string textColor: Math.sign(Number(changePct24hour)) === 0 ? Theme.palette.baseColor1 :
|
|
|
|
Math.sign(Number(changePct24hour)) === -1 ? Theme.palette.dangerColor1 :
|
|
|
|
Theme.palette.successColor1
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.right: parent.right
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.strikeout: false
|
|
|
|
text: enabledNetworkCurrencyBalance.toLocaleCurrencyString(Qt.locale(), RootStore.currencyStore.currentCurrencySymbol)
|
|
|
|
}
|
|
|
|
Row {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
spacing: 8
|
|
|
|
StatusBaseText {
|
|
|
|
id: change24HourText
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.strikeout: false
|
|
|
|
color: valueColumn.textColor
|
2022-09-09 08:13:04 +00:00
|
|
|
text: currencyPrice.toLocaleCurrencyString(Qt.locale(), RootStore.currencyStore.currentCurrencySymbol)
|
2022-08-24 15:47:26 +00:00
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
width: 1
|
|
|
|
height: change24HourText.implicitHeight
|
|
|
|
color: Theme.palette.directColor9
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.strikeout: false
|
|
|
|
color: valueColumn.textColor
|
|
|
|
text: changePct24hour !== "" ? "%1%".arg(changePct24hour) : "---"
|
|
|
|
}
|
|
|
|
}
|
2022-08-08 21:12:12 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
onClicked: {
|
2022-09-27 08:30:18 +00:00
|
|
|
RootStore.getHistoricalDataForToken(symbol, RootStore.currencyStore.currentCurrency)
|
2022-08-08 21:12:12 +00:00
|
|
|
d.selectedAssetIndex = index
|
|
|
|
assetClicked(model)
|
|
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
|
|
// on Model reset if the detail view is shown, update the data in background.
|
|
|
|
if(root.assetDetailsLaunched && index === d.selectedAssetIndex)
|
|
|
|
assetClicked(model)
|
|
|
|
}
|
2022-07-14 11:03:36 +00:00
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
}
|