2023-06-20 11:59:15 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
|
|
import shared.status 1.0
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
2023-12-20 14:10:50 +00:00
|
|
|
import AppLayouts.Wallet 1.0
|
|
|
|
|
2023-06-20 11:59:15 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../../stores"
|
|
|
|
import "../../controls"
|
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
2023-06-20 11:59:15 +00:00
|
|
|
|
|
|
|
property WalletStore walletStore
|
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
signal goBack
|
2023-07-11 15:10:26 +00:00
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
spacing: Style.current.padding
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property string walletAccountDnDKey: "status-wallet-account-item"
|
|
|
|
property int indexMoveFrom: -1
|
|
|
|
property int indexMoveTo: -1
|
2023-06-20 11:59:15 +00:00
|
|
|
}
|
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: accountsList.count > 1? qsTr("Move your most frequently used accounts to the top of your wallet list") :
|
|
|
|
qsTr("This account looks a little lonely. Add another account to enable re-ordering.")
|
|
|
|
color: Theme.palette.baseColor1
|
2023-06-20 11:59:15 +00:00
|
|
|
}
|
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
StatusListView {
|
|
|
|
id: accountsList
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: contentHeight
|
|
|
|
interactive: false
|
|
|
|
model: walletStore.accounts
|
2023-06-20 11:59:15 +00:00
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
displaced: Transition {
|
|
|
|
NumberAnimation { properties: "x,y"; easing.type: Easing.OutQuad }
|
|
|
|
}
|
2023-06-20 11:59:15 +00:00
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
delegate: DropArea {
|
|
|
|
id: delegateRoot
|
2023-06-20 11:59:15 +00:00
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
property int visualIndex: index
|
2023-06-20 11:59:15 +00:00
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
width: ListView.view.width
|
|
|
|
height: draggableDelegate.height
|
2023-06-20 11:59:15 +00:00
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
keys: [d.walletAccountDnDKey]
|
2023-06-20 11:59:15 +00:00
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
onEntered: function(drag) {
|
|
|
|
const from = drag.source.visualIndex
|
|
|
|
const to = draggableDelegate.visualIndex
|
|
|
|
if (to === from)
|
|
|
|
return
|
|
|
|
if (d.indexMoveFrom === -1)
|
|
|
|
d.indexMoveFrom = from
|
|
|
|
d.indexMoveTo = to
|
|
|
|
root.walletStore.moveAccount(from, to)
|
|
|
|
drag.accept()
|
|
|
|
}
|
2023-06-20 11:59:15 +00:00
|
|
|
|
2023-07-18 14:25:42 +00:00
|
|
|
StatusDraggableListItem {
|
|
|
|
id: draggableDelegate
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: parent.width
|
|
|
|
height: implicitHeight
|
|
|
|
|
|
|
|
dragParent: accountsList
|
|
|
|
visualIndex: delegateRoot.visualIndex
|
|
|
|
draggable: accountsList.count > 1
|
|
|
|
Drag.keys: [d.walletAccountDnDKey]
|
|
|
|
title: model.name
|
2024-10-02 19:38:03 +00:00
|
|
|
secondaryTitle: WalletUtils.addressToDisplay(model.address, true, containsMouse)
|
2023-07-18 14:25:42 +00:00
|
|
|
secondaryTitleIcon: model.walletType === Constants.watchWalletType? "show" :
|
|
|
|
model.keycardAccount ? "keycard" : ""
|
|
|
|
hasEmoji: true
|
|
|
|
icon.width: 40
|
|
|
|
icon.height: 40
|
|
|
|
icon.name: model.emoji
|
|
|
|
icon.color: Utils.getColorForId(model.colorId)
|
2024-04-09 08:24:10 +00:00
|
|
|
|
|
|
|
onDragFinished: {
|
|
|
|
let from = d.indexMoveFrom
|
|
|
|
let to = d.indexMoveTo
|
|
|
|
d.indexMoveFrom = -1
|
|
|
|
d.indexMoveTo = -1
|
|
|
|
root.walletStore.moveAccountFinally(from, to)
|
|
|
|
}
|
2023-06-20 11:59:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|