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
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
DropArea {
|
|
|
|
id: root
|
|
|
|
objectName: "manageTokensGroupDelegate-%1".arg(index)
|
|
|
|
|
|
|
|
// expected roles: communityId, communityName, communityImage
|
|
|
|
|
|
|
|
property int visualIndex: index
|
|
|
|
property var controller
|
|
|
|
property bool communityGroupsExpanded
|
|
|
|
property var dragParent
|
|
|
|
property alias dragEnabled: groupedCommunityTokenDelegate.dragEnabled
|
|
|
|
property bool isCollectible
|
2024-01-16 16:22:05 +00:00
|
|
|
property bool isHidden // inside the "Hidden" section
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
readonly property string communityId: model.communityId
|
|
|
|
readonly property int childCount: model.enabledNetworkBalance // NB using "balance" as "count" in m_communityTokenGroupsModel
|
|
|
|
readonly property alias title: groupedCommunityTokenDelegate.title
|
|
|
|
|
2024-01-24 16:35:53 +00:00
|
|
|
property var getCurrencyAmount: function (balance, symbol) {}
|
|
|
|
property var getCurrentCurrencyAmount: function(balance){}
|
|
|
|
|
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 }
|
|
|
|
}
|
|
|
|
|
|
|
|
keys: ["x-status-draggable-community-group-item"]
|
2024-01-16 16:22:05 +00:00
|
|
|
width: ListView.view ? ListView.view.width : 0
|
|
|
|
height: visible ? groupedCommunityTokenDelegate.implicitHeight : 0
|
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
|
2024-01-16 16:22:05 +00:00
|
|
|
horizontalPadding: root.isHidden ? 0 : Style.current.halfPadding
|
2023-11-09 11:21:56 +00:00
|
|
|
draggable: true
|
|
|
|
spacing: 12
|
|
|
|
bgColor: Theme.palette.baseColor4
|
|
|
|
title: model.communityName
|
|
|
|
|
|
|
|
visualIndex: index
|
|
|
|
dragParent: root.dragParent
|
|
|
|
Drag.keys: root.keys
|
|
|
|
Drag.hotSpot.x: root.width/2
|
|
|
|
Drag.hotSpot.y: root.height/2
|
|
|
|
|
|
|
|
contentItem: ColumnLayout {
|
2024-01-16 16:22:05 +00:00
|
|
|
spacing: 12
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: 12
|
|
|
|
Layout.rightMargin: 12
|
|
|
|
spacing: groupedCommunityTokenDelegate.spacing
|
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
Layout.preferredWidth: 20
|
|
|
|
Layout.preferredHeight: 20
|
|
|
|
icon: "justify"
|
|
|
|
color: root.dragEnabled ? Theme.palette.baseColor1 : Theme.palette.baseColor2
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusRoundedImage {
|
|
|
|
//radius: groupedCommunityTokenDelegate.bgRadius // TODO different for a collection
|
|
|
|
Layout.preferredWidth: root.isCollectible ? 44 : 32
|
|
|
|
Layout.preferredHeight: root.isCollectible ? 44 : 32
|
|
|
|
image.source: model.communityImage
|
|
|
|
showLoadingIndicator: true
|
|
|
|
image.fillMode: Image.PreserveAspectCrop
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: groupedCommunityTokenDelegate.title
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 1
|
|
|
|
font.weight: Font.Medium
|
|
|
|
}
|
|
|
|
|
|
|
|
Item { Layout.fillWidth: true }
|
|
|
|
|
2024-01-16 16:22:05 +00:00
|
|
|
ManageTokensCommunityTag {
|
|
|
|
text: root.childCount
|
|
|
|
asset.name: root.isCollectible ? "image" : "token"
|
|
|
|
asset.isImage: false
|
|
|
|
asset.color: Theme.palette.baseColor1
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
|
2023-11-09 11:21:56 +00:00
|
|
|
ManageTokenMenuButton {
|
|
|
|
objectName: "btnManageTokenMenu-%1".arg(currentIndex)
|
|
|
|
currentIndex: visualIndex
|
2024-01-16 16:22:05 +00:00
|
|
|
count: root.controller.communityTokenGroupsModel.count // FIXME collection
|
2023-11-09 11:21:56 +00:00
|
|
|
isGroup: true
|
|
|
|
isCollectible: root.isCollectible
|
|
|
|
groupId: model.communityId
|
2024-01-16 16:22:05 +00:00
|
|
|
inHidden: root.isHidden
|
|
|
|
onMoveRequested: (from, to) => root.controller.communityTokenGroupsModel.moveItem(from, to) // FIXME collection
|
2024-01-11 13:59:13 +00:00
|
|
|
onShowHideGroupRequested: function(groupId, flag) {
|
|
|
|
root.controller.showHideGroup(groupId, flag)
|
|
|
|
root.controller.saveSettings()
|
|
|
|
}
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusListView {
|
|
|
|
objectName: "manageTokensGroupListView"
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: contentHeight
|
|
|
|
model: root.controller.communityTokensModel
|
|
|
|
interactive: false
|
2024-01-16 16:22:05 +00:00
|
|
|
visible: root.communityGroupsExpanded && !root.isHidden
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
displaced: Transition {
|
|
|
|
NumberAnimation { properties: "x,y"; easing.type: Easing.OutQuad }
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: ManageTokensDelegate {
|
|
|
|
controller: root.controller
|
|
|
|
dragParent: root.dragParent
|
|
|
|
isGrouped: true
|
|
|
|
count: root.childCount
|
|
|
|
dragEnabled: count > 1
|
|
|
|
keys: ["x-status-draggable-community-token-item-%1".arg(model.communityId)]
|
|
|
|
bgColor: Theme.palette.indirectColor4
|
|
|
|
topInset: 2 // tighter "spacing"
|
|
|
|
bottomInset: 2
|
|
|
|
visible: root.communityId === model.communityId
|
|
|
|
isCollectible: root.isCollectible
|
2024-01-24 16:35:53 +00:00
|
|
|
getCurrencyAmount: function (balance, symbol) {
|
|
|
|
return root.getCurrencyAmount(balance, symbol)
|
|
|
|
}
|
|
|
|
getCurrentCurrencyAmount: function (balance) {
|
|
|
|
return root.getCurrentCurrencyAmount(balance)
|
|
|
|
}
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|