2020-06-17 19:18:31 +00:00
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-27 21:28:25 +00:00
|
|
|
|
import "../../../../imports"
|
2020-06-19 18:06:58 +00:00
|
|
|
|
import "../../../../shared"
|
2021-04-26 10:25:01 +00:00
|
|
|
|
import "../../../../shared/status/core"
|
2020-11-16 13:15:39 +00:00
|
|
|
|
import "../../../../shared/status"
|
2020-06-13 13:49:20 +00:00
|
|
|
|
import "./Contacts"
|
2020-05-27 21:28:25 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: contactsContainer
|
2020-07-24 11:27:26 +00:00
|
|
|
|
property alias searchStr: searchBox.text
|
2020-09-17 08:47:14 +00:00
|
|
|
|
property bool isPending: false
|
2021-01-14 20:09:07 +00:00
|
|
|
|
height: parent.height
|
|
|
|
|
Layout.fillWidth: true
|
2021-04-08 15:44:58 +00:00
|
|
|
|
clip: true
|
2020-05-27 21:28:25 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
Item {
|
2020-05-27 21:28:25 +00:00
|
|
|
|
anchors.top: parent.top
|
2020-07-21 21:03:22 +00:00
|
|
|
|
anchors.topMargin: 32
|
2021-01-14 20:09:07 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
2021-04-08 15:44:58 +00:00
|
|
|
|
width: profileContainer.profileContentWidth
|
|
|
|
|
|
2021-03-18 09:33:39 +00:00
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
SearchBox {
|
|
|
|
|
id: searchBox
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
fontPixelSize: 15
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: addNewContact
|
|
|
|
|
anchors.top: searchBox.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
|
width: addButton.width + usernameText.width + Style.current.padding
|
|
|
|
|
height: addButton.height
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
|
id: addButton
|
|
|
|
|
icon.name: "plusSign"
|
|
|
|
|
size: "medium"
|
2021-03-16 19:19:48 +00:00
|
|
|
|
type: "secondary"
|
2021-01-14 20:09:07 +00:00
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: usernameText
|
|
|
|
|
//% "Add new contact"
|
|
|
|
|
text: qsTrId("add-new-contact")
|
|
|
|
|
color: Style.current.blue
|
|
|
|
|
anchors.left: addButton.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
anchors.verticalCenter: addButton.verticalCenter
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: {
|
|
|
|
|
addContactModal.open()
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: blockedContactsButton
|
|
|
|
|
anchors.top: addNewContact.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
|
width: blockButton.width + blockButtonLabel.width + Style.current.padding
|
2021-01-26 17:25:39 +00:00
|
|
|
|
visible: profileModel.contacts.blockedContacts.rowCount() > 0
|
2021-01-14 20:09:07 +00:00
|
|
|
|
height: addButton.height
|
|
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
|
id: blockButton
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
icon.name: "block-icon"
|
|
|
|
|
icon.color: Style.current.lightBlue
|
|
|
|
|
width: 40
|
|
|
|
|
height: 40
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: blockButtonLabel
|
|
|
|
|
//% "Blocked contacts"
|
|
|
|
|
text: qsTrId("blocked-contacts")
|
|
|
|
|
color: Style.current.blue
|
|
|
|
|
anchors.left: blockButton.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
anchors.verticalCenter: blockButton.verticalCenter
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: {
|
|
|
|
|
blockedContactsModal.open()
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
ModalPopup {
|
|
|
|
|
id: blockedContactsModal
|
|
|
|
|
//% "Blocked contacts"
|
|
|
|
|
title: qsTrId("blocked-contacts")
|
|
|
|
|
|
|
|
|
|
ContactList {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
contacts: profileModel.contacts.blockedContacts
|
|
|
|
|
}
|
2020-09-17 08:47:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: loadingIndicator
|
2021-04-26 10:25:01 +00:00
|
|
|
|
StatusLoadingIndicator {
|
2021-01-14 20:09:07 +00:00
|
|
|
|
width: 12
|
|
|
|
|
height: 12
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
ModalPopup {
|
|
|
|
|
id: addContactModal
|
|
|
|
|
//% "Add contact"
|
|
|
|
|
title: qsTrId("add-contact")
|
2021-03-22 14:51:17 +00:00
|
|
|
|
property string validationError: ""
|
|
|
|
|
|
|
|
|
|
function validate(value) {
|
|
|
|
|
if (!Utils.isChatKey(value) && !Utils.isValidETHNamePrefix(value)) {
|
|
|
|
|
//% "Enter a valid chat key or ENS username"
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Enter a valid chat key or ENS username"
|
|
|
|
|
addContactModal.validationError = qsTrId("enter-a-valid-chat-key-or-ens-username");
|
2021-03-22 14:51:17 +00:00
|
|
|
|
} else if (profileModel.profile.pubKey === value) {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "You can't add yourself"
|
|
|
|
|
addContactModal.validationError = qsTrId("you-can-t-add-yourself");
|
2021-03-22 14:51:17 +00:00
|
|
|
|
} else {
|
2021-07-13 16:05:44 +00:00
|
|
|
|
addContactModal.validationError = "";
|
2021-03-22 14:51:17 +00:00
|
|
|
|
}
|
2021-07-13 16:05:44 +00:00
|
|
|
|
return addContactModal.validationError === "";
|
2021-03-22 14:51:17 +00:00
|
|
|
|
}
|
2020-09-17 08:47:14 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
property var lookupContact: Backpressure.debounce(addContactSearchInput, 400, function (value) {
|
2021-03-22 14:51:17 +00:00
|
|
|
|
contactsContainer.isPending = true
|
|
|
|
|
searchResults.showProfileNotFoundMessage = false
|
2021-01-14 20:09:07 +00:00
|
|
|
|
profileModel.contacts.lookupContact(value)
|
|
|
|
|
})
|
2020-11-19 19:23:16 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
onOpened: {
|
|
|
|
|
addContactSearchInput.text = ""
|
2021-03-22 14:51:17 +00:00
|
|
|
|
searchResults.reset()
|
2020-09-17 08:47:14 +00:00
|
|
|
|
}
|
2021-01-14 20:09:07 +00:00
|
|
|
|
|
|
|
|
|
Input {
|
|
|
|
|
id: addContactSearchInput
|
|
|
|
|
//% "Enter ENS username or chat key"
|
|
|
|
|
placeholderText: qsTrId("enter-contact-code")
|
|
|
|
|
customHeight: 44
|
|
|
|
|
fontPixelSize: 15
|
2021-07-29 09:54:00 +00:00
|
|
|
|
onTextEdited: {
|
|
|
|
|
if (addContactSearchInput.text === "") {
|
|
|
|
|
searchResults.reset();
|
|
|
|
|
return;
|
2021-07-13 16:05:44 +00:00
|
|
|
|
}
|
2021-07-29 09:54:00 +00:00
|
|
|
|
if (!addContactModal.validate(addContactSearchInput.text)) {
|
|
|
|
|
searchResults.reset();
|
|
|
|
|
contactsContainer.isPending = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt.callLater(addContactModal.lookupContact, addContactSearchInput.text);
|
2020-09-17 08:47:14 +00:00
|
|
|
|
}
|
2021-01-14 20:09:07 +00:00
|
|
|
|
|
2020-09-17 08:47:14 +00:00
|
|
|
|
|
2021-02-08 20:03:09 +00:00
|
|
|
|
Connections {
|
|
|
|
|
target: profileModel.contacts
|
|
|
|
|
onEnsWasResolved: {
|
2021-03-22 14:51:17 +00:00
|
|
|
|
if (resolvedPubKey === "") {
|
|
|
|
|
searchResults.pubKey = ""
|
|
|
|
|
searchResults.showProfileNotFoundMessage = true
|
|
|
|
|
contactsContainer.isPending = false
|
|
|
|
|
return
|
2021-02-08 20:03:09 +00:00
|
|
|
|
}
|
2021-03-22 14:51:17 +00:00
|
|
|
|
searchResults.username = utilsModel.generateAlias(resolvedPubKey)
|
|
|
|
|
searchResults.userAlias = Utils.compactAddress(resolvedPubKey, 4)
|
|
|
|
|
searchResults.pubKey = resolvedPubKey
|
|
|
|
|
searchResults.showProfileNotFoundMessage = false
|
|
|
|
|
contactsContainer.isPending = false
|
2021-02-08 20:03:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-22 14:51:17 +00:00
|
|
|
|
}
|
2021-02-08 20:03:09 +00:00
|
|
|
|
|
2021-03-22 14:51:17 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: validationErrorMessage
|
|
|
|
|
text: addContactModal.validationError
|
|
|
|
|
visible: addContactModal.validationError !== ""
|
|
|
|
|
font.pixelSize: 13
|
|
|
|
|
color: Style.current.danger
|
|
|
|
|
anchors.top: addContactSearchInput.bottom
|
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-01-14 20:09:07 +00:00
|
|
|
|
}
|
2021-03-22 14:51:17 +00:00
|
|
|
|
|
2021-03-31 19:14:09 +00:00
|
|
|
|
SearchResults {
|
2021-03-22 14:51:17 +00:00
|
|
|
|
id: searchResults
|
|
|
|
|
anchors.top: addContactSearchInput.bottom
|
|
|
|
|
anchors.topMargin: Style.current.xlPadding
|
|
|
|
|
loading: contactsContainer.isPending
|
|
|
|
|
resultClickable: false
|
|
|
|
|
onAddToContactsButtonClicked: profileModel.contacts.addContact(pubKey)
|
2021-01-14 20:09:07 +00:00
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
2021-01-14 20:09:07 +00:00
|
|
|
|
|
|
|
|
|
ContactList {
|
|
|
|
|
id: contactListView
|
|
|
|
|
anchors.top: blockedContactsButton.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
2020-07-24 11:27:26 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
2021-01-14 20:09:07 +00:00
|
|
|
|
contacts: profileModel.contacts.addedContacts
|
|
|
|
|
searchString: searchBox.text
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-01 12:06:21 +00:00
|
|
|
|
NoFriendsRectangle {
|
2021-01-14 20:09:07 +00:00
|
|
|
|
id: element
|
2021-01-26 17:25:39 +00:00
|
|
|
|
visible: profileModel.contacts.addedContacts.rowCount() === 0
|
2021-02-18 16:36:05 +00:00
|
|
|
|
//% "You don’t have any contacts yet"
|
|
|
|
|
text: qsTrId("you-don-t-have-any-contacts-yet")
|
2021-01-26 17:25:39 +00:00
|
|
|
|
width: parent.width
|
2021-02-01 12:06:21 +00:00
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
2020-05-27 21:28:25 +00:00
|
|
|
|
}
|
2020-06-13 13:49:20 +00:00
|
|
|
|
}
|
2020-06-16 18:04:56 +00:00
|
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
|
Designer {
|
2020-07-21 21:03:22 +00:00
|
|
|
|
D{i:0;autoSize:true;formeditorColor:"#ffffff";formeditorZoom:0.6600000262260437;height:480;width:600}
|
2020-06-16 18:04:56 +00:00
|
|
|
|
}
|
|
|
|
|
##^##*/
|