2023-05-19 09:51:47 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
|
|
|
import AppLayouts.Wallet 1.0
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
|
|
|
import AppLayouts.Profile.stores 1.0 as ProfileStores
|
2023-05-19 09:51:47 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\qmltype TransactionAddress
|
|
|
|
\inherits Item
|
|
|
|
\inqmlmodule shared.controls
|
|
|
|
\since shared.controls 1.0
|
|
|
|
\brief It displays transaction address in depending on amount of data provided.
|
|
|
|
|
|
|
|
The \c TransactionAddress should be used to display transaction activity data.
|
|
|
|
|
|
|
|
\qml
|
|
|
|
TransactionAddress {
|
|
|
|
address: "0x29D7d1dd5B6f9C864d9db560D72a247c208aE86B"
|
|
|
|
}
|
|
|
|
\endqml
|
|
|
|
*/
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\qmlproperty string TransactionAddress::address
|
|
|
|
This property holds wallet address.
|
|
|
|
*/
|
|
|
|
property string address
|
|
|
|
|
|
|
|
/* /internal Property hold reference to contacts store to refresh contact data on any change. */
|
2024-05-22 08:13:39 +00:00
|
|
|
property ProfileStores.ContactsStore contactsStore
|
2023-05-19 09:51:47 +00:00
|
|
|
|
2023-05-22 10:16:39 +00:00
|
|
|
/* /internal Property hold reference to root store to refresh wallet data on any change. */
|
2024-05-22 08:13:39 +00:00
|
|
|
property WalletStores.RootStore rootStore
|
2023-05-22 10:16:39 +00:00
|
|
|
|
2023-05-19 09:51:47 +00:00
|
|
|
/*!
|
|
|
|
\qmlproperty \l{StatusAssetSettings} TransactionAddress::asset
|
|
|
|
Property holds asset settings for contact icon.
|
|
|
|
*/
|
|
|
|
property StatusAssetSettings asset: StatusAssetSettings {
|
2023-06-07 11:37:44 +00:00
|
|
|
id: statusAssetSettings
|
2023-05-19 09:51:47 +00:00
|
|
|
width: 36
|
|
|
|
height: 36
|
2023-05-22 10:16:39 +00:00
|
|
|
color: d.isContact ? Utils.colorForPubkey(root.contactPubKey) : d.walletAddressColor
|
|
|
|
name: {
|
|
|
|
if (d.isContact) {
|
2024-01-26 15:28:49 +00:00
|
|
|
return isImage ? d.contactData.thumbnailImage : nameText.text
|
2023-05-22 10:16:39 +00:00
|
|
|
} else if (d.isWallet && !d.walletAddressEmoji) {
|
|
|
|
return "filled-account"
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
2024-01-26 15:28:49 +00:00
|
|
|
isImage: d.isContact && statusAssetSettings.isImgSrc(d.contactData.thumbnailImage)
|
2023-05-22 10:16:39 +00:00
|
|
|
emoji: d.isWallet && !!d.walletAddressEmoji ? d.walletAddressEmoji : ""
|
2023-05-19 09:51:47 +00:00
|
|
|
isLetterIdenticon: d.isContact && !isImage
|
|
|
|
charactersLen: 2
|
|
|
|
}
|
|
|
|
|
2023-06-30 15:07:53 +00:00
|
|
|
implicitHeight: Math.max(44, contentColumn.height) + 12
|
2023-05-19 09:51:47 +00:00
|
|
|
|
2024-02-14 10:49:22 +00:00
|
|
|
onAddressChanged: {
|
|
|
|
d.refresh()
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
d.refresh()
|
|
|
|
}
|
|
|
|
|
2023-05-19 09:51:47 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
2023-05-22 10:16:39 +00:00
|
|
|
|
|
|
|
property string contactPubKey: !!root.contactsStore ? root.contactsStore.getContactPublicKeyByAddress(root.address) : ""
|
|
|
|
readonly property bool isContact: contactData.isContact
|
|
|
|
readonly property bool isWallet: !isContact && !!walletAddressName
|
2023-06-12 08:14:19 +00:00
|
|
|
property var contactData
|
|
|
|
property string savedAddressName
|
|
|
|
property string walletAddressName
|
|
|
|
property string walletAddressEmoji
|
|
|
|
property string walletAddressColor
|
|
|
|
|
2024-02-14 10:49:22 +00:00
|
|
|
function refresh() {
|
2023-06-12 08:14:19 +00:00
|
|
|
refreshContactData()
|
|
|
|
refreshSavedAddressName()
|
|
|
|
refreshWalletAddress()
|
|
|
|
}
|
2023-05-19 09:51:47 +00:00
|
|
|
|
|
|
|
function refreshContactData() {
|
2023-05-22 10:16:39 +00:00
|
|
|
d.contactData = Utils.getContactDetailsAsJson(d.contactPubKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
function refreshSavedAddressName() {
|
2023-12-29 13:10:55 +00:00
|
|
|
if (!root.rootStore) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
let savedAddress = root.rootStore.getSavedAddress(root.address)
|
|
|
|
d.savedAddressName = savedAddress.name
|
2023-05-22 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function refreshWalletAddress() {
|
|
|
|
d.walletAddressName = !!root.rootStore ? root.rootStore.getNameForWalletAddress(root.address) : ""
|
2023-06-15 13:09:35 +00:00
|
|
|
if (!d.walletAddressName)
|
|
|
|
return // No need to query other if name not found
|
2023-05-22 10:16:39 +00:00
|
|
|
d.walletAddressEmoji = !!root.rootStore ? root.rootStore.getEmojiForWalletAddress(root.address) : ""
|
2023-06-12 08:14:19 +00:00
|
|
|
d.walletAddressColor = Utils.getColorForId(!!root.rootStore ? root.rootStore.getColorForWalletAddress(root.address) : "")
|
2023-05-22 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
readonly property Connections walletAccountsConnection: Connections {
|
|
|
|
target: !!root.rootStore ? root.rootStore.accounts ?? null : null
|
|
|
|
function onItemChanged(address) {
|
|
|
|
if (address === root.address)
|
|
|
|
d.refreshWalletAddress()
|
|
|
|
}
|
2023-05-19 09:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
readonly property Connections myContactsModelConnection: Connections {
|
|
|
|
target: root.contactsStore.myContactsModel ?? null
|
|
|
|
function onItemChanged(pubKey) {
|
|
|
|
if (pubKey === root.contactPubKey)
|
|
|
|
d.refreshContactData()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
readonly property Connections receivedContactsReqModelConnection: Connections {
|
|
|
|
target: root.contactsStore.receivedContactRequestsModel ?? null
|
|
|
|
function onItemChanged(pubKey) {
|
|
|
|
if (pubKey === root.contactPubKey)
|
|
|
|
d.refreshContactData()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
readonly property Connections sentContactReqModelConnection: Connections {
|
|
|
|
target: root.contactsStore.sentContactRequestsModel ?? null
|
|
|
|
function onItemChanged(pubKey) {
|
|
|
|
if (pubKey === root.contactPubKey)
|
|
|
|
d.refreshContactData()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: contentRow
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
StatusSmartIdenticon {
|
|
|
|
id: identicon
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
asset: root.asset
|
|
|
|
name: nameText.text
|
|
|
|
ringSettings {
|
|
|
|
ringSpecModel: d.isContact ? Utils.getColorHashAsJson(d.contactData.publicKey) : []
|
|
|
|
ringPxSize: asset.width / 24
|
|
|
|
}
|
2023-05-22 10:16:39 +00:00
|
|
|
visible: d.isContact || d.isWallet
|
2023-05-19 09:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: contentColumn
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: nameText
|
|
|
|
Layout.fillWidth: true
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
2024-02-14 10:49:22 +00:00
|
|
|
text: {
|
|
|
|
let name = ""
|
|
|
|
if (d.isContact) {
|
|
|
|
name = ProfileUtils.displayName(d.contactData.localNickname, d.contactData.name, d.contactData.displayName, d.contactData.alias)
|
|
|
|
}
|
|
|
|
return name || d.walletAddressName || d.savedAddressName
|
|
|
|
}
|
2023-05-19 09:51:47 +00:00
|
|
|
visible: !!text
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
wrapMode: Text.WrapAnywhere
|
2023-05-31 09:25:16 +00:00
|
|
|
enabled: false // Set to false to disable hover for rich text
|
2024-10-04 15:23:26 +00:00
|
|
|
text: root.address
|
2023-05-19 09:51:47 +00:00
|
|
|
visible: !!root.address
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|