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
|
|
|
|
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-02-13 11:12:01 +00:00
|
|
|
readonly property bool unknownCommunityName: model.communityName.startsWith("0x") && model.communityName == model.communityId
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
return qsTr("Community %1").arg(StatusQUtils.Utils.elideAndFormatWalletAddress(model.communityName))
|
|
|
|
}
|
|
|
|
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-02-13 11:12:01 +00:00
|
|
|
StatusSmartIdenticon {
|
|
|
|
id: identicon
|
|
|
|
Layout.preferredWidth: visible ? 32 : 0
|
|
|
|
Layout.preferredHeight: visible ? 32 : 0
|
|
|
|
asset.width: 32
|
|
|
|
asset.height: 32
|
|
|
|
visible: root.unknownCommunityName
|
|
|
|
asset.name: "help"
|
|
|
|
asset.color: Theme.palette.baseColor1
|
|
|
|
asset.isImage: false
|
|
|
|
}
|
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
StatusRoundedImage {
|
2024-02-13 11:12:01 +00:00
|
|
|
visible: !root.unknownCommunityName
|
2024-01-19 09:53:32 +00:00
|
|
|
radius: root.isCollection ? Style.current.radius : height/2
|
2024-02-13 11:12:01 +00:00
|
|
|
Layout.preferredWidth: {
|
|
|
|
if (!visible){
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return root.isCollectible ? 44 : 32
|
|
|
|
}
|
|
|
|
Layout.preferredHeight: {
|
|
|
|
if (!visible){
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return root.isCollectible ? 44 : 32
|
|
|
|
}
|
|
|
|
image.source: {
|
|
|
|
if(root.isCollection) {
|
|
|
|
return model.imageUrl
|
|
|
|
}
|
|
|
|
|
|
|
|
return model.communityImage // FIXME unify group image
|
|
|
|
}
|
2024-01-19 09:53:32 +00:00
|
|
|
showLoadingIndicator: true
|
|
|
|
image.fillMode: Image.PreserveAspectCrop
|
|
|
|
}
|
2024-01-16 16:22:05 +00:00
|
|
|
|
2024-02-13 11:12:01 +00:00
|
|
|
RowLayout {
|
|
|
|
id: communityNameRow
|
|
|
|
spacing: 2
|
2024-02-02 09:41:14 +00:00
|
|
|
Layout.fillWidth: true
|
2024-02-13 11:12:01 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: groupedCommunityTokenDelegate.title
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 1
|
|
|
|
font.weight: Font.Medium
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyToClipBoardButton {
|
|
|
|
visible: root.unknownCommunityName && communityNameArea.hovered
|
|
|
|
icon.height: Theme.primaryTextFontSize
|
|
|
|
icon.width: Theme.primaryTextFontSize
|
|
|
|
icon.color: Theme.palette.directColor1
|
|
|
|
Layout.preferredWidth: 16
|
|
|
|
Layout.preferredHeight: 16
|
|
|
|
color: Style.current.transparent
|
|
|
|
textToCopy: model.communityName
|
|
|
|
onCopyClicked: {
|
|
|
|
Utils.copyToClipboard(textToCopy)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
id: communityNameToolTip
|
|
|
|
text: qsTr("Community name could not be fetched")
|
|
|
|
visible: root.unknownCommunityName && communityNameArea.hovered
|
|
|
|
orientation: StatusToolTip.Orientation.Top
|
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: communityNameArea
|
|
|
|
}
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
|
2024-02-13 11:12:01 +00:00
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
Item { Layout.fillWidth: true }
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|