2024-06-12 20:43:08 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
ItemDelegate {
|
|
|
|
id: root
|
|
|
|
|
2024-09-24 09:18:09 +00:00
|
|
|
objectName: "tokenSelectorAssetDelegate_" + name
|
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
required property string name
|
|
|
|
required property string symbol
|
|
|
|
required property string currencyBalanceAsString
|
2024-06-25 13:37:42 +00:00
|
|
|
required property string iconSource
|
2024-06-12 20:43:08 +00:00
|
|
|
|
2024-09-18 11:03:36 +00:00
|
|
|
// expected structure: [iconUrl: string, balanceAsString: string]
|
|
|
|
property alias balancesModel: balancesListView.model
|
2024-06-12 20:43:08 +00:00
|
|
|
|
2024-09-18 11:03:36 +00:00
|
|
|
property alias balancesListInteractive: balancesListView.interactive
|
2024-06-12 20:43:08 +00:00
|
|
|
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding
|
|
|
|
horizontalPadding: Theme.padding
|
2024-06-12 20:43:08 +00:00
|
|
|
verticalPadding: 4
|
|
|
|
|
2024-09-18 11:03:36 +00:00
|
|
|
opacity: enabled ? 1 : 0.3
|
2024-06-12 20:43:08 +00:00
|
|
|
implicitHeight: 60
|
|
|
|
|
|
|
|
icon.width: 32
|
|
|
|
icon.height: 32
|
2024-06-25 13:37:42 +00:00
|
|
|
icon.source: iconSource
|
2024-06-12 20:43:08 +00:00
|
|
|
|
|
|
|
background: Rectangle {
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.radius
|
2024-09-18 11:03:36 +00:00
|
|
|
color: root.hovered || root.highlighted
|
|
|
|
? Theme.palette.statusListItem.highlightColor
|
|
|
|
: "transparent"
|
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
HoverHandler {
|
2024-09-18 11:03:36 +00:00
|
|
|
cursorShape: root.enabled ? Qt.PointingHandCursor : undefined
|
2024-06-12 20:43:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: RowLayout {
|
|
|
|
spacing: root.spacing
|
|
|
|
|
|
|
|
// asset icon
|
|
|
|
StatusRoundedImage {
|
|
|
|
Layout.preferredWidth: root.icon.width
|
|
|
|
Layout.preferredHeight: root.icon.height
|
|
|
|
image.source: root.icon.source
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
// name, symbol, total balance
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: root.spacing
|
2024-09-18 11:03:36 +00:00
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: childrenRect.height
|
2024-09-18 11:03:36 +00:00
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: nameText
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2024-09-18 11:03:36 +00:00
|
|
|
width: Math.min(implicitWidth, parent.width - symbolText.width
|
|
|
|
- symbolText.anchors.leftMargin)
|
2024-06-12 20:43:08 +00:00
|
|
|
text: root.name
|
|
|
|
font.weight: Font.Medium
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
2024-09-18 11:03:36 +00:00
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: symbolText
|
|
|
|
anchors.left: nameText.right
|
|
|
|
anchors.leftMargin: 6
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
text: root.symbol
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
}
|
2024-09-18 11:03:36 +00:00
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
StatusBaseText {
|
|
|
|
font.weight: Font.Medium
|
|
|
|
text: root.currencyBalanceAsString
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-18 11:03:36 +00:00
|
|
|
// balances per chain
|
2024-06-12 20:43:08 +00:00
|
|
|
StatusListView {
|
2024-09-18 11:03:36 +00:00
|
|
|
id: balancesListView
|
|
|
|
|
|
|
|
objectName: "balancesListView"
|
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
Layout.preferredWidth: contentWidth
|
|
|
|
Layout.preferredHeight: 22
|
2024-09-18 11:03:36 +00:00
|
|
|
|
|
|
|
ScrollBar.horizontal: null
|
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
orientation: ListView.Horizontal
|
|
|
|
spacing: root.spacing
|
|
|
|
visible: count
|
2024-09-18 11:03:36 +00:00
|
|
|
interactive: root.balancesListInteractive
|
2024-06-12 20:43:08 +00:00
|
|
|
|
|
|
|
delegate: RowLayout {
|
|
|
|
height: ListView.view.height
|
|
|
|
spacing: 4
|
2024-09-18 11:03:36 +00:00
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
StatusRoundedImage {
|
|
|
|
Layout.preferredWidth: 16
|
|
|
|
Layout.preferredHeight: 16
|
2024-10-15 19:26:12 +00:00
|
|
|
image.source: Theme.svg("tiny/%1".arg(model.iconUrl))
|
2024-06-12 20:43:08 +00:00
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize
|
|
|
|
text: model.balanceAsString
|
|
|
|
}
|
|
|
|
}
|
2024-09-18 11:03:36 +00:00
|
|
|
|
2024-06-12 20:43:08 +00:00
|
|
|
// let the root handle the click
|
|
|
|
TapHandler {
|
|
|
|
onTapped: root.clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|