2022-12-16 08:50:56 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
|
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
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
StatusListItem {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var getNetworkIcon: function(chainId){
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
signal tokenSelected(var selectedToken)
|
2023-04-18 16:05:24 +00:00
|
|
|
signal tokenHovered(var selectedToken, bool hovered)
|
2022-12-16 08:50:56 +00:00
|
|
|
|
2023-05-10 13:04:27 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2023-09-15 08:51:06 +00:00
|
|
|
readonly property int indexesThatCanBeShown:
|
|
|
|
Math.floor((root.statusListItemInlineTagsSlot.availableWidth
|
|
|
|
- compactRow.width) / statusListItemInlineTagsSlot.children[0].width) - 1
|
2023-05-10 13:04:27 +00:00
|
|
|
|
|
|
|
function selectToken() {
|
2023-09-15 08:51:06 +00:00
|
|
|
root.tokenSelected({name, symbol, totalRawBalance, totalBalance,
|
|
|
|
totalCurrencyBalance, balances, decimals})
|
2023-05-10 13:04:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.sensor
|
|
|
|
function onContainsMouseChanged() {
|
2023-09-15 08:51:06 +00:00
|
|
|
root.tokenHovered({name, symbol, totalRawBalance, totalBalance,
|
|
|
|
totalCurrencyBalance, balances, decimals},
|
|
|
|
root.sensor.containsMouse)
|
2023-05-10 13:04:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-16 08:50:56 +00:00
|
|
|
title: name
|
2023-04-18 16:05:24 +00:00
|
|
|
titleAsideText: symbol
|
|
|
|
statusListItemTitleAside.font.pixelSize: 15
|
2023-02-28 15:10:40 +00:00
|
|
|
label: LocaleUtils.currencyAmountToLocaleString(totalCurrencyBalance)
|
2022-12-16 08:50:56 +00:00
|
|
|
asset.name: symbol ? Style.png("tokens/" + symbol) : ""
|
|
|
|
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
|
2022-12-16 08:50:56 +00:00
|
|
|
tagsModel: balances.count > 0 ? balances : []
|
2023-05-10 13:04:27 +00:00
|
|
|
tagsDelegate: expandedItem
|
|
|
|
statusListItemInlineTagsSlot.children: Row {
|
|
|
|
id: compactRow
|
|
|
|
spacing: -6
|
|
|
|
Repeater {
|
|
|
|
model: balances.count > 0 ? balances : []
|
|
|
|
delegate: compactItem
|
2023-04-18 16:05:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:04:27 +00:00
|
|
|
radius: sensor.containsMouse || root.highlighted ? 0 : 8
|
|
|
|
color: sensor.containsMouse || highlighted ? Theme.palette.baseColor2 : "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: compactItem
|
|
|
|
StatusRoundedImage {
|
|
|
|
z: index + 1
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
image.source: Style.svg("tiny/%1".arg(root.getNetworkIcon(chainId)))
|
2023-05-10 13:04:27 +00:00
|
|
|
visible: !root.sensor.containsMouse || index > d.indexesThatCanBeShown
|
2022-12-16 08:50:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: expandedItem
|
|
|
|
StatusListItemTag {
|
|
|
|
height: 16
|
2023-09-28 20:15:30 +00:00
|
|
|
leftPadding: 0
|
2023-01-08 22:23:51 +00:00
|
|
|
title: LocaleUtils.currencyAmountToLocaleString(balance)
|
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
|
|
|
|
asset.name: Style.svg("tiny/%1".arg(root.getNetworkIcon(chainId)))
|
2023-05-10 13:04:27 +00:00
|
|
|
visible: root.sensor.containsMouse && index <= d.indexesThatCanBeShown
|
2022-12-16 08:50:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|