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"
|
2022-11-23 17:58:22 +00:00
|
|
|
import shared.controls 1.0
|
2021-10-05 20:50:22 +00:00
|
|
|
|
|
|
|
Item {
|
2022-08-08 21:12:12 +00:00
|
|
|
id: root
|
|
|
|
|
2022-03-25 08:46:47 +00:00
|
|
|
property var account
|
2023-03-15 09:17:25 +00:00
|
|
|
property var networkConnectionStore
|
2022-08-08 21:12:12 +00:00
|
|
|
property bool assetDetailsLaunched: false
|
|
|
|
|
|
|
|
signal assetClicked(var token)
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
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
|
2023-03-22 22:08:36 +00:00
|
|
|
model: filteredModel
|
|
|
|
delegate: delegateLoader
|
2023-01-10 13:04:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
id: filteredModel
|
|
|
|
sourceModel: account.assets
|
|
|
|
filters: [
|
|
|
|
ExpressionFilter {
|
2023-03-22 22:08:36 +00:00
|
|
|
expression: visibleForNetworkWithPositiveBalance || loading
|
2023-01-10 13:04:23 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2023-03-22 22:08:36 +00:00
|
|
|
Component {
|
|
|
|
id: delegateLoader
|
|
|
|
Loader {
|
|
|
|
property var modelData: model
|
|
|
|
property int index: index
|
|
|
|
width: ListView.view.width
|
|
|
|
sourceComponent: loading ? loadingTokenDelegate: tokenDelegate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-10 13:04:23 +00:00
|
|
|
Component {
|
|
|
|
id: loadingTokenDelegate
|
|
|
|
LoadingTokenDelegate {
|
2023-03-15 09:17:25 +00:00
|
|
|
objectName: "AssetView_LoadingTokenDelegate_" + index
|
2022-08-08 21:12:12 +00:00
|
|
|
}
|
2023-01-10 13:04:23 +00:00
|
|
|
}
|
2022-08-24 15:47:26 +00:00
|
|
|
|
2023-01-10 13:04:23 +00:00
|
|
|
Component {
|
|
|
|
id: tokenDelegate
|
|
|
|
TokenDelegate {
|
2023-03-22 22:08:36 +00:00
|
|
|
objectName: "AssetView_TokenListItem_" + modelData.symbol
|
|
|
|
readonly property string balance: "%1".arg(modelData.enabledNetworkBalance.amount) // Needed for the tests
|
|
|
|
errorTooltipText_1: networkConnectionStore.getBlockchainNetworkDownTextForToken(modelData.balances)
|
2023-03-15 09:17:25 +00:00
|
|
|
errorTooltipText_2: networkConnectionStore.getMarketNetworkDownText()
|
2023-03-23 10:23:02 +00:00
|
|
|
subTitle: networkConnectionStore.noTokenBalanceAvailable ? "" : LocaleUtils.currencyAmountToLocaleString(modelData.enabledNetworkBalance)
|
|
|
|
errorMode: networkConnectionStore.noBlockchainConnectionAndNoCache && !networkConnectionStore.noMarketConnectionAndNoCache
|
|
|
|
errorIcon.tooltip.text: networkConnectionStore.noBlockchainConnectionAndNoCacheText
|
2022-08-08 21:12:12 +00:00
|
|
|
onClicked: {
|
2023-03-22 22:08:36 +00:00
|
|
|
RootStore.getHistoricalDataForToken(modelData.symbol, RootStore.currencyStore.currentCurrency)
|
2022-08-08 21:12:12 +00:00
|
|
|
d.selectedAssetIndex = index
|
2023-03-22 22:08:36 +00:00
|
|
|
assetClicked(modelData)
|
2022-08-08 21:12:12 +00: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 22:08:36 +00:00
|
|
|
assetClicked(modelData)
|
2022-08-08 21:12:12 +00:00
|
|
|
}
|
2022-07-14 11:03:36 +00:00
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
}
|