2022-12-16 08:50:56 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
|
2023-11-28 19:16:18 +00:00
|
|
|
import StatusQ 0.1
|
2023-01-12 22:39:46 +00:00
|
|
|
import StatusQ.Core 0.1
|
2022-12-16 08:50:56 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-11-28 19:16:18 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
|
|
|
import SortFilterProxyModel 0.2
|
2022-12-16 08:50:56 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
StatusListItem {
|
|
|
|
id: root
|
|
|
|
|
2024-04-05 12:56:15 +00:00
|
|
|
objectName: "tokenBalancePerChainDelegate"
|
|
|
|
|
2022-12-16 08:50:56 +00:00
|
|
|
signal tokenSelected(var selectedToken)
|
2023-04-18 16:05:24 +00:00
|
|
|
signal tokenHovered(var selectedToken, bool hovered)
|
2024-01-30 13:15:58 +00:00
|
|
|
property var formatCurrentCurrencyAmount: function(balance){}
|
|
|
|
property var formatCurrencyAmountFromBigInt: function(balance, symbol, decimals){}
|
2023-11-28 19:16:18 +00:00
|
|
|
property var balancesModel
|
2022-12-16 08:50:56 +00:00
|
|
|
|
2023-05-10 13:04:27 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
function selectToken() {
|
2023-11-28 19:16:18 +00:00
|
|
|
root.tokenSelected({name, symbol, balances, decimals})
|
|
|
|
}
|
2023-05-10 13:04:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.sensor
|
|
|
|
function onContainsMouseChanged() {
|
2023-11-28 19:16:18 +00:00
|
|
|
root.tokenHovered({name, symbol, balances, decimals},
|
2023-09-15 08:51:06 +00:00
|
|
|
root.sensor.containsMouse)
|
2023-05-10 13:04:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-16 08:50:56 +00:00
|
|
|
title: name
|
2024-03-27 16:18:45 +00:00
|
|
|
titleAsideText: symbol ?? ""
|
2023-04-18 16:05:24 +00:00
|
|
|
statusListItemTitleAside.font.pixelSize: 15
|
2023-10-03 21:10:02 +00:00
|
|
|
statusListItemTitleAside.width: statusListItemTitleArea.width - statusListItemTitle.width
|
|
|
|
statusListItemTitleAside.elide: Text.ElideRight
|
2023-11-28 19:16:18 +00:00
|
|
|
label: {
|
2024-01-30 13:15:58 +00:00
|
|
|
let balance = !!model && !!model.currentCurrencyBalance ? model.currentCurrencyBalance : 0
|
|
|
|
return root.formatCurrentCurrencyAmount(balance)
|
2023-11-28 19:16:18 +00:00
|
|
|
}
|
2024-03-28 17:49:14 +00:00
|
|
|
// Community assets have a dedicated image streamed from status-go
|
2024-04-04 14:41:43 +00:00
|
|
|
asset.name: !!model && !!model.image
|
2024-03-28 17:49:14 +00:00
|
|
|
? model.image
|
|
|
|
: Constants.tokenIcon(symbol)
|
2022-12-16 08:50:56 +00:00
|
|
|
asset.isImage: true
|
|
|
|
asset.width: 32
|
|
|
|
asset.height: 32
|
2023-04-18 16:05:24 +00:00
|
|
|
statusListItemLabel.anchors.verticalCenterOffset: -12
|
2022-12-16 08:50:56 +00:00
|
|
|
statusListItemLabel.color: Theme.palette.directColor1
|
2023-05-10 13:04:27 +00:00
|
|
|
statusListItemInlineTagsSlot.spacing: 0
|
2024-01-30 13:15:58 +00:00
|
|
|
tagsModel: root.balancesModel
|
2023-05-10 13:04:27 +00:00
|
|
|
tagsDelegate: expandedItem
|
2024-05-28 17:39:41 +00:00
|
|
|
tagsScrollBarVisible: false
|
2023-04-18 16:05:24 +00:00
|
|
|
|
2024-05-28 17:39:41 +00:00
|
|
|
radius: sensor.containsMouse || highlighted ? 0 : 8
|
|
|
|
color: sensor.containsMouse || highlighted ? Theme.palette.statusListItem.highlightColor : "transparent"
|
2023-02-02 15:28:39 +00:00
|
|
|
|
2023-05-10 13:04:27 +00:00
|
|
|
onClicked: d.selectToken()
|
2022-12-16 08:50:56 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: expandedItem
|
|
|
|
StatusListItemTag {
|
|
|
|
height: 16
|
2023-09-28 20:15:30 +00:00
|
|
|
leftPadding: 0
|
2024-01-30 13:15:58 +00:00
|
|
|
title: root.formatCurrencyAmountFromBigInt(balance, symbol, decimals)
|
2022-12-16 08:50:56 +00:00
|
|
|
titleText.font.pixelSize: 12
|
|
|
|
closeButtonVisible: false
|
|
|
|
bgColor: "transparent"
|
|
|
|
asset.width: 16
|
|
|
|
asset.height: 16
|
|
|
|
asset.isImage: true
|
2024-05-28 17:39:41 +00:00
|
|
|
asset.name: Style.svg("tiny/%1".arg(model.iconUrl))
|
|
|
|
tagClickable: true
|
|
|
|
onTagClicked: d.selectToken()
|
2022-12-16 08:50:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|