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"
|
2024-01-15 09:20:52 +00:00
|
|
|
import "../stores"
|
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
|
2024-02-02 09:55:56 +00:00
|
|
|
property var networkConnectionStore
|
2022-09-05 09:15:47 +00:00
|
|
|
property string name
|
|
|
|
property string address
|
2022-10-20 13:33:23 +00:00
|
|
|
property string ens
|
2023-12-29 13:10:55 +00:00
|
|
|
property string colorId
|
2023-02-20 10:57:45 +00:00
|
|
|
property string chainShortNames
|
2023-07-03 09:23:26 +00:00
|
|
|
property bool areTestNetworksEnabled: false
|
2024-02-20 09:31:04 +00:00
|
|
|
property bool isGoerliEnabled: false
|
2022-09-05 09:15:47 +00:00
|
|
|
|
2024-02-19 08:40:16 +00:00
|
|
|
property int usage: SavedAddressesDelegate.Usage.Delegate
|
|
|
|
property bool showButtons: sensor.containsMouse
|
|
|
|
|
|
|
|
property alias sendButton: sendButton
|
|
|
|
|
|
|
|
signal aboutToOpenPopup()
|
2023-02-20 10:57:45 +00:00
|
|
|
signal openSendModal(string recipient)
|
2022-09-05 09:15:47 +00:00
|
|
|
|
2024-02-19 08:40:16 +00:00
|
|
|
enum Usage {
|
|
|
|
Delegate,
|
|
|
|
Item
|
|
|
|
}
|
|
|
|
|
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
|
2023-12-29 15:40:14 +00:00
|
|
|
else {
|
|
|
|
return sensor.containsMouse ? WalletUtils.colorizedChainPrefix(root.chainShortNames) +
|
|
|
|
Utils.richColorText(root.address, Theme.palette.directColor1)
|
|
|
|
: root.chainShortNames + root.address
|
|
|
|
}
|
2023-02-20 10:57:45 +00:00
|
|
|
}
|
2023-12-29 15:40:14 +00:00
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
border.color: Theme.palette.baseColor5
|
2023-12-29 15:40:14 +00:00
|
|
|
|
|
|
|
asset {
|
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
color: Utils.getColorForId(root.colorId)
|
|
|
|
isLetterIdenticon: true
|
2024-05-17 17:45:27 +00:00
|
|
|
letterIdenticonBgWithAlpha: true
|
2023-12-29 15:40:14 +00:00
|
|
|
}
|
2023-02-20 10:57:45 +00:00
|
|
|
|
|
|
|
statusListItemIcon.hoverEnabled: true
|
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
statusListItemComponentsSlot.spacing: 0
|
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2024-01-10 09:47:29 +00:00
|
|
|
readonly property string visibleAddress: !!root.ens? root.ens : root.address
|
2024-01-15 12:27:47 +00:00
|
|
|
readonly property var preferredSharedNetworkNamesArray: root.chainShortNames.split(":").filter(Boolean)
|
2023-02-20 10:57:45 +00:00
|
|
|
}
|
|
|
|
|
2024-02-19 08:40:16 +00:00
|
|
|
onClicked: {
|
|
|
|
if (root.usage === SavedAddressesDelegate.Usage.Item) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
Global.openSavedAddressActivityPopup({
|
|
|
|
name: root.name,
|
|
|
|
address: root.address,
|
|
|
|
chainShortNames: root.chainShortNames,
|
|
|
|
ens: root.ens,
|
|
|
|
colorId: root.colorId
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
components: [
|
2024-01-10 08:40:15 +00:00
|
|
|
StatusRoundButton {
|
2024-02-19 08:40:16 +00:00
|
|
|
id: sendButton
|
2024-01-10 08:40:15 +00:00
|
|
|
visible: !!root.name && root.showButtons
|
|
|
|
type: StatusRoundButton.Type.Quinary
|
|
|
|
radius: 8
|
|
|
|
icon.name: "send"
|
2024-02-02 09:55:56 +00:00
|
|
|
enabled: root.networkConnectionStore.sendBuyBridgeEnabled
|
2024-01-10 08:40:15 +00:00
|
|
|
onClicked: root.openSendModal(d.visibleAddress)
|
|
|
|
},
|
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
|
2024-01-10 08:40:15 +00:00
|
|
|
enabled: root.showButtons
|
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: {
|
2024-01-09 13:50:01 +00:00
|
|
|
menu.openMenu(this, x + width - menu.width - statusListItemComponentsSlot.spacing, y + height + Style.current.halfPadding,
|
2023-03-13 11:51:57 +00:00
|
|
|
{
|
|
|
|
name: root.name,
|
|
|
|
address: root.address,
|
|
|
|
chainShortNames: root.chainShortNames,
|
|
|
|
ens: root.ens,
|
2023-12-29 13:10:55 +00:00
|
|
|
colorId: root.colorId,
|
2023-03-13 11:51:57 +00:00
|
|
|
}
|
|
|
|
);
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
2023-03-13 11:51:57 +00:00
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusMenu {
|
2024-01-05 10:57:15 +00:00
|
|
|
id: menu
|
|
|
|
property string name
|
|
|
|
property string address
|
|
|
|
property string chainShortNames
|
|
|
|
property string ens
|
2023-12-29 13:10:55 +00:00
|
|
|
property string colorId
|
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) {
|
2024-01-05 10:57:15 +00:00
|
|
|
menu.name = model.name;
|
|
|
|
menu.address = model.address;
|
|
|
|
menu.chainShortNames = model.chainShortNames;
|
|
|
|
menu.ens = model.ens;
|
|
|
|
menu.colorId = model.colorId;
|
2023-03-13 11:51:57 +00:00
|
|
|
popup(parent, x, y);
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
onClosed: {
|
2024-01-05 10:57:15 +00:00
|
|
|
menu.name = "";
|
|
|
|
menu.address = "";
|
|
|
|
menu.chainShortNames = ""
|
|
|
|
menu.ens = ""
|
|
|
|
menu.colorId = ""
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
2024-01-16 07:50:25 +00:00
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2023-12-29 15:40:14 +00:00
|
|
|
text: qsTr("Edit saved address")
|
2024-01-04 15:53:04 +00:00
|
|
|
objectName: "editSavedAddress"
|
2022-09-05 09:15:47 +00:00
|
|
|
assetSettings.name: "pencil-outline"
|
|
|
|
onTriggered: {
|
2024-02-19 08:40:16 +00:00
|
|
|
if (root.usage === SavedAddressesDelegate.Usage.Item) {
|
|
|
|
root.aboutToOpenPopup()
|
|
|
|
}
|
2023-12-26 10:19:41 +00:00
|
|
|
Global.openAddEditSavedAddressesPopup({
|
|
|
|
edit: true,
|
2024-01-05 10:57:15 +00:00
|
|
|
address: menu.address,
|
|
|
|
name: menu.name,
|
|
|
|
chainShortNames: menu.chainShortNames,
|
|
|
|
ens: menu.ens,
|
|
|
|
colorId: menu.colorId
|
2023-12-26 10:19:41 +00:00
|
|
|
})
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-16 07:50:25 +00:00
|
|
|
|
2024-01-10 09:47:29 +00:00
|
|
|
StatusSuccessAction {
|
|
|
|
id: copyAddressAction
|
2023-02-20 10:57:45 +00:00
|
|
|
objectName: "copySavedAddressAction"
|
2024-01-10 09:47:29 +00:00
|
|
|
successText: qsTr("Address copied")
|
|
|
|
text: qsTr("Copy address")
|
|
|
|
icon.name: "copy"
|
|
|
|
timeout: 1500
|
|
|
|
autoDismissMenu: true
|
2023-02-20 10:57:45 +00:00
|
|
|
onTriggered: {
|
2024-01-10 09:47:29 +00:00
|
|
|
store.copyToClipboard(d.visibleAddress)
|
2023-02-20 10:57:45 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-16 07:50:25 +00:00
|
|
|
|
2023-12-29 15:40:14 +00:00
|
|
|
StatusAction {
|
|
|
|
text: qsTr("Show address QR")
|
|
|
|
objectName: "showQrSavedAddressAction"
|
|
|
|
assetSettings.name: "qr"
|
|
|
|
onTriggered: {
|
2024-02-19 08:40:16 +00:00
|
|
|
if (root.usage === SavedAddressesDelegate.Usage.Item) {
|
|
|
|
root.aboutToOpenPopup()
|
|
|
|
}
|
2024-01-15 09:20:52 +00:00
|
|
|
Global.openShowQRPopup({
|
|
|
|
showSingleAccount: true,
|
|
|
|
showForSavedAddress: true,
|
|
|
|
switchingAccounsEnabled: false,
|
|
|
|
changingPreferredChainsEnabled: true,
|
|
|
|
hasFloatingButtons: true,
|
|
|
|
name: menu.name,
|
|
|
|
address: menu.address,
|
|
|
|
colorId: menu.colorId,
|
|
|
|
preferredSharingChainIds: RootStore.getNetworkIds(menu.chainShortNames)
|
|
|
|
})
|
2023-12-29 15:40:14 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-15 12:27:47 +00:00
|
|
|
|
2024-01-16 07:50:25 +00:00
|
|
|
StatusAction {
|
|
|
|
text: qsTr("View activity")
|
|
|
|
objectName: "viewActivitySavedAddressAction"
|
|
|
|
assetSettings.name: "wallet"
|
|
|
|
onTriggered: {
|
2024-02-19 08:40:16 +00:00
|
|
|
if (root.usage === SavedAddressesDelegate.Usage.Item) {
|
|
|
|
root.aboutToOpenPopup()
|
|
|
|
}
|
2024-01-16 07:50:25 +00:00
|
|
|
Global.changeAppSectionBySectionType(Constants.appSection.wallet,
|
|
|
|
WalletLayout.LeftPanelSelection.AllAddresses,
|
|
|
|
WalletLayout.RightPanelSelection.Activity,
|
|
|
|
{savedAddress: menu.address})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-15 12:27:47 +00:00
|
|
|
StatusMenuSeparator {
|
|
|
|
visible: d.preferredSharedNetworkNamesArray.length > 0
|
|
|
|
}
|
2023-07-03 09:23:26 +00:00
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
StatusAction {
|
2024-01-15 12:27:47 +00:00
|
|
|
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.mainnet)
|
|
|
|
enabled: d.preferredSharedNetworkNamesArray.includes(Constants.networkShortChainNames.mainnet)
|
|
|
|
icon.name: "link"
|
2023-02-20 10:57:45 +00:00
|
|
|
onTriggered: {
|
2024-02-20 09:31:04 +00:00
|
|
|
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.mainnet, root.areTestNetworksEnabled, root.isGoerliEnabled, d.visibleAddress ? d.visibleAddress : root.ens)
|
2024-01-15 12:27:47 +00:00
|
|
|
Global.openLink(link)
|
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 {
|
2024-03-15 16:43:12 +00:00
|
|
|
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.arbitrum)
|
|
|
|
enabled: d.preferredSharedNetworkNamesArray.includes(Constants.networkShortChainNames.arbitrum)
|
2024-01-15 12:27:47 +00:00
|
|
|
icon.name: "link"
|
2023-03-13 11:51:57 +00:00
|
|
|
onTriggered: {
|
2024-03-15 16:43:12 +00:00
|
|
|
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.arbitrum, root.areTestNetworksEnabled, root.isGoerliEnabled, d.visibleAddress ? d.visibleAddress : root.ens)
|
2024-01-15 12:27:47 +00:00
|
|
|
Global.openLink(link)
|
2023-03-13 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-15 12:27:47 +00:00
|
|
|
|
2023-03-13 11:51:57 +00:00
|
|
|
StatusAction {
|
2024-01-15 12:27:47 +00:00
|
|
|
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.optimism)
|
|
|
|
enabled: d.preferredSharedNetworkNamesArray.includes(Constants.networkShortChainNames.optimism)
|
|
|
|
icon.name: "link"
|
2023-03-13 11:51:57 +00:00
|
|
|
onTriggered: {
|
2024-02-20 09:31:04 +00:00
|
|
|
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.optimism, root.areTestNetworksEnabled, root.isGoerliEnabled, d.visibleAddress ? d.visibleAddress : root.ens)
|
2024-01-15 12:27:47 +00:00
|
|
|
Global.openLink(link)
|
2023-03-13 11:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-15 12:27:47 +00:00
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
StatusMenuSeparator { }
|
2024-01-15 12:27:47 +00:00
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2023-12-29 15:40:14 +00:00
|
|
|
text: qsTr("Remove saved address")
|
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: {
|
2024-02-19 08:40:16 +00:00
|
|
|
if (root.usage === SavedAddressesDelegate.Usage.Item) {
|
|
|
|
root.aboutToOpenPopup()
|
|
|
|
}
|
2023-12-26 10:19:41 +00:00
|
|
|
Global.openDeleteSavedAddressesPopup({
|
2024-01-05 10:57:15 +00:00
|
|
|
name: menu.name,
|
|
|
|
address: menu.address,
|
|
|
|
ens: menu.ens,
|
|
|
|
colorId: menu.colorId,
|
|
|
|
chainShortNames: menu.chainShortNames
|
2023-12-26 10:19:41 +00:00
|
|
|
})
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|