2021-02-08 12:21:23 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-12-08 21:20:43 +00:00
|
|
|
import shared.stores 1.0
|
2021-10-18 10:34:16 +00:00
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2021-10-14 12:21:08 +00:00
|
|
|
import "../"
|
|
|
|
import "../status"
|
|
|
|
import "../panels"
|
2021-10-01 15:58:36 +00:00
|
|
|
import "./"
|
2021-02-08 12:21:23 +00:00
|
|
|
|
2021-10-20 22:47:23 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
2021-02-08 12:21:23 +00:00
|
|
|
Item {
|
|
|
|
id: root
|
2022-02-03 10:39:46 +00:00
|
|
|
width: parent.width
|
2022-04-06 17:13:49 +00:00
|
|
|
height: hasExistingContacts ? 64 : 0
|
2022-02-03 10:39:46 +00:00
|
|
|
|
2021-02-08 12:21:23 +00:00
|
|
|
property bool hasExistingContacts: false
|
|
|
|
property bool showProfileNotFoundMessage: false
|
|
|
|
property bool loading: false
|
|
|
|
property string username: ""
|
|
|
|
property string userAlias: ""
|
|
|
|
property string pubKey: ""
|
2021-04-13 17:49:24 +00:00
|
|
|
property string address: ""
|
2021-03-22 14:46:50 +00:00
|
|
|
property bool resultClickable: true
|
2021-07-13 09:57:11 +00:00
|
|
|
property bool addContactEnabled: true
|
2022-02-03 10:39:46 +00:00
|
|
|
property bool isAddedContact: false
|
2022-01-10 16:44:54 +00:00
|
|
|
|
2022-01-12 17:56:41 +00:00
|
|
|
signal resultClicked(string pubKey, bool isAddedContact, string username)
|
2021-02-08 12:21:23 +00:00
|
|
|
signal addToContactsButtonClicked(string pubKey)
|
2021-03-22 14:46:50 +00:00
|
|
|
|
|
|
|
function reset() {
|
|
|
|
hasExistingContacts = false
|
|
|
|
showProfileNotFoundMessage = false
|
|
|
|
username = ""
|
|
|
|
userAlias = ""
|
|
|
|
pubKey = ""
|
2022-02-03 10:39:46 +00:00
|
|
|
isAddedContact = false
|
2021-03-22 14:46:50 +00:00
|
|
|
}
|
|
|
|
|
2022-07-06 16:51:56 +00:00
|
|
|
function isUserAdded() {
|
|
|
|
return root.pubKey != "" ? Utils.getContactDetailsAsJson(root.pubKey).isAdded : false
|
2022-02-03 10:39:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onPubKeyChanged: {
|
2022-07-06 16:51:56 +00:00
|
|
|
root.isAddedContact = root.isUserAdded()
|
2022-02-03 10:39:46 +00:00
|
|
|
}
|
2021-02-08 12:21:23 +00:00
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: nonContactsLabel
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Non contacts")
|
2021-02-08 12:21:23 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.pixelSize: 15
|
|
|
|
visible: root.hasExistingContacts && (root.loading || root.pubKey !== "" || root.showProfileNotFoundMessage)
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
active: root.loading
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
sourceComponent: Component {
|
|
|
|
LoadingAnimation {
|
|
|
|
width: 18
|
|
|
|
height: 18
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: foundContact
|
|
|
|
property bool hovered: false
|
|
|
|
anchors.top: nonContactsLabel.visible ? nonContactsLabel.bottom : parent.top
|
|
|
|
color: hovered ? Style.current.backgroundHover : Style.current.background
|
|
|
|
radius: Style.current.radius
|
|
|
|
width: parent.width
|
|
|
|
height: 64
|
|
|
|
visible: root.pubKey !== "" && !root.loading
|
|
|
|
|
2021-10-20 22:47:23 +00:00
|
|
|
StatusSmartIdenticon {
|
2021-02-08 12:21:23 +00:00
|
|
|
id: contactIdenticon
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
2022-06-20 13:27:00 +00:00
|
|
|
name: root.username
|
2021-02-08 12:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: ensUsername
|
|
|
|
font.pixelSize: 17
|
|
|
|
color: Style.current.textColor
|
|
|
|
anchors.top: contactIdenticon.top
|
|
|
|
anchors.left: contactIdenticon.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
text: root.username
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: contactAlias
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
anchors.top: ensUsername.bottom
|
|
|
|
anchors.topMargin: 2
|
|
|
|
anchors.left: ensUsername.left
|
|
|
|
text: root.userAlias
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
2021-03-22 14:46:50 +00:00
|
|
|
cursorShape: root.resultClickable ? Qt.PointingHandCursor : Qt.ArrowCursor
|
2021-02-08 12:21:23 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: foundContact.hovered = true
|
|
|
|
onExited: foundContact.hovered = false
|
2021-03-22 14:46:50 +00:00
|
|
|
onClicked: {
|
|
|
|
if (root.resultClickable) {
|
2022-01-12 17:56:41 +00:00
|
|
|
root.resultClicked(root.pubKey, root.isAddedContact, root.username)
|
2021-03-22 14:46:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-08 12:21:23 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 10:34:16 +00:00
|
|
|
StatusFlatRoundButton {
|
2021-02-08 12:21:23 +00:00
|
|
|
id: addContactBtn
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.width: 24
|
|
|
|
icon.height: 24
|
|
|
|
icon.name: "add-contact"
|
|
|
|
backgroundHoverColor: Utils.setColorAlpha(Style.current.buttonHoveredBackgroundColor, 0.2)
|
2021-07-13 09:57:11 +00:00
|
|
|
visible: addContactEnabled && !isAddedContact && !checkIcon.visible
|
2021-10-18 10:34:16 +00:00
|
|
|
onClicked: {
|
|
|
|
root.addToContactsButtonClicked(root.pubKey)
|
|
|
|
mouse.accepted = false
|
2021-02-08 12:21:23 +00:00
|
|
|
}
|
2021-10-18 10:34:16 +00:00
|
|
|
onHoveredChanged: foundContact.hovered = addContactBtn.hovered
|
2021-02-08 12:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: checkIcon
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg("check-2")
|
2021-02-08 12:21:23 +00:00
|
|
|
width: 19
|
|
|
|
height: 19
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.smallPadding * 2
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-05-18 15:07:18 +00:00
|
|
|
visible: foundContact.hovered && isAddedContact
|
2021-02-08 12:21:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: profileNotFoundMessage
|
2021-07-07 18:37:49 +00:00
|
|
|
color: Style.current.secondaryText
|
2021-02-08 12:21:23 +00:00
|
|
|
visible: root.showProfileNotFoundMessage
|
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("No profile found")
|
2021-02-08 12:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|