2021-02-08 12:21:23 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-03-31 19:14:09 +00:00
|
|
|
import "../imports"
|
|
|
|
import "./status"
|
|
|
|
// TODO move Contact into shared to get rid of that import
|
|
|
|
import "../app/AppLayouts/Chat/components"
|
2021-02-08 12:21:23 +00:00
|
|
|
import "./"
|
|
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
height: 64
|
|
|
|
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-02-08 12:21:23 +00:00
|
|
|
|
2021-06-21 19:35:32 +00:00
|
|
|
property bool isAddedContact: pubKey != "" ? chatsModel.messageView.isAddedContact(pubKey) : false
|
2021-05-18 15:07:18 +00:00
|
|
|
|
2021-02-08 12:21:23 +00:00
|
|
|
signal resultClicked(string pubKey)
|
|
|
|
signal addToContactsButtonClicked(string pubKey)
|
2021-03-22 14:46:50 +00:00
|
|
|
|
|
|
|
function reset() {
|
|
|
|
hasExistingContacts = false
|
|
|
|
showProfileNotFoundMessage = false
|
|
|
|
username = ""
|
|
|
|
userAlias = ""
|
|
|
|
pubKey = ""
|
|
|
|
}
|
|
|
|
|
2021-02-08 12:21:23 +00:00
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: nonContactsLabel
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Non contacts"
|
|
|
|
text: qsTrId("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
|
|
|
|
|
|
|
|
StatusImageIdenticon {
|
|
|
|
id: contactIdenticon
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
source: utilsModel.generateIdenticon(root.pubKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
root.resultClicked(root.pubKey)
|
|
|
|
}
|
|
|
|
}
|
2021-02-08 12:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusIconButton {
|
|
|
|
id: addContactBtn
|
|
|
|
icon.name: "add-contact"
|
|
|
|
highlightedBackgroundColor: Utils.setColorAlpha(Style.current.buttonHoveredBackgroundColor, 0.2)
|
|
|
|
iconColor: Style.current.primary
|
|
|
|
icon.width: 24
|
|
|
|
icon.height: 24
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-05-18 15:07:18 +00:00
|
|
|
visible: !isAddedContact && !checkIcon.visible
|
2021-02-08 12:21:23 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onEntered: {
|
|
|
|
foundContact.hovered = true
|
|
|
|
}
|
|
|
|
onExited: {
|
|
|
|
foundContact.hovered = false
|
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
root.addToContactsButtonClicked(root.pubKey)
|
|
|
|
mouse.accepted = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: checkIcon
|
|
|
|
source: "../../../../app/img/check-2.svg"
|
|
|
|
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
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "No profile found"
|
|
|
|
text: qsTrId("no-profile-found")
|
2021-02-08 12:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|