2021-10-05 22:50:22 +02:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
2022-07-13 15:29:38 +03:00
|
|
|
import StatusQ.Core 0.1
|
2022-08-24 17:47:26 +02:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-08-08 23:12:12 +02:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
2022-07-13 15:29:38 +03:00
|
|
|
|
2021-10-05 22:50:22 +02:00
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../stores"
|
2022-11-23 18:58:22 +01:00
|
|
|
import shared.controls 1.0
|
2021-10-05 22:50:22 +02:00
|
|
|
|
|
|
|
Item {
|
2022-08-08 23:12:12 +02:00
|
|
|
id: root
|
|
|
|
|
2023-04-25 18:54:50 +02:00
|
|
|
property var assets
|
2023-03-15 10:17:25 +01:00
|
|
|
property var networkConnectionStore
|
2022-08-08 23:12:12 +02:00
|
|
|
property bool assetDetailsLaunched: false
|
|
|
|
|
|
|
|
signal assetClicked(var token)
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
property int selectedAssetIndex: -1
|
|
|
|
}
|
2022-03-25 09:46:47 +01:00
|
|
|
|
2021-10-05 22:50:22 +02:00
|
|
|
height: assetListView.height
|
|
|
|
|
2022-07-14 14:03:36 +03:00
|
|
|
StatusListView {
|
|
|
|
id: assetListView
|
2022-08-08 12:07:29 +02:00
|
|
|
objectName: "assetViewStatusListView"
|
2022-08-08 23:12:12 +02:00
|
|
|
anchors.fill: parent
|
2023-03-22 23:08:36 +01:00
|
|
|
model: filteredModel
|
2023-08-04 10:41:45 +02:00
|
|
|
reuseItems: true
|
2023-03-22 23:08:36 +01:00
|
|
|
delegate: delegateLoader
|
2023-01-10 14:04:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
id: filteredModel
|
2023-05-23 14:46:16 +02:00
|
|
|
sourceModel: !!assets ? assets : null
|
2023-01-10 14:04:23 +01:00
|
|
|
filters: [
|
|
|
|
ExpressionFilter {
|
2023-03-22 23:08:36 +01:00
|
|
|
expression: visibleForNetworkWithPositiveBalance || loading
|
2023-01-10 14:04:23 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2023-03-22 23:08:36 +01:00
|
|
|
Component {
|
|
|
|
id: delegateLoader
|
2023-08-04 10:41:45 +02:00
|
|
|
Loader {
|
2023-03-22 23:08:36 +01:00
|
|
|
property var modelData: model
|
|
|
|
property int index: index
|
|
|
|
width: ListView.view.width
|
|
|
|
sourceComponent: loading ? loadingTokenDelegate: tokenDelegate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-10 14:04:23 +01:00
|
|
|
Component {
|
|
|
|
id: loadingTokenDelegate
|
|
|
|
LoadingTokenDelegate {
|
2023-03-15 10:17:25 +01:00
|
|
|
objectName: "AssetView_LoadingTokenDelegate_" + index
|
2022-08-08 23:12:12 +02:00
|
|
|
}
|
2023-01-10 14:04:23 +01:00
|
|
|
}
|
2022-08-24 17:47:26 +02:00
|
|
|
|
2023-01-10 14:04:23 +01:00
|
|
|
Component {
|
|
|
|
id: tokenDelegate
|
|
|
|
TokenDelegate {
|
2023-05-23 14:46:16 +02:00
|
|
|
objectName: "AssetView_TokenListItem_" + (!!modelData ? modelData.symbol : "")
|
|
|
|
readonly property string balance: !!modelData ? "%1".arg(modelData.enabledNetworkBalance.amount) : "" // Needed for the tests
|
|
|
|
errorTooltipText_1: !!modelData && !! networkConnectionStore ? networkConnectionStore.getBlockchainNetworkDownTextForToken(modelData.balances) : ""
|
|
|
|
errorTooltipText_2: !!networkConnectionStore ? networkConnectionStore.getMarketNetworkDownText() : ""
|
2023-06-06 08:13:22 +02:00
|
|
|
subTitle: {
|
|
|
|
if (!modelData) {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
if (networkConnectionStore && networkConnectionStore.noTokenBalanceAvailable) {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return LocaleUtils.currencyAmountToLocaleString(modelData.enabledNetworkBalance)
|
|
|
|
|
|
|
|
}
|
2023-05-23 14:46:16 +02:00
|
|
|
errorMode: !!networkConnectionStore ? networkConnectionStore.noBlockchainConnectionAndNoCache && !networkConnectionStore.noMarketConnectionAndNoCache : false
|
|
|
|
errorIcon.tooltip.text: !!networkConnectionStore ? networkConnectionStore.noBlockchainConnectionAndNoCacheText : ""
|
2022-08-08 23:12:12 +02:00
|
|
|
onClicked: {
|
2023-03-22 23:08:36 +01:00
|
|
|
RootStore.getHistoricalDataForToken(modelData.symbol, RootStore.currencyStore.currentCurrency)
|
2022-08-08 23:12:12 +02:00
|
|
|
d.selectedAssetIndex = index
|
2023-03-22 23:08:36 +01:00
|
|
|
assetClicked(modelData)
|
2022-08-08 23:12:12 +02:00
|
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
|
|
// on Model reset if the detail view is shown, update the data in background.
|
|
|
|
if(root.assetDetailsLaunched && index === d.selectedAssetIndex)
|
2023-03-22 23:08:36 +01:00
|
|
|
assetClicked(modelData)
|
2022-08-08 23:12:12 +02:00
|
|
|
}
|
2022-07-14 14:03:36 +03:00
|
|
|
}
|
2021-10-05 22:50:22 +02:00
|
|
|
}
|
|
|
|
}
|