2023-11-22 19:58:02 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
2022-11-23 17:58:22 +00:00
|
|
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
2023-01-10 13:04:23 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2022-11-23 17:58:22 +00:00
|
|
|
|
2023-11-22 19:58:02 +00:00
|
|
|
import AppLayouts.Wallet.controls 1.0
|
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
StatusListItem {
|
2022-12-29 16:44:51 +00:00
|
|
|
id: root
|
2023-01-10 13:04:23 +00:00
|
|
|
|
2023-11-22 19:58:02 +00:00
|
|
|
// expected roles: name, symbol, enabledNetworkBalance, enabledNetworkCurrencyBalance, currencyPrice, changePct24hour, communityId, communityName, communityImage
|
|
|
|
|
|
|
|
property alias currencyBalance: currencyBalance
|
2023-01-10 13:04:23 +00:00
|
|
|
property alias change24HourPercentage: change24HourPercentageText
|
2023-11-22 19:58:02 +00:00
|
|
|
property alias currencyPrice: currencyPrice
|
2023-01-10 13:04:23 +00:00
|
|
|
|
|
|
|
property string currentCurrencySymbol
|
2023-04-04 12:09:36 +00:00
|
|
|
property string textColor: {
|
|
|
|
if (!modelData) {
|
|
|
|
return Theme.palette.successColor1
|
|
|
|
}
|
|
|
|
return modelData.changePct24hour === undefined ?
|
|
|
|
Theme.palette.baseColor1 :
|
|
|
|
modelData.changePct24hour === 0 ?
|
|
|
|
Theme.palette.baseColor1 :
|
|
|
|
modelData.changePct24hour < 0 ?
|
|
|
|
Theme.palette.dangerColor1 :
|
|
|
|
Theme.palette.successColor1
|
|
|
|
}
|
|
|
|
|
2023-03-15 09:17:25 +00:00
|
|
|
property string errorTooltipText_1
|
|
|
|
property string errorTooltipText_2
|
2023-01-10 13:04:23 +00:00
|
|
|
|
2023-11-22 19:58:02 +00:00
|
|
|
readonly property bool isCommunityToken: !!modelData && !!modelData.communityId
|
2023-08-04 08:41:45 +00:00
|
|
|
readonly property string symbolUrl: !!modelData && modelData.symbol ? Constants.tokenIcon(modelData.symbol, false) : ""
|
2023-11-22 19:58:02 +00:00
|
|
|
readonly property string upDownTriangle: {
|
|
|
|
if (!modelData)
|
|
|
|
return ""
|
|
|
|
if (modelData.changePct24hour < 0)
|
|
|
|
return "▾"
|
|
|
|
if (modelData.changePct24hour > 0)
|
|
|
|
return "▴"
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
signal switchToCommunityRequested(string communityId)
|
2023-08-04 08:41:45 +00:00
|
|
|
|
2023-04-04 12:09:36 +00:00
|
|
|
title: modelData ? modelData.name : ""
|
2023-03-22 22:08:36 +00:00
|
|
|
subTitle: LocaleUtils.currencyAmountToLocaleString(modelData.enabledNetworkBalance)
|
2023-08-04 08:41:45 +00:00
|
|
|
asset.name: symbolUrl
|
2022-11-23 17:58:22 +00:00
|
|
|
asset.isImage: true
|
2023-11-22 19:58:02 +00:00
|
|
|
asset.width: 32
|
|
|
|
asset.height: 32
|
2023-03-23 10:23:02 +00:00
|
|
|
errorIcon.tooltip.maxWidth: 300
|
2023-01-10 13:04:23 +00:00
|
|
|
|
2023-03-15 09:17:25 +00:00
|
|
|
statusListItemTitleIcons.sourceComponent: StatusFlatRoundButton {
|
|
|
|
width: 14
|
|
|
|
height: visible ? 14 : 0
|
|
|
|
icon.width: 14
|
|
|
|
icon.height: 14
|
|
|
|
icon.name: "tiny/warning"
|
|
|
|
icon.color: Theme.palette.dangerColor1
|
|
|
|
tooltip.text: root.errorTooltipText_1
|
|
|
|
tooltip.maxWidth: 300
|
|
|
|
visible: !!tooltip.text
|
|
|
|
}
|
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
components: [
|
|
|
|
Column {
|
2023-11-22 19:58:02 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-03-15 09:17:25 +00:00
|
|
|
StatusFlatRoundButton {
|
|
|
|
id: errorIcon
|
|
|
|
width: 14
|
|
|
|
height: visible ? 14 : 0
|
|
|
|
icon.width: 14
|
|
|
|
icon.height: 14
|
|
|
|
icon.name: "tiny/warning"
|
|
|
|
icon.color: Theme.palette.dangerColor1
|
|
|
|
tooltip.text: root.errorTooltipText_2
|
|
|
|
tooltip.maxWidth: 200
|
|
|
|
visible: !!tooltip.text
|
|
|
|
}
|
2023-01-10 13:04:23 +00:00
|
|
|
StatusTextWithLoadingState {
|
2023-11-22 19:58:02 +00:00
|
|
|
id: currencyBalance
|
2022-11-23 17:58:22 +00:00
|
|
|
anchors.right: parent.right
|
2023-04-04 12:09:36 +00:00
|
|
|
text: modelData ? LocaleUtils.currencyAmountToLocaleString(modelData.enabledNetworkCurrencyBalance) : ""
|
2023-11-22 19:58:02 +00:00
|
|
|
visible: !errorIcon.visible && !root.isCommunityToken
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|
|
|
|
Row {
|
2023-11-22 19:58:02 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
spacing: 6
|
|
|
|
visible: !errorIcon.visible && !root.isCommunityToken
|
2023-01-10 13:04:23 +00:00
|
|
|
StatusTextWithLoadingState {
|
2023-11-22 19:58:02 +00:00
|
|
|
id: change24HourPercentageText
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-01-10 13:04:23 +00:00
|
|
|
customColor: root.textColor
|
2023-11-22 19:58:02 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
text: modelData && modelData.changePct24hour !== undefined ? "%1 %2%".arg(root.upDownTriangle).arg(LocaleUtils.numberToLocaleString(modelData.changePct24hour, 2))
|
|
|
|
: "---"
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|
|
|
|
Rectangle {
|
2023-11-22 19:58:02 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2022-11-23 17:58:22 +00:00
|
|
|
width: 1
|
2023-11-22 19:58:02 +00:00
|
|
|
height: 12
|
2022-11-23 17:58:22 +00:00
|
|
|
color: Theme.palette.directColor9
|
|
|
|
}
|
2023-01-10 13:04:23 +00:00
|
|
|
StatusTextWithLoadingState {
|
2023-11-22 19:58:02 +00:00
|
|
|
id: currencyPrice
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-01-10 13:04:23 +00:00
|
|
|
customColor: root.textColor
|
2023-11-22 19:58:02 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
text: modelData ? LocaleUtils.currencyAmountToLocaleString(modelData.currencyPrice) : ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ManageTokensCommunityTag {
|
|
|
|
anchors.right: parent.right
|
2023-11-29 15:48:33 +00:00
|
|
|
text: modelData && !!modelData.communityName ? modelData.communityName : ""
|
|
|
|
imageSrc: modelData && !!modelData.communityImage ? modelData.communityImage : ""
|
2023-11-22 19:58:02 +00:00
|
|
|
visible: root.isCommunityToken
|
|
|
|
StatusToolTip {
|
2023-11-29 15:48:33 +00:00
|
|
|
text: modelData ? qsTr("This token was minted by the %1 community").arg(modelData.communityName) : ""
|
2023-11-22 19:58:02 +00:00
|
|
|
visible: parent.hovered
|
|
|
|
}
|
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
onSingleTapped: root.switchToCommunityRequested(modelData.communityId)
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2023-08-04 08:41:45 +00:00
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
2023-11-22 19:58:02 +00:00
|
|
|
name: "unknownToken"
|
2023-08-04 08:41:45 +00:00
|
|
|
when: !root.symbolUrl
|
|
|
|
PropertyChanges {
|
|
|
|
target: root.asset
|
|
|
|
isLetterIdenticon: true
|
|
|
|
color: Theme.palette.miscColor5
|
|
|
|
name: !!modelData && modelData.symbol ? modelData.symbol : ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|