2022-09-05 09:15:47 +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
|
2022-08-18 14:44:48 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2022-09-05 09:15:47 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import shared.controls 1.0
|
|
|
|
|
|
|
|
import "../popups"
|
|
|
|
import "../controls"
|
|
|
|
|
|
|
|
StatusListItem {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var store
|
|
|
|
property var contactsStore
|
|
|
|
property string name
|
|
|
|
property string address
|
2022-08-18 14:44:48 +00:00
|
|
|
property bool favourite: false
|
|
|
|
property var saveAddress: function (name, address, favourite) {}
|
2022-09-05 09:15:47 +00:00
|
|
|
property var deleteSavedAddress: function (address) {}
|
2022-08-18 14:44:48 +00:00
|
|
|
// TODO: fetch this from status-go
|
|
|
|
readonly property string ensName: ""
|
2022-09-05 09:15:47 +00:00
|
|
|
|
|
|
|
signal openSendModal()
|
|
|
|
|
|
|
|
implicitWidth: parent.width
|
|
|
|
|
|
|
|
title: name
|
|
|
|
objectName: name
|
2022-08-18 14:44:48 +00:00
|
|
|
subTitle: (ensName.length > 0 ? ensName + " \u2022 " : "")
|
|
|
|
+ Utils.elideText(address, 6, 4)
|
2022-09-05 09:15:47 +00:00
|
|
|
color: "transparent"
|
|
|
|
border.color: Theme.palette.baseColor5
|
2022-08-18 14:44:48 +00:00
|
|
|
titleTextIcon: root.favourite ? "star-icon" : ""
|
2022-09-05 09:15:47 +00:00
|
|
|
statusListItemComponentsSlot.spacing: 0
|
|
|
|
property bool showButtons: sensor.containsMouse
|
|
|
|
|
|
|
|
components: [
|
|
|
|
StatusRoundButton {
|
|
|
|
icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
icon.name: "send"
|
|
|
|
onClicked: openSendModal()
|
|
|
|
},
|
|
|
|
CopyToClipBoardButton {
|
|
|
|
id: copyButton
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
store: root.store
|
|
|
|
textToCopy: root.address
|
|
|
|
},
|
2022-08-18 14:44:48 +00:00
|
|
|
StatusRoundButton {
|
2022-08-24 08:23:43 +00:00
|
|
|
objectName: "savedAddressView_Delegate_favouriteButton"
|
2022-08-18 14:44:48 +00:00
|
|
|
icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
icon.name: root.favourite ? "unfavourite" : "favourite"
|
|
|
|
onClicked: {
|
|
|
|
root.saveAddress(root.name, root.address, !root.favourite)
|
|
|
|
}
|
|
|
|
},
|
2022-09-05 09:15:47 +00:00
|
|
|
StatusRoundButton {
|
2022-08-24 08:23:43 +00:00
|
|
|
objectName: "savedAddressView_Delegate_menuButton"
|
2022-09-05 09:15:47 +00:00
|
|
|
visible: !!root.name
|
|
|
|
icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
icon.name: "more"
|
|
|
|
onClicked: {
|
2022-08-18 14:44:48 +00:00
|
|
|
editDeleteMenu.openMenu(root.name, root.address, root.favourite);
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
StatusRoundButton {
|
|
|
|
visible: !root.name
|
|
|
|
icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
icon.name: "add"
|
|
|
|
onClicked: {
|
|
|
|
Global.openPopup(addEditSavedAddress,
|
|
|
|
{
|
|
|
|
addAddress: true,
|
|
|
|
address: root.address
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
StatusPopupMenu {
|
|
|
|
id: editDeleteMenu
|
|
|
|
property string contactName
|
|
|
|
property string contactAddress
|
2022-08-18 14:44:48 +00:00
|
|
|
property bool storeFavourite
|
|
|
|
function openMenu(name, address, favourite) {
|
2022-09-05 09:15:47 +00:00
|
|
|
contactName = name;
|
|
|
|
contactAddress = address;
|
2022-08-18 14:44:48 +00:00
|
|
|
storeFavourite = favourite;
|
2022-09-05 09:15:47 +00:00
|
|
|
popup();
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
contactName = "";
|
|
|
|
contactAddress = "";
|
2022-08-18 14:44:48 +00:00
|
|
|
storeFavourite = false;
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Edit")
|
|
|
|
objectName: "editroot"
|
|
|
|
assetSettings.name: "pencil-outline"
|
|
|
|
onTriggered: {
|
|
|
|
Global.openPopup(addEditSavedAddress,
|
|
|
|
{
|
|
|
|
edit: true,
|
|
|
|
address: editDeleteMenu.contactAddress,
|
2022-08-18 14:44:48 +00:00
|
|
|
name: editDeleteMenu.contactName,
|
|
|
|
favourite: editDeleteMenu.storeFavourite
|
2022-09-05 09:15:47 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusMenuSeparator { }
|
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Delete")
|
|
|
|
type: StatusMenuItem.Type.Danger
|
|
|
|
assetSettings.name: "delete"
|
|
|
|
objectName: "deleteSavedAddress"
|
|
|
|
onTriggered: {
|
|
|
|
deleteAddressConfirm.name = editDeleteMenu.contactName;
|
|
|
|
deleteAddressConfirm.address = editDeleteMenu.contactAddress;
|
2022-08-18 14:44:48 +00:00
|
|
|
deleteAddressConfirm.favourite = editDeleteMenu.storeFavourite;
|
2022-09-05 09:15:47 +00:00
|
|
|
deleteAddressConfirm.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: addEditSavedAddress
|
|
|
|
AddEditSavedAddressPopup {
|
|
|
|
id: addEditModal
|
|
|
|
anchors.centerIn: parent
|
|
|
|
onClosed: destroy()
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
onSave: {
|
2022-08-18 14:44:48 +00:00
|
|
|
root.saveAddress(name, address, favourite)
|
2022-09-05 09:15:47 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusModal {
|
|
|
|
id: deleteAddressConfirm
|
|
|
|
property string address
|
|
|
|
property string name
|
2022-08-18 14:44:48 +00:00
|
|
|
property bool favourite
|
2022-09-05 09:15:47 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
header.title: qsTr("Are you sure?")
|
|
|
|
header.subTitle: name
|
|
|
|
contentItem: StatusBaseText {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
height: contentHeight + topPadding + bottomPadding
|
|
|
|
text: qsTr("Are you sure you want to remove '%1' from your saved addresses?").arg(name)
|
|
|
|
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
|
|
|
|
objectName: "confirmDeleteSavedAddress"
|
|
|
|
text: qsTr("Delete")
|
|
|
|
onClicked: {
|
|
|
|
root.deleteSavedAddress(deleteAddressConfirm.address)
|
|
|
|
deleteAddressConfirm.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|