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-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-03-31 19:14:09 +00:00
|
|
|
// TODO move Contact into shared to get rid of that import
|
2021-10-27 21:27:49 +00:00
|
|
|
import "../../../app/AppLayouts/Chat/controls"
|
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
|
|
|
|
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-07-13 09:57:11 +00:00
|
|
|
property bool addContactEnabled: true
|
2021-02-08 12:21:23 +00:00
|
|
|
|
2021-11-11 16:09:38 +00:00
|
|
|
property bool isAddedContact: isContactAdded()
|
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-11-11 16:09:38 +00:00
|
|
|
function isContactAdded() {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
return false
|
|
|
|
// return pubKey != "" ? chatsModel.messageView.isAddedContact(pubKey) : false
|
2021-11-11 16:09:38 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
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
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// image.source: utilsModel.generateIdenticon(root.pubKey)
|
2021-10-20 22:47:23 +00:00
|
|
|
image.isIdenticon: true
|
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) {
|
|
|
|
root.resultClicked(root.pubKey)
|
|
|
|
}
|
|
|
|
}
|
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
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "No profile found"
|
|
|
|
text: qsTrId("no-profile-found")
|
2021-02-08 12:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|