2022-03-01 10:14:13 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
2022-07-19 15:09:20 +00:00
|
|
|
import shared.controls 1.0
|
2022-03-01 10:14:13 +00:00
|
|
|
|
2022-07-19 15:09:20 +00:00
|
|
|
import "../stores"
|
2022-03-01 10:14:13 +00:00
|
|
|
import "../popups"
|
|
|
|
import "../controls"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
2022-07-19 13:16:14 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2022-03-01 10:14:13 +00:00
|
|
|
|
2022-07-19 15:09:20 +00:00
|
|
|
property var sendModal
|
2022-03-01 10:14:13 +00:00
|
|
|
property var contactsStore
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: _internal
|
|
|
|
property bool loading: false
|
|
|
|
property string error: ""
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: header
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
height: btnAdd.height
|
|
|
|
|
2022-07-19 13:16:14 +00:00
|
|
|
StatusBaseText {
|
2022-03-01 10:14:13 +00:00
|
|
|
anchors.left: parent.left
|
2022-07-19 13:16:14 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
id: title
|
|
|
|
text: qsTr("Saved addresses")
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 28
|
|
|
|
color: Theme.palette.directColor1
|
2022-03-01 10:14:13 +00:00
|
|
|
}
|
|
|
|
StatusButton {
|
2022-08-03 10:08:46 +00:00
|
|
|
objectName: "addNewAddressBtn"
|
2022-03-01 10:14:13 +00:00
|
|
|
id: btnAdd
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
2022-07-19 13:16:14 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
font.weight: Font.Medium
|
|
|
|
text: qsTr("Add new address")
|
2022-03-01 10:14:13 +00:00
|
|
|
visible: !_internal.loading
|
|
|
|
onClicked: {
|
|
|
|
Global.openPopup(addEditSavedAddress)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusLoadingIndicator {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: _internal.loading
|
|
|
|
color: Theme.palette.directColor4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: delegateSavedAddress
|
|
|
|
StatusListItem {
|
|
|
|
id: savedAddress
|
|
|
|
title: name
|
2022-08-03 10:08:46 +00:00
|
|
|
objectName: name
|
2022-07-19 15:09:20 +00:00
|
|
|
subTitle: name + " \u2022 " + Utils.getElidedCompressedPk(address)
|
2022-03-01 10:14:13 +00:00
|
|
|
implicitWidth: parent.width
|
2022-07-19 15:09:20 +00:00
|
|
|
color: "transparent"
|
|
|
|
border.color: Theme.palette.baseColor5
|
|
|
|
//TODO uncomment when #6456 is fixed
|
|
|
|
//titleTextIcon: RootStore.favouriteAddress ? "star-icon" : ""
|
|
|
|
statusListItemComponentsSlot.spacing: 0
|
2022-03-01 10:14:13 +00:00
|
|
|
property bool showButtons: sensor.containsMouse
|
2022-07-19 15:09:20 +00:00
|
|
|
|
2022-03-01 10:14:13 +00:00
|
|
|
components: [
|
|
|
|
StatusRoundButton {
|
2022-07-19 15:09:20 +00:00
|
|
|
icon.color: savedAddress.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
icon.name: "send"
|
2022-03-01 10:14:13 +00:00
|
|
|
onClicked: {
|
2022-07-19 15:09:20 +00:00
|
|
|
root.sendModal.open(address);
|
2022-03-01 10:14:13 +00:00
|
|
|
}
|
|
|
|
},
|
2022-07-19 15:09:20 +00:00
|
|
|
CopyToClipBoardButton {
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
icon.color: savedAddress.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
store: RootStore
|
|
|
|
textToCopy: address
|
2022-03-01 10:14:13 +00:00
|
|
|
},
|
2022-07-19 15:09:20 +00:00
|
|
|
//TODO uncomment when #6456 is fixed
|
|
|
|
// StatusRoundButton {
|
|
|
|
// icon.color: savedAddress.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
// type: StatusRoundButton.Type.Tertiary
|
|
|
|
// icon.name: savedAddress.favouriteAddress ? "favourite" : "unfavourite"
|
|
|
|
// onClicked: {
|
|
|
|
// RootStore.setFavourite();
|
|
|
|
// }
|
|
|
|
// },
|
2022-03-01 10:14:13 +00:00
|
|
|
StatusRoundButton {
|
2022-07-19 15:09:20 +00:00
|
|
|
icon.color: savedAddress.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
icon.name: "more"
|
|
|
|
onClicked: {
|
|
|
|
editDeleteMenu.openMenu(name, address);
|
|
|
|
}
|
2022-03-01 10:14:13 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-19 15:09:20 +00:00
|
|
|
StatusPopupMenu {
|
|
|
|
id: editDeleteMenu
|
|
|
|
property string contactName
|
|
|
|
property string contactAddress
|
|
|
|
function openMenu(name, address) {
|
|
|
|
contactName = name;
|
|
|
|
contactAddress = address;
|
|
|
|
popup();
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
contactName = "";
|
|
|
|
contactAddress = "";
|
|
|
|
}
|
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Edit")
|
2022-08-04 09:06:15 +00:00
|
|
|
objectName: "editSavedAddress"
|
2022-07-19 15:09:20 +00:00
|
|
|
iconSettings.name: "pencil-outline"
|
|
|
|
onTriggered: {
|
|
|
|
Global.openPopup(addEditSavedAddress,
|
|
|
|
{
|
|
|
|
edit: true,
|
|
|
|
address: editDeleteMenu.contactAddress,
|
|
|
|
name: editDeleteMenu.contactName
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusMenuSeparator { }
|
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Delete")
|
|
|
|
type: StatusMenuItem.Type.Danger
|
|
|
|
iconSettings.name: "delete"
|
2022-08-04 09:06:15 +00:00
|
|
|
objectName: "deleteSavedAddress"
|
2022-07-19 15:09:20 +00:00
|
|
|
onTriggered: {
|
|
|
|
deleteAddressConfirm.name = editDeleteMenu.contactName;
|
|
|
|
deleteAddressConfirm.address = editDeleteMenu.contactAddress;
|
|
|
|
deleteAddressConfirm.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-01 10:14:13 +00:00
|
|
|
Component {
|
|
|
|
id: addEditSavedAddress
|
|
|
|
AddEditSavedAddressPopup {
|
|
|
|
id: addEditModal
|
|
|
|
anchors.centerIn: parent
|
|
|
|
onClosed: destroy()
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
onSave: {
|
|
|
|
_internal.loading = true
|
|
|
|
_internal.error = RootStore.createOrUpdateSavedAddress(name, address)
|
|
|
|
_internal.loading = false
|
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusModal {
|
|
|
|
id: deleteAddressConfirm
|
|
|
|
property string address
|
|
|
|
property string name
|
|
|
|
// NOTE: the `text` property was created as a workaround because
|
|
|
|
// setting StatusBaseText.text to `qsTr("...").arg("...")`
|
|
|
|
// caused no text to render
|
|
|
|
property string text: qsTr("Are you sure you want to remove '%1' from your saved addresses?").arg(name)
|
|
|
|
anchors.centerIn: parent
|
2022-07-19 13:16:14 +00:00
|
|
|
header.title: qsTr("Are you sure?")
|
2022-03-01 10:14:13 +00:00
|
|
|
header.subTitle: name
|
|
|
|
contentItem: StatusBaseText {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
height: contentHeight + topPadding + bottomPadding
|
|
|
|
text: deleteAddressConfirm.text
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
topPadding: Style.current.padding
|
|
|
|
rightPadding: Style.current.padding
|
|
|
|
bottomPadding: Style.current.padding
|
|
|
|
leftPadding: Style.current.padding
|
|
|
|
}
|
|
|
|
rightButtons: [
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
onClicked: deleteAddressConfirm.close()
|
|
|
|
},
|
|
|
|
StatusButton {
|
|
|
|
type: StatusBaseButton.Type.Danger
|
2022-08-04 09:06:15 +00:00
|
|
|
objectName: "confirmDeleteSavedAddress"
|
2022-03-01 10:14:13 +00:00
|
|
|
text: qsTr("Delete")
|
|
|
|
onClicked: {
|
|
|
|
_internal.loading = true
|
|
|
|
_internal.error = RootStore.deleteSavedAddress(deleteAddressConfirm.address)
|
|
|
|
deleteAddressConfirm.close()
|
|
|
|
_internal.loading = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
SavedAddressesError {
|
|
|
|
id: errorMessage
|
|
|
|
anchors.top: header.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
visible: _internal.error !== ""
|
|
|
|
text: _internal.error
|
|
|
|
height: visible ? 36 : 0
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: listView.count === 0
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
text: qsTr("No saved addresses")
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
|
|
|
id: listView
|
2022-08-03 10:08:46 +00:00
|
|
|
objectName: "savedAddresses"
|
2022-03-01 10:14:13 +00:00
|
|
|
anchors.top: errorMessage.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: Style.current.halfPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
visible: listView.count > 0
|
2022-07-14 11:03:36 +00:00
|
|
|
spacing: 5
|
|
|
|
model: RootStore.savedAddresses
|
|
|
|
delegate: delegateSavedAddress
|
2022-03-01 10:14:13 +00:00
|
|
|
}
|
|
|
|
}
|