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
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import shared.controls 1.0
|
|
|
|
|
|
|
|
import "../popups"
|
|
|
|
import "../controls"
|
2023-02-20 10:57:45 +00:00
|
|
|
import ".."
|
2022-09-05 09:15:47 +00:00
|
|
|
|
|
|
|
StatusListItem {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var store
|
|
|
|
property var contactsStore
|
|
|
|
property string name
|
|
|
|
property string address
|
2022-10-20 13:33:23 +00:00
|
|
|
property string ens
|
2023-02-20 10:57:45 +00:00
|
|
|
property string chainShortNames
|
2022-08-18 14:44:48 +00:00
|
|
|
property bool favourite: false
|
2023-07-03 09:23:26 +00:00
|
|
|
property bool areTestNetworksEnabled: false
|
2023-02-20 10:57:45 +00:00
|
|
|
property var saveAddress: function (name, address, favourite, chainShortNames, ens) {}
|
|
|
|
property var deleteSavedAddress: function (address, ens) {}
|
2022-09-05 09:15:47 +00:00
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
signal openSendModal(string recipient)
|
2022-09-05 09:15:47 +00:00
|
|
|
|
2023-04-04 12:09:36 +00:00
|
|
|
implicitWidth: ListView.view ? ListView.view.width : 0
|
2022-09-05 09:15:47 +00:00
|
|
|
|
|
|
|
title: name
|
|
|
|
objectName: name
|
2023-02-20 10:57:45 +00:00
|
|
|
subTitle: {
|
|
|
|
if (ens.length > 0)
|
|
|
|
return ens
|
|
|
|
else
|
|
|
|
return WalletUtils.colorizedChainPrefix(chainShortNames) + address
|
|
|
|
}
|
2022-09-05 09:15:47 +00:00
|
|
|
border.color: Theme.palette.baseColor5
|
2023-03-14 08:43:33 +00:00
|
|
|
asset.name: d.favouriteEnabled ? (root.favourite ? "star-icon" : "favourite") : ""
|
2023-02-20 10:57:45 +00:00
|
|
|
asset.color: root.favourite ? Theme.palette.pinColor1 : (showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1) // star icon color default
|
|
|
|
asset.hoverColor: root.favourite ? "transparent": Theme.palette.directColor1 // star icon color on hover
|
|
|
|
asset.bgColor: statusListItemIcon.hovered ? Theme.palette.primaryColor3 : "transparent" // icon outer background color
|
|
|
|
asset.bgRadius: 8
|
|
|
|
|
|
|
|
statusListItemIcon.hoverEnabled: true
|
|
|
|
|
|
|
|
onIconClicked: {
|
|
|
|
root.saveAddress(root.name, root.address, !root.favourite, root.chainShortNames, root.ens)
|
|
|
|
}
|
|
|
|
|
|
|
|
statusListItemSubTitle.font.pixelSize: 13
|
|
|
|
statusListItemSubTitle.customColor: !enabled ? Theme.palette.baseColor1 : Theme.palette.directColor1
|
2022-09-05 09:15:47 +00:00
|
|
|
statusListItemComponentsSlot.spacing: 0
|
|
|
|
property bool showButtons: sensor.containsMouse
|
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property string visibleAddress: root.address == Constants.zeroAddress ? root.ens : root.address
|
2023-03-14 08:43:33 +00:00
|
|
|
readonly property bool favouriteEnabled: false // Disabling favourite functionality until good times
|
2023-02-20 10:57:45 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
components: [
|
|
|
|
StatusRoundButton {
|
|
|
|
icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
2023-02-20 10:57:45 +00:00
|
|
|
type: StatusRoundButton.Type.Quinary
|
|
|
|
radius: 8
|
2022-09-05 09:15:47 +00:00
|
|
|
icon.name: "send"
|
2023-02-20 10:57:45 +00:00
|
|
|
onClicked: openSendModal(d.visibleAddress)
|
2022-08-18 14:44:48 +00:00
|
|
|
},
|
2022-09-05 09:15:47 +00:00
|
|
|
StatusRoundButton {
|
2023-03-06 12:30:58 +00:00
|
|
|
objectName: "savedAddressView_Delegate_menuButton_" + root.name
|
2022-09-05 09:15:47 +00:00
|
|
|
visible: !!root.name
|
|
|
|
icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
2023-02-20 10:57:45 +00:00
|
|
|
type: StatusRoundButton.Type.Quinary
|
|
|
|
radius: 8
|
2022-09-05 09:15:47 +00:00
|
|
|
icon.name: "more"
|
|
|
|
onClicked: {
|
2023-03-13 11:51:57 +00:00
|
|
|
editDeleteMenu.openMenu(this, x - editDeleteMenu.width - statusListItemComponentsSlot.spacing, y + height + Style.current.halfPadding,
|
|
|
|
{
|
|
|
|
name: root.name,
|
|
|
|
address: root.address,
|
|
|
|
favourite: root.favourite,
|
|
|
|
chainShortNames: root.chainShortNames,
|
|
|
|
ens: root.ens,
|
|
|
|
}
|
|
|
|
);
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
2023-03-13 11:51:57 +00:00
|
|
|
|
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,
|
2023-02-20 10:57:45 +00:00
|
|
|
address: d.visibleAddress,
|
|
|
|
ens: root.ens
|
2022-09-05 09:15:47 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusMenu {
|
2022-09-05 09:15:47 +00:00
|
|
|
id: editDeleteMenu
|
|
|
|
property string contactName
|
|
|
|
property string contactAddress
|
2022-08-18 14:44:48 +00:00
|
|
|
property bool storeFavourite
|
2023-02-20 10:57:45 +00:00
|
|
|
property string contactChainShortNames
|
|
|
|
property string contactEns
|
2023-03-13 11:51:57 +00:00
|
|
|
|
|
|
|
readonly property int maxHeight: 341
|
|
|
|
height: implicitHeight > maxHeight ? maxHeight : implicitHeight
|
|
|
|
contentWidth: 216
|
|
|
|
|
|
|
|
function openMenu(parent, x, y, model) {
|
|
|
|
contactName = model.name;
|
|
|
|
contactAddress = model.address;
|
|
|
|
storeFavourite = model.favourite;
|
|
|
|
contactChainShortNames = model.chainShortNames;
|
|
|
|
contactEns = model.ens;
|
|
|
|
popup(parent, x, y);
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
contactName = "";
|
|
|
|
contactAddress = "";
|
2022-08-18 14:44:48 +00:00
|
|
|
storeFavourite = false;
|
2023-02-20 10:57:45 +00:00
|
|
|
contactChainShortNames = ""
|
|
|
|
contactEns = ""
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-09-05 09:15:47 +00:00
|
|
|
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,
|
2023-02-20 10:57:45 +00:00
|
|
|
favourite: editDeleteMenu.storeFavourite,
|
|
|
|
chainShortNames: editDeleteMenu.contactChainShortNames,
|
|
|
|
ens: editDeleteMenu.contactEns
|
2022-09-05 09:15:47 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2023-02-20 10:57:45 +00:00
|
|
|
StatusAction {
|
|
|
|
text: qsTr("Copy")
|
|
|
|
objectName: "copySavedAddressAction"
|
|
|
|
assetSettings.name: "copy"
|
|
|
|
onTriggered: {
|
|
|
|
if (d.visibleAddress)
|
|
|
|
store.copyToClipboard(d.visibleAddress)
|
|
|
|
else
|
|
|
|
store.copyToClipboard(root.ens)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusMenuSeparator { }
|
2023-07-03 09:23:26 +00:00
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
StatusAction {
|
|
|
|
text: qsTr("View on Etherscan")
|
|
|
|
objectName: "viewOnEtherscanAction"
|
|
|
|
assetSettings.name: "external"
|
|
|
|
onTriggered: {
|
2023-07-03 09:23:26 +00:00
|
|
|
var baseUrl = Constants.networkExplorerLinks.etherscan
|
|
|
|
if (root.areTestNetworksEnabled) {
|
|
|
|
baseUrl = Constants.networkExplorerLinks.goerliEtherscan
|
|
|
|
}
|
2023-07-21 10:55:36 +00:00
|
|
|
Global.openLink("%1/%2/%3".arg(baseUrl).arg(Constants.networkExplorerLinks.addressPath).arg(d.visibleAddress ? d.visibleAddress : root.ens))
|
2023-02-20 10:57:45 +00:00
|
|
|
}
|
|
|
|
}
|
2023-07-03 09:23:26 +00:00
|
|
|
|
2023-03-13 11:51:57 +00:00
|
|
|
StatusAction {
|
|
|
|
text: qsTr("View on Arbiscan")
|
|
|
|
objectName: "viewOnArbiscanAction"
|
|
|
|
assetSettings.name: "external"
|
|
|
|
onTriggered: {
|
2023-07-03 09:23:26 +00:00
|
|
|
var baseUrl = Constants.networkExplorerLinks.arbiscan
|
|
|
|
if (root.areTestNetworksEnabled) {
|
|
|
|
baseUrl = Constants.networkExplorerLinks.goerliArbiscan
|
|
|
|
}
|
2023-07-21 10:55:36 +00:00
|
|
|
Global.openLink("%1/%2/%3".arg(baseUrl).arg(Constants.networkExplorerLinks.addressPath).arg(d.visibleAddress ? d.visibleAddress : root.ens))
|
2023-03-13 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusAction {
|
|
|
|
text: qsTr("View on Optimism Explorer")
|
|
|
|
objectName: "viewOnOptimismExplorerAction"
|
|
|
|
assetSettings.name: "external"
|
|
|
|
onTriggered: {
|
2023-07-03 09:23:26 +00:00
|
|
|
var baseUrl = Constants.networkExplorerLinks.optimistic
|
|
|
|
if (root.areTestNetworksEnabled) {
|
|
|
|
baseUrl = Constants.networkExplorerLinks.goerliOptimistic
|
|
|
|
}
|
2023-07-21 10:55:36 +00:00
|
|
|
Global.openLink("%1/%2/%3".arg(baseUrl).arg(Constants.networkExplorerLinks.addressPath).arg(d.visibleAddress ? d.visibleAddress : root.ens))
|
2023-03-13 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-05 09:15:47 +00:00
|
|
|
StatusMenuSeparator { }
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-09-05 09:15:47 +00:00
|
|
|
text: qsTr("Delete")
|
2022-12-01 16:58:37 +00:00
|
|
|
type: StatusAction.Type.Danger
|
2022-09-05 09:15:47 +00:00
|
|
|
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;
|
2023-02-20 10:57:45 +00:00
|
|
|
deleteAddressConfirm.ens = editDeleteMenu.contactEns
|
2022-09-05 09:15:47 +00:00
|
|
|
deleteAddressConfirm.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: addEditSavedAddress
|
|
|
|
AddEditSavedAddressPopup {
|
|
|
|
id: addEditModal
|
|
|
|
anchors.centerIn: parent
|
|
|
|
onClosed: destroy()
|
|
|
|
contactsStore: root.contactsStore
|
2023-02-20 10:57:45 +00:00
|
|
|
store: root.store
|
2022-09-05 09:15:47 +00:00
|
|
|
onSave: {
|
2023-02-20 10:57:45 +00:00
|
|
|
root.saveAddress(name, address, favourite, chainShortNames, ens)
|
2022-09-05 09:15:47 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusModal {
|
|
|
|
id: deleteAddressConfirm
|
|
|
|
property string address
|
2023-02-20 10:57:45 +00:00
|
|
|
property string ens
|
2022-09-05 09:15:47 +00:00
|
|
|
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
|
2023-05-23 12:46:16 +00:00
|
|
|
headerSettings.title: qsTr("Are you sure?")
|
|
|
|
headerSettings.subTitle: name
|
2022-09-05 09:15:47 +00:00
|
|
|
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: {
|
2023-02-20 10:57:45 +00:00
|
|
|
root.deleteSavedAddress(deleteAddressConfirm.address, deleteAddressConfirm.ens)
|
2022-09-05 09:15:47 +00:00
|
|
|
deleteAddressConfirm.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|