2023-11-29 15:48:33 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2023-01-20 00:44:35 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
2023-01-31 10:49:07 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2023-01-20 00:44:35 +00:00
|
|
|
|
2023-07-18 17:34:57 +00:00
|
|
|
import AppLayouts.Communities.panels 1.0
|
2023-11-29 15:48:33 +00:00
|
|
|
import AppLayouts.Wallet.controls 1.0
|
2023-07-18 17:34:57 +00:00
|
|
|
|
2023-01-31 10:49:07 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2023-03-09 16:40:34 +00:00
|
|
|
Control {
|
2023-01-20 00:44:35 +00:00
|
|
|
id: root
|
|
|
|
|
2024-10-03 13:13:35 +00:00
|
|
|
objectName: "collectibleViewControl"
|
|
|
|
|
2023-03-09 16:40:34 +00:00
|
|
|
property string title: ""
|
2024-08-28 13:58:33 +00:00
|
|
|
property string unknownTitle: "..."
|
2023-03-09 16:40:34 +00:00
|
|
|
property string subTitle: ""
|
2023-05-17 10:00:52 +00:00
|
|
|
property alias subTitleColor: subTitleItem.customColor
|
2023-03-09 16:40:34 +00:00
|
|
|
property string backgroundColor: "transparent"
|
2023-04-03 15:38:05 +00:00
|
|
|
property url mediaUrl : ""
|
|
|
|
property string mediaType: ""
|
|
|
|
property url fallbackImageUrl : ""
|
2023-03-09 16:40:34 +00:00
|
|
|
property bool isLoading: false
|
|
|
|
property bool navigationIconVisible: false
|
2024-08-28 13:58:33 +00:00
|
|
|
property bool isMetadataValid: false
|
2023-09-27 14:03:49 +00:00
|
|
|
property string communityId: ""
|
2023-11-29 15:48:33 +00:00
|
|
|
property string communityName
|
|
|
|
property string communityImage
|
2024-03-05 20:16:37 +00:00
|
|
|
property int balance: 1
|
2023-01-20 00:44:35 +00:00
|
|
|
|
2023-07-18 17:34:57 +00:00
|
|
|
// Special Owner and TMaster token properties
|
2023-09-27 14:03:49 +00:00
|
|
|
readonly property bool isCommunityCollectible: communityId !== ""
|
2023-08-04 16:41:21 +00:00
|
|
|
property int privilegesLevel: Constants.TokenPrivilegesLevel.Community
|
|
|
|
readonly property bool isPrivilegedToken: (privilegesLevel === Constants.TokenPrivilegesLevel.Owner) ||
|
|
|
|
(privilegesLevel === Constants.TokenPrivilegesLevel.TMaster)
|
2023-07-18 17:34:57 +00:00
|
|
|
property color ornamentColor // Relevant color for these special tokens (community color)
|
|
|
|
|
2024-03-12 15:47:20 +00:00
|
|
|
QtObject {
|
2024-02-13 11:12:01 +00:00
|
|
|
id: d
|
2024-03-12 15:47:20 +00:00
|
|
|
|
2024-02-13 11:12:01 +00:00
|
|
|
readonly property bool unknownCommunityName: root.communityName.startsWith("0x") && root.communityId === root.communityName
|
|
|
|
}
|
|
|
|
|
2023-03-09 16:40:34 +00:00
|
|
|
signal clicked
|
2023-11-29 15:48:33 +00:00
|
|
|
signal rightClicked
|
|
|
|
signal switchToCommunityRequested(string communityId)
|
2023-01-20 00:44:35 +00:00
|
|
|
|
2023-03-09 16:40:34 +00:00
|
|
|
background: Rectangle {
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.radius
|
2023-05-11 17:12:22 +00:00
|
|
|
color: Theme.palette.baseColor2
|
2023-11-29 15:48:33 +00:00
|
|
|
visible: !root.isLoading && root.hovered
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
enabled: !root.isLoading
|
|
|
|
onTapped: root.clicked()
|
|
|
|
}
|
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.RightButton
|
|
|
|
enabled: !root.isLoading
|
|
|
|
onTapped: root.rightClicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
cursorShape: !root.isLoading ? Qt.PointingHandCursor : undefined
|
2023-03-09 16:40:34 +00:00
|
|
|
}
|
|
|
|
|
2024-03-05 20:16:37 +00:00
|
|
|
property Component balanceTag: Component {
|
|
|
|
CollectibleBalanceTag {
|
|
|
|
visible: !root.isLoading && (root.balance > 1)
|
|
|
|
balance: root.balance
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-09 16:40:34 +00:00
|
|
|
contentItem: ColumnLayout {
|
2023-01-20 00:44:35 +00:00
|
|
|
spacing: 0
|
|
|
|
|
2024-08-28 13:58:33 +00:00
|
|
|
CollectibleMedia {
|
2023-01-20 00:44:35 +00:00
|
|
|
id: image
|
2023-03-09 16:40:34 +00:00
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.margins: Theme.halfPadding
|
2023-03-09 16:40:34 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: width
|
2023-07-18 17:34:57 +00:00
|
|
|
|
2024-08-28 13:58:33 +00:00
|
|
|
backgroundColor: root.isLoading ? "transparent" : root.backgroundColor
|
2023-09-27 14:03:49 +00:00
|
|
|
visible: !specialCollectible.visible
|
2024-08-28 13:58:33 +00:00
|
|
|
isMetadataValid: root.isMetadataValid
|
2023-04-03 15:38:05 +00:00
|
|
|
mediaUrl: root.mediaUrl
|
|
|
|
mediaType: root.mediaType
|
|
|
|
fallbackImageUrl: root.fallbackImageUrl
|
2023-01-20 00:44:35 +00:00
|
|
|
showLoadingIndicator: true
|
2024-08-28 13:58:33 +00:00
|
|
|
isCollectibleLoading: root.isLoading
|
2024-04-11 09:00:42 +00:00
|
|
|
fillMode: Image.PreserveAspectCrop
|
2023-03-09 16:40:34 +00:00
|
|
|
|
2024-03-05 20:16:37 +00:00
|
|
|
Loader {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.margins: Theme.halfPadding
|
2024-03-05 20:16:37 +00:00
|
|
|
sourceComponent: root.balanceTag
|
|
|
|
}
|
2023-01-20 00:44:35 +00:00
|
|
|
}
|
2023-03-09 16:40:34 +00:00
|
|
|
|
2023-07-18 17:34:57 +00:00
|
|
|
PrivilegedTokenArtworkPanel {
|
2023-09-27 14:03:49 +00:00
|
|
|
id: specialCollectible
|
|
|
|
|
2023-07-18 17:34:57 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.margins: Theme.halfPadding
|
2023-07-18 17:34:57 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: width
|
|
|
|
|
2023-09-27 14:03:49 +00:00
|
|
|
visible: root.isCommunityCollectible && root.isPrivilegedToken
|
2023-07-18 17:34:57 +00:00
|
|
|
size: PrivilegedTokenArtworkPanel.Size.Medium
|
2024-05-15 09:36:56 +00:00
|
|
|
artwork: visible ? root.fallbackImageUrl : ""
|
2023-07-18 17:34:57 +00:00
|
|
|
color: root.ornamentColor
|
2024-04-11 09:00:42 +00:00
|
|
|
fillMode: Image.PreserveAspectCrop
|
2023-08-04 16:41:21 +00:00
|
|
|
isOwner: root.privilegesLevel === Constants.TokenPrivilegesLevel.Owner
|
2023-07-18 17:34:57 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
anchors.fill: parent
|
|
|
|
active: root.isLoading
|
|
|
|
sourceComponent: LoadingComponent {radius: image.radius}
|
|
|
|
}
|
2024-03-05 20:16:37 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.margins: Theme.halfPadding
|
2024-03-05 20:16:37 +00:00
|
|
|
sourceComponent: root.balanceTag
|
|
|
|
}
|
2023-07-18 17:34:57 +00:00
|
|
|
}
|
|
|
|
|
2023-03-09 16:40:34 +00:00
|
|
|
RowLayout {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.halfPadding
|
2023-03-09 16:40:34 +00:00
|
|
|
Layout.rightMargin: Layout.leftMargin
|
|
|
|
Layout.fillWidth: !root.isLoading
|
|
|
|
Layout.preferredWidth: root.isLoading ? 134 : width
|
|
|
|
|
|
|
|
StatusTextWithLoadingState {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
customColor: Theme.palette.directColor1
|
|
|
|
font.weight: Font.DemiBold
|
|
|
|
elide: Text.ElideRight
|
2024-08-28 13:58:33 +00:00
|
|
|
text: root.isLoading ? Constants.dummyText : root.title || root.unknownTitle
|
2023-03-09 16:40:34 +00:00
|
|
|
loading: root.isLoading
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
visible: root.navigationIconVisible
|
|
|
|
icon: "next"
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
2023-01-20 00:44:35 +00:00
|
|
|
}
|
2023-03-09 16:40:34 +00:00
|
|
|
|
2023-01-31 10:49:07 +00:00
|
|
|
StatusTextWithLoadingState {
|
2023-05-17 10:00:52 +00:00
|
|
|
id: subTitleItem
|
|
|
|
|
2023-11-29 15:48:33 +00:00
|
|
|
Layout.topMargin: 4
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.halfPadding
|
2023-03-09 16:40:34 +00:00
|
|
|
Layout.rightMargin: Layout.leftMargin
|
|
|
|
Layout.fillWidth: !root.isLoading
|
|
|
|
Layout.preferredWidth: root.isLoading ? 88 : width
|
2023-01-20 00:44:35 +00:00
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
font.pixelSize: 13
|
2023-01-31 10:49:07 +00:00
|
|
|
customColor: Theme.palette.baseColor1
|
2023-01-20 00:44:35 +00:00
|
|
|
elide: Text.ElideRight
|
2023-11-29 15:48:33 +00:00
|
|
|
text: root.isLoading ? Constants.dummyText : root.subTitle
|
2023-03-09 16:40:34 +00:00
|
|
|
loading: root.isLoading
|
2023-11-29 15:48:33 +00:00
|
|
|
visible: text && !root.communityName
|
|
|
|
}
|
|
|
|
|
|
|
|
ManageTokensCommunityTag {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.topMargin: Theme.halfPadding
|
|
|
|
Layout.leftMargin: Theme.halfPadding
|
|
|
|
Layout.rightMargin: Theme.halfPadding
|
2023-11-29 15:48:33 +00:00
|
|
|
Layout.maximumWidth: parent.width - Layout.leftMargin - Layout.rightMargin
|
2024-02-13 11:12:01 +00:00
|
|
|
communityName: root.communityName
|
|
|
|
communityId: root.communityId
|
|
|
|
communityImage: root.communityImage
|
2023-11-29 15:48:33 +00:00
|
|
|
visible: root.isCommunityCollectible
|
|
|
|
enabled: !root.isLoading
|
2024-02-13 11:12:01 +00:00
|
|
|
|
2023-11-29 15:48:33 +00:00
|
|
|
TapHandler {
|
2024-02-13 11:12:01 +00:00
|
|
|
enabled: !d.unknownCommunityName
|
2023-11-29 15:48:33 +00:00
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
onSingleTapped: root.switchToCommunityRequested(root.communityId)
|
|
|
|
}
|
2023-01-20 00:44:35 +00:00
|
|
|
}
|
|
|
|
|
2023-03-09 16:40:34 +00:00
|
|
|
// Filler
|
|
|
|
Item {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2023-01-20 00:44:35 +00:00
|
|
|
}
|
2023-01-31 10:49:07 +00:00
|
|
|
}
|