2020-06-17 19:18:31 +00:00
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
2021-10-26 14:21:08 +00:00
|
|
|
|
import StatusQ.Components 0.1
|
2021-10-25 19:37:44 +00:00
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
|
import utils 1.0
|
2021-10-26 14:21:08 +00:00
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
|
import shared.views 1.0
|
|
|
|
|
import shared.panels 1.0
|
|
|
|
|
import shared.popups 1.0
|
|
|
|
|
import shared.controls 1.0
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|
|
|
|
|
import "../panels"
|
|
|
|
|
import "../popups"
|
2020-05-27 21:28:25 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
2021-10-06 09:16:39 +00:00
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property var store
|
|
|
|
|
|
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
|
2021-10-25 19:37:44 +00:00
|
|
|
|
width: 40
|
|
|
|
|
height: 40
|
|
|
|
|
icon.name: "add"
|
|
|
|
|
type: StatusRoundButton.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
|
2021-09-17 15:08:16 +00:00
|
|
|
|
width: parent.width
|
2021-10-06 09:16:39 +00:00
|
|
|
|
visible: root.store.blockedContacts.rowCount() > 0
|
2021-09-17 15:08:16 +00:00
|
|
|
|
height: 64
|
2021-01-14 20:09:07 +00:00
|
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
|
id: blockButton
|
|
|
|
|
width: 40
|
|
|
|
|
height: 40
|
2021-10-25 19:37:44 +00:00
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
icon.name: "cancel"
|
|
|
|
|
icon.color: Theme.palette.primaryColor1
|
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-09-17 15:08:16 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: numberOfBlockedContacts
|
2021-10-06 09:16:39 +00:00
|
|
|
|
text: root.store.blockedContacts.rowCount()
|
2021-09-17 15:08:16 +00:00
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
|
anchors.verticalCenter: blockButton.verticalCenter
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
}
|
|
|
|
|
|
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")
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
ContactsListPanel {
|
2021-01-14 20:09:07 +00:00
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
2021-10-06 09:16:39 +00:00
|
|
|
|
contacts: root.store.blockedContacts
|
2021-01-14 20:09:07 +00:00
|
|
|
|
}
|
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)) {
|
2021-09-16 23:48:09 +00:00
|
|
|
|
addContactModal.validationError = qsTr("Enter a valid chat key or ENS username");
|
2021-10-06 09:16:39 +00:00
|
|
|
|
} else if (root.store.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-10-13 21:31:04 +00:00
|
|
|
|
console.log('Lookup', value)
|
2021-10-06 09:16:39 +00:00
|
|
|
|
root.isPending = true
|
2021-03-22 14:51:17 +00:00
|
|
|
|
searchResults.showProfileNotFoundMessage = false
|
2021-10-06 09:16:39 +00:00
|
|
|
|
root.store.lookupContact(value)
|
2021-01-14 20:09:07 +00:00
|
|
|
|
})
|
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();
|
2021-10-06 09:16:39 +00:00
|
|
|
|
root.isPending = false;
|
2021-07-29 09:54:00 +00:00
|
|
|
|
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 {
|
2021-10-13 21:31:04 +00:00
|
|
|
|
target: root.store.contactsModuleInst
|
|
|
|
|
onEnsWasResolved: function (resolvedPubKey) {
|
2021-03-22 14:51:17 +00:00
|
|
|
|
if (resolvedPubKey === "") {
|
|
|
|
|
searchResults.pubKey = ""
|
|
|
|
|
searchResults.showProfileNotFoundMessage = true
|
2021-10-06 09:16:39 +00:00
|
|
|
|
root.isPending = false
|
2021-03-22 14:51:17 +00:00
|
|
|
|
return
|
2021-02-08 20:03:09 +00:00
|
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
|
searchResults.username = Utils.isChatKey(addContactSearchInput.text) ? root.store.generateAlias(resolvedPubKey) : Utils.addStatusEns(addContactSearchInput.text.trim())
|
2021-03-22 14:51:17 +00:00
|
|
|
|
searchResults.userAlias = Utils.compactAddress(resolvedPubKey, 4)
|
|
|
|
|
searchResults.pubKey = resolvedPubKey
|
|
|
|
|
searchResults.showProfileNotFoundMessage = false
|
2021-10-06 09:16:39 +00:00
|
|
|
|
root.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
|
2021-10-06 09:16:39 +00:00
|
|
|
|
loading: root.isPending
|
2021-03-22 14:51:17 +00:00
|
|
|
|
resultClickable: false
|
2021-10-06 09:16:39 +00:00
|
|
|
|
onAddToContactsButtonClicked: root.store.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
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
ContactsListPanel {
|
2021-01-14 20:09:07 +00:00
|
|
|
|
id: contactListView
|
2021-09-17 15:08:16 +00:00
|
|
|
|
anchors.top: blockedContactsButton.visible ? blockedContactsButton.bottom : addNewContact.bottom
|
2021-01-14 20:09:07 +00:00
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
2020-07-24 11:27:26 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
2021-10-06 09:16:39 +00:00
|
|
|
|
contacts: root.store.addedContacts
|
2021-08-09 11:11:04 +00:00
|
|
|
|
hideBlocked: true
|
2021-01-14 20:09:07 +00:00
|
|
|
|
searchString: searchBox.text
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|
|
|
|
|
onContactClicked: {
|
|
|
|
|
root.store.changeAppSection(Constants.chat)
|
|
|
|
|
root.store.joinPrivateChat(contact.address)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSendMessageActionTriggered: {
|
|
|
|
|
root.store.changeAppSection(Constants.chat)
|
|
|
|
|
root.store.joinPrivateChat(contact.address)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBlockContactActionTriggered: {
|
|
|
|
|
blockContactConfirmationDialog.contactName = Utils.removeStatusEns(contact.name)
|
|
|
|
|
blockContactConfirmationDialog.contactAddress = contact.address
|
|
|
|
|
blockContactConfirmationDialog.open()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onRemoveContactActionTriggered: {
|
|
|
|
|
removeContactConfirmationDialog.value = contact.address
|
|
|
|
|
removeContactConfirmationDialog.open()
|
|
|
|
|
}
|
|
|
|
|
onUnblockContactActionTriggered: {
|
|
|
|
|
root.store.unblockContact(contact.address)
|
|
|
|
|
}
|
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-10-06 09:16:39 +00:00
|
|
|
|
visible: root.store.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-16 18:04:56 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
// TODO: Make BlockContactConfirmationDialog a dynamic component on a future refactor
|
|
|
|
|
BlockContactConfirmationDialog {
|
|
|
|
|
id: blockContactConfirmationDialog
|
|
|
|
|
onBlockButtonClicked: {
|
|
|
|
|
root.store.blockContact(blockContactConfirmationDialog.contactAddress)
|
|
|
|
|
blockContactConfirmationDialog.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Make ConfirmationDialog a dynamic component on a future refactor
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
|
id: removeContactConfirmationDialog
|
|
|
|
|
//% "Remove contact"
|
|
|
|
|
header.title: qsTrId("remove-contact")
|
|
|
|
|
//% "Are you sure you want to remove this contact?"
|
|
|
|
|
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
|
|
|
|
onConfirmButtonClicked: {
|
|
|
|
|
if (root.store.isContactAdded(removeContactConfirmationDialog.value)) {
|
|
|
|
|
root.store.removeContact(removeContactConfirmationDialog.value);
|
|
|
|
|
}
|
|
|
|
|
removeContactConfirmationDialog.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-16 18:04:56 +00:00
|
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|