2023-11-09 11:21:56 +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.Controls 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2024-02-13 11:12:01 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-02-13 11:12:01 +00:00
|
|
|
import shared.controls 1.0
|
2023-11-09 11:21:56 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
DropArea {
|
|
|
|
id: root
|
|
|
|
objectName: "manageTokensGroupDelegate-%1".arg(index)
|
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
// expected roles: communityId, communityName, communityImage, collectionUid, collectionName, imageUrl // FIXME unify group image
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
property int visualIndex: index
|
|
|
|
property var controller
|
|
|
|
property var dragParent
|
|
|
|
property alias dragEnabled: groupedCommunityTokenDelegate.dragEnabled
|
2024-01-19 09:53:32 +00:00
|
|
|
property bool isCollectible: isCollection
|
|
|
|
property bool isCollection
|
2024-01-16 16:22:05 +00:00
|
|
|
property bool isHidden // inside the "Hidden" section
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
readonly property string groupId: isCollection ? model.collectionUid : model.communityId
|
2024-03-14 23:15:33 +00:00
|
|
|
readonly property string groupImage: !!model ? model.communityImage || model.imageUrl : ""
|
2024-01-19 09:53:32 +00:00
|
|
|
readonly property int childCount: model.enabledNetworkBalance // NB using "balance" as "count" in the grouped model
|
2023-11-09 11:21:56 +00:00
|
|
|
readonly property alias title: groupedCommunityTokenDelegate.title
|
|
|
|
|
2024-03-14 23:15:33 +00:00
|
|
|
readonly property bool unknownCommunityName: model.communityName.startsWith("0x") && model.communityName === model.communityId
|
2024-02-13 11:12:01 +00:00
|
|
|
|
2023-11-09 11:21:56 +00:00
|
|
|
ListView.onRemove: SequentialAnimation {
|
|
|
|
PropertyAction { target: root; property: "ListView.delayRemove"; value: true }
|
|
|
|
NumberAnimation { target: root; property: "scale"; to: 0; easing.type: Easing.InOutQuad }
|
|
|
|
PropertyAction { target: root; property: "ListView.delayRemove"; value: false }
|
|
|
|
}
|
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
keys: isCollection ? ["x-status-draggable-collection-group-item"] : ["x-status-draggable-community-group-item"]
|
2024-01-16 16:22:05 +00:00
|
|
|
width: ListView.view ? ListView.view.width : 0
|
2024-01-26 15:39:42 +00:00
|
|
|
height: groupedCommunityTokenDelegate.implicitHeight
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
onEntered: function(drag) {
|
|
|
|
const from = drag.source.visualIndex
|
|
|
|
const to = groupedCommunityTokenDelegate.visualIndex
|
|
|
|
if (to === from)
|
|
|
|
return
|
|
|
|
ListView.view.model.moveItem(from, to)
|
|
|
|
drag.accept()
|
|
|
|
}
|
|
|
|
|
2024-03-14 23:15:33 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
readonly property int iconSize: root.isCollectible ? 44 : 32
|
|
|
|
}
|
|
|
|
|
2023-11-09 11:21:56 +00:00
|
|
|
StatusDraggableListItem {
|
|
|
|
id: groupedCommunityTokenDelegate
|
|
|
|
width: parent.width
|
|
|
|
height: dragActive ? implicitHeight : parent.height
|
|
|
|
draggable: true
|
|
|
|
spacing: 12
|
|
|
|
bgColor: Theme.palette.baseColor4
|
2024-02-13 11:12:01 +00:00
|
|
|
|
|
|
|
title: {
|
|
|
|
if (root.isCollection) {
|
|
|
|
return model.collectionName
|
|
|
|
}
|
|
|
|
|
|
|
|
if (root.unknownCommunityName) {
|
|
|
|
if (communityNameArea.hovered) {
|
2024-03-14 23:15:33 +00:00
|
|
|
return qsTr("Community %1").arg(model.communityName)
|
2024-02-13 11:12:01 +00:00
|
|
|
}
|
|
|
|
return qsTr("Unknown community")
|
|
|
|
}
|
|
|
|
|
|
|
|
return model.communityName
|
|
|
|
}
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
visualIndex: index
|
|
|
|
dragParent: root.dragParent
|
|
|
|
Drag.keys: root.keys
|
|
|
|
Drag.hotSpot.x: root.width/2
|
|
|
|
Drag.hotSpot.y: root.height/2
|
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
contentItem: RowLayout {
|
|
|
|
spacing: groupedCommunityTokenDelegate.spacing
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
StatusIcon {
|
|
|
|
Layout.preferredWidth: 20
|
|
|
|
Layout.preferredHeight: 20
|
|
|
|
icon: "justify"
|
|
|
|
color: root.dragEnabled ? Theme.palette.baseColor1 : Theme.palette.baseColor2
|
|
|
|
}
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-03-14 23:15:33 +00:00
|
|
|
StatusRoundIcon {
|
|
|
|
Layout.preferredWidth: d.iconSize
|
|
|
|
Layout.preferredHeight: d.iconSize
|
|
|
|
radius: root.isCollection ? Style.current.radius : height/2
|
|
|
|
visible: root.unknownCommunityName || !root.groupImage
|
|
|
|
asset.name: root.unknownCommunityName ? "help" : root.isCollection ? "gallery" : "group"
|
|
|
|
asset.color: root.unknownCommunityName ? Theme.palette.directColor1 : "black"
|
|
|
|
asset.bgColor: root.unknownCommunityName ? Theme.palette.primaryColor3 : model.backgroundColor
|
2024-02-13 11:12:01 +00:00
|
|
|
}
|
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
StatusRoundedImage {
|
2024-03-14 23:15:33 +00:00
|
|
|
visible: !!root.groupImage
|
2024-01-19 09:53:32 +00:00
|
|
|
radius: root.isCollection ? Style.current.radius : height/2
|
2024-03-14 23:15:33 +00:00
|
|
|
Layout.preferredWidth: d.iconSize
|
|
|
|
Layout.preferredHeight: d.iconSize
|
|
|
|
|
|
|
|
image.source: root.groupImage
|
2024-01-19 09:53:32 +00:00
|
|
|
showLoadingIndicator: true
|
|
|
|
image.fillMode: Image.PreserveAspectCrop
|
|
|
|
}
|
2024-01-16 16:22:05 +00:00
|
|
|
|
2024-03-14 23:15:33 +00:00
|
|
|
Row {
|
2024-02-13 11:12:01 +00:00
|
|
|
id: communityNameRow
|
|
|
|
spacing: 2
|
2024-02-02 09:41:14 +00:00
|
|
|
Layout.fillWidth: true
|
2024-02-13 11:12:01 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
2024-03-14 23:15:33 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: Math.min(implicitWidth, parent.width - copyButton.width)
|
2024-02-13 11:12:01 +00:00
|
|
|
text: groupedCommunityTokenDelegate.title
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 1
|
|
|
|
font.weight: Font.Medium
|
2024-03-14 23:15:33 +00:00
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
text: qsTr("Community name could not be fetched")
|
|
|
|
visible: root.unknownCommunityName && communityNameArea.hovered
|
|
|
|
}
|
2024-02-13 11:12:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CopyToClipBoardButton {
|
2024-03-14 23:15:33 +00:00
|
|
|
id: copyButton
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2024-02-13 11:12:01 +00:00
|
|
|
visible: root.unknownCommunityName && communityNameArea.hovered
|
|
|
|
icon.height: Theme.primaryTextFontSize
|
|
|
|
icon.width: Theme.primaryTextFontSize
|
|
|
|
icon.color: Theme.palette.directColor1
|
|
|
|
color: Style.current.transparent
|
|
|
|
textToCopy: model.communityName
|
|
|
|
onCopyClicked: {
|
|
|
|
Utils.copyToClipboard(textToCopy)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: communityNameArea
|
|
|
|
}
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
ManageTokensCommunityTag {
|
2024-02-13 11:12:01 +00:00
|
|
|
communityName: root.childCount
|
|
|
|
communityId: ""
|
2024-01-19 09:53:32 +00:00
|
|
|
asset.name: root.isCollectible ? "image" : "token"
|
|
|
|
asset.isImage: false
|
|
|
|
asset.color: Theme.palette.baseColor1
|
2024-02-13 11:12:01 +00:00
|
|
|
loading: false
|
2024-01-19 09:53:32 +00:00
|
|
|
enabled: false
|
|
|
|
}
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
ManageTokenMenuButton {
|
|
|
|
objectName: "btnManageTokenMenu-%1".arg(currentIndex)
|
|
|
|
currentIndex: visualIndex
|
|
|
|
count: root.isCollection ? root.controller.collectionGroupsModel.count :
|
|
|
|
root.controller.communityTokenGroupsModel.count
|
|
|
|
isGroup: true
|
|
|
|
isCollection: root.isCollection
|
|
|
|
isCollectible: root.isCollectible
|
|
|
|
groupId: root.groupId
|
|
|
|
inHidden: root.isHidden
|
|
|
|
onMoveRequested: (from, to) => root.ListView.view.model.moveItem(from, to)
|
|
|
|
onShowHideGroupRequested: function(groupId, flag) {
|
|
|
|
if (root.isCollection)
|
|
|
|
root.controller.showHideCollectionGroup(groupId, flag)
|
|
|
|
else
|
|
|
|
root.controller.showHideGroup(groupId, flag)
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|