2024-10-15 19:26:12 +00:00
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
|
import QtQuick.Layouts 1.15
|
2022-08-08 21:12:12 +00:00
|
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
import shared.controls 1.0
|
|
|
|
|
|
2023-10-30 22:18:58 +00:00
|
|
|
|
import StatusQ 0.1
|
2022-08-08 21:12:12 +00:00
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Core 0.1
|
2023-11-24 12:16:13 +00:00
|
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2022-08-08 21:12:12 +00:00
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
2022-08-08 21:12:12 +00:00
|
|
|
|
Control {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property alias primaryText: tokenName.text
|
|
|
|
|
property alias secondaryText: cryptoBalance.text
|
|
|
|
|
property alias tertiaryText: fiatBalance.text
|
2024-02-20 09:04:39 +00:00
|
|
|
|
property alias communityTag: communityTag
|
2022-08-08 21:12:12 +00:00
|
|
|
|
property var balances
|
2023-11-24 12:16:13 +00:00
|
|
|
|
property int decimals
|
2024-10-28 12:10:30 +00:00
|
|
|
|
property var networksModel
|
2023-03-15 09:17:25 +00:00
|
|
|
|
property bool isLoading: false
|
|
|
|
|
property string errorTooltipText
|
2024-02-20 09:04:39 +00:00
|
|
|
|
property string address
|
2022-08-11 11:55:08 +00:00
|
|
|
|
property StatusAssetSettings asset: StatusAssetSettings {
|
2024-02-20 09:04:39 +00:00
|
|
|
|
width: 25
|
|
|
|
|
height: 25
|
2022-08-08 21:12:12 +00:00
|
|
|
|
}
|
2022-12-29 16:44:51 +00:00
|
|
|
|
property var formatBalance: function(balance){}
|
2022-08-08 21:12:12 +00:00
|
|
|
|
|
2024-10-15 19:26:12 +00:00
|
|
|
|
topPadding: Theme.padding
|
2022-08-08 21:12:12 +00:00
|
|
|
|
|
2024-02-20 09:04:39 +00:00
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
|
id: mainLayout
|
2022-08-08 21:12:12 +00:00
|
|
|
|
spacing: 4
|
2024-02-20 09:04:39 +00:00
|
|
|
|
readonly property bool isOverflowing: parent.width - tokenNameAndIcon.width - communityAndBalances.width < 24
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
id: tokenNameAndIcon
|
|
|
|
|
Layout.fillWidth: true
|
2022-08-08 21:12:12 +00:00
|
|
|
|
spacing: 8
|
2023-03-15 09:17:25 +00:00
|
|
|
|
StatusTextWithLoadingState {
|
2022-08-08 21:12:12 +00:00
|
|
|
|
id: tokenName
|
2024-02-20 09:04:39 +00:00
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
Layout.maximumWidth: root.width-root.asset.width-8
|
|
|
|
|
font.pixelSize: 28
|
|
|
|
|
font.bold: true
|
|
|
|
|
lineHeight: 38
|
2022-08-08 21:12:12 +00:00
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
|
elide: Text.ElideRight
|
2023-03-15 09:17:25 +00:00
|
|
|
|
customColor: Theme.palette.directColor1
|
|
|
|
|
loading: root.isLoading
|
2022-08-08 21:12:12 +00:00
|
|
|
|
}
|
2024-02-20 09:04:39 +00:00
|
|
|
|
StatusSmartIdenticon {
|
|
|
|
|
Layout.preferredWidth: root.asset.width
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
asset: root.asset
|
2023-03-15 09:17:25 +00:00
|
|
|
|
loading: root.isLoading
|
2022-08-08 21:12:12 +00:00
|
|
|
|
}
|
2024-02-20 09:04:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
|
rowSpacing: Theme.halfPadding
|
|
|
|
|
columnSpacing: Theme.halfPadding
|
2024-02-20 09:04:39 +00:00
|
|
|
|
flow: mainLayout.isOverflowing ? GridLayout.TopToBottom: GridLayout.LeftToRight
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
|
spacing: Theme.halfPadding
|
2024-02-20 09:04:39 +00:00
|
|
|
|
StatusTextWithLoadingState {
|
|
|
|
|
id: cryptoBalance
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
font.pixelSize: 28
|
|
|
|
|
font.bold: true
|
|
|
|
|
lineHeight: 38
|
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
|
customColor: Theme.palette.baseColor1
|
|
|
|
|
loading: root.isLoading
|
|
|
|
|
}
|
|
|
|
|
StatusTextWithLoadingState {
|
|
|
|
|
id: fiatBalance
|
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
|
Layout.bottomMargin: 2
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
lineHeight: 22
|
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
|
customColor: Theme.palette.baseColor1
|
|
|
|
|
loading: root.isLoading
|
|
|
|
|
}
|
2022-08-08 21:12:12 +00:00
|
|
|
|
}
|
2024-02-20 09:04:39 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: filler
|
|
|
|
|
Layout.fillWidth: true
|
2022-08-08 21:12:12 +00:00
|
|
|
|
}
|
2023-11-24 12:16:13 +00:00
|
|
|
|
|
2024-02-20 09:04:39 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
id: communityAndBalances
|
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
|
spacing: Theme.halfPadding
|
2024-02-20 09:04:39 +00:00
|
|
|
|
InformationTag {
|
|
|
|
|
id: communityTag
|
|
|
|
|
}
|
|
|
|
|
Repeater {
|
|
|
|
|
id: chainRepeater
|
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2024-10-28 12:10:30 +00:00
|
|
|
|
model: root.networksModel
|
2024-02-20 09:04:39 +00:00
|
|
|
|
delegate: InformationTag {
|
|
|
|
|
readonly property double aggregatedbalance: balancesAggregator.value/(10 ** root.decimals)
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
|
id: filteredBalances
|
|
|
|
|
sourceModel: root.balances
|
|
|
|
|
filters: [
|
|
|
|
|
ValueFilter {
|
|
|
|
|
roleName: "chainId"
|
|
|
|
|
value: model.chainId
|
|
|
|
|
},
|
|
|
|
|
ValueFilter {
|
|
|
|
|
roleName: "account"
|
|
|
|
|
value: root.address.toLowerCase()
|
|
|
|
|
enabled: !!root.address
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
SumAggregator {
|
|
|
|
|
id: balancesAggregator
|
|
|
|
|
model: filteredBalances
|
|
|
|
|
roleName: "balance"
|
|
|
|
|
}
|
|
|
|
|
tagPrimaryLabel.text: root.formatBalance(aggregatedbalance)
|
|
|
|
|
tagPrimaryLabel.color: model.chainColor
|
2024-10-15 19:26:12 +00:00
|
|
|
|
asset.name: Theme.svg("tiny/%1".arg(model.iconUrl))
|
2024-02-20 09:04:39 +00:00
|
|
|
|
asset.isImage: true
|
|
|
|
|
loading: root.isLoading
|
|
|
|
|
visible: balancesAggregator.value > 0
|
|
|
|
|
rightComponent: StatusFlatRoundButton {
|
|
|
|
|
width: visible ? 14 : 0
|
|
|
|
|
height: visible ? 14 : 0
|
|
|
|
|
icon.width: 14
|
|
|
|
|
icon.height: 14
|
|
|
|
|
icon.name: "tiny/warning"
|
|
|
|
|
icon.color: Theme.palette.dangerColor1
|
|
|
|
|
tooltip.text: root.errorTooltipText
|
|
|
|
|
visible: !!root.errorTooltipText
|
2023-11-24 12:16:13 +00:00
|
|
|
|
}
|
2023-03-15 09:17:25 +00:00
|
|
|
|
}
|
2022-08-08 21:12:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|