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-24 12:16:13 +00:00
|
|
|
// expected roles: name, symbol, currencyPrice, changePct24hour, communityId, communityName, communityImage
|
2023-11-22 19:58:02 +00:00
|
|
|
|
|
|
|
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: {
|
2023-11-24 12:16:13 +00:00
|
|
|
if (!modelData || !modelData.marketDetails) {
|
2023-04-04 12:09:36 +00:00
|
|
|
return Theme.palette.successColor1
|
|
|
|
}
|
2023-11-24 12:16:13 +00:00
|
|
|
return modelData.marketDetails.changePct24hour === undefined ?
|
2023-04-04 12:09:36 +00:00
|
|
|
Theme.palette.baseColor1 :
|
2023-11-24 12:16:13 +00:00
|
|
|
modelData.marketDetails.changePct24hour === 0 ?
|
2023-04-04 12:09:36 +00:00
|
|
|
Theme.palette.baseColor1 :
|
2023-11-24 12:16:13 +00:00
|
|
|
modelData.marketDetails.changePct24hour < 0 ?
|
2023-04-04 12:09:36 +00:00
|
|
|
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-12-20 10:31:02 +00:00
|
|
|
readonly property string symbolUrl: {
|
|
|
|
if (!modelData)
|
|
|
|
return ""
|
2023-11-24 12:16:13 +00:00
|
|
|
if (modelData.image)
|
|
|
|
return modelData.image
|
2023-12-20 10:31:02 +00:00
|
|
|
if (modelData.symbol)
|
|
|
|
return Constants.tokenIcon(modelData.symbol, false)
|
|
|
|
return ""
|
|
|
|
}
|
2023-11-22 19:58:02 +00:00
|
|
|
readonly property string upDownTriangle: {
|
2023-11-24 12:16:13 +00:00
|
|
|
if (!modelData || !modelData.marketDetails)
|
2023-11-22 19:58:02 +00:00
|
|
|
return ""
|
2023-11-24 12:16:13 +00:00
|
|
|
if (modelData.marketDetails.changePct24hour < 0)
|
2023-11-22 19:58:02 +00:00
|
|
|
return "▾"
|
2023-11-24 12:16:13 +00:00
|
|
|
if (modelData.marketDetails.changePct24hour > 0)
|
2023-11-22 19:58:02 +00:00
|
|
|
return "▴"
|
|
|
|
return ""
|
|
|
|
}
|
2024-03-25 17:31:01 +00:00
|
|
|
readonly property bool isUndefined: modelData && !modelData.marketDetailsLoading && title === ""
|
2023-11-22 19:58:02 +00:00
|
|
|
|
|
|
|
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
|
2024-03-25 17:31:01 +00:00
|
|
|
height: isUndefined ? 0 : implicitHeight
|
|
|
|
visible: !isUndefined
|
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-11-24 12:16:13 +00:00
|
|
|
loading: modelData && modelData.marketDetailsLoading
|
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
|
2023-11-24 12:16:13 +00:00
|
|
|
loading: modelData && modelData.marketDetailsLoading
|
|
|
|
text: modelData && modelData.marketDetails && modelData.marketDetails.changePct24hour !== undefined ? "%1 %2%".arg(root.upDownTriangle).arg(LocaleUtils.numberToLocaleString(modelData.marketDetails.changePct24hour, 2))
|
2023-12-18 10:12:57 +00:00
|
|
|
: "---"
|
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
|
2023-11-24 12:16:13 +00:00
|
|
|
loading: modelData && modelData.marketDetailsLoading
|
2023-12-18 10:12:57 +00:00
|
|
|
text: modelData && modelData.marketDetails ? LocaleUtils.currencyAmountToLocaleString(modelData.marketDetails.currencyPrice) : ""
|
2023-11-22 19:58:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ManageTokensCommunityTag {
|
|
|
|
anchors.right: parent.right
|
2024-02-13 11:12:01 +00:00
|
|
|
communityImage: !!modelData ? modelData.communityImage : ""
|
|
|
|
communityName: !!modelData && !!modelData.communityName ? modelData.communityName: ""
|
|
|
|
communityId: !!modelData && !!modelData.communityId ? modelData.communityId : ""
|
2023-11-24 12:16:13 +00:00
|
|
|
asset.letterSize: 12
|
2023-11-22 19:58:02 +00:00
|
|
|
visible: root.isCommunityToken
|
2024-02-13 11:12:01 +00:00
|
|
|
|
2023-11-22 19:58:02 +00:00
|
|
|
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
|
|
|
}
|