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"
|
2020-11-16 13:15:39 +00:00
|
|
|
|
import "../../../../shared/status"
|
2020-07-21 21:03:22 +00:00
|
|
|
|
import "../../Chat/components"
|
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
|
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
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: contentMargin
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: contentMargin
|
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"
|
|
|
|
|
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
|
|
|
|
Connections {
|
|
|
|
|
target: profileModel.contacts
|
|
|
|
|
onContactToAddChanged: {
|
|
|
|
|
contactsContainer.isPending = false
|
|
|
|
|
}
|
2020-09-17 08:47:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: loadingIndicator
|
|
|
|
|
LoadingImage {
|
|
|
|
|
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")
|
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) {
|
|
|
|
|
profileModel.contacts.lookupContact(value)
|
|
|
|
|
})
|
2020-11-19 19:23:16 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
onOpened: {
|
|
|
|
|
addContactSearchInput.text = ""
|
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
|
|
|
|
|
onEditingFinished: {
|
|
|
|
|
contactsContainer.isPending = true
|
|
|
|
|
profileModel.contacts.lookupContact(inputValue)
|
|
|
|
|
contactsContainer.isPending = false
|
|
|
|
|
}
|
|
|
|
|
onTextChanged: {
|
|
|
|
|
if (addContactSearchInput.text !== "") {
|
|
|
|
|
contactsContainer.isPending = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Keys.onReleased: {
|
|
|
|
|
Qt.callLater(addContactModal.lookupContact, addContactSearchInput.text)
|
2020-09-17 08:47:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-14 20:09:07 +00:00
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
sourceComponent: loadingIndicator
|
|
|
|
|
anchors.top: addContactSearchInput.bottom
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
active: contactsContainer.isPending
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: contactToAddInfo
|
|
|
|
|
anchors.top: addContactSearchInput.bottom
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
height: contactUsername.height
|
|
|
|
|
width: contactUsername.width + contactPubKey.width
|
|
|
|
|
visible: !contactsContainer.isPending && !!addContactSearchInput.text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
font.pixelSize: 12
|
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
|
//% "User not found"
|
|
|
|
|
text: qsTrId("user-not-found")
|
|
|
|
|
visible: !contactsContainer.isPending && !!!profileModel.contacts.contactToAddUsername
|
|
|
|
|
}
|
2020-09-17 08:47:14 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: contactUsername
|
|
|
|
|
text: profileModel.contacts.contactToAddUsername + " • "
|
|
|
|
|
font.pixelSize: 12
|
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
|
visible: !!profileModel.contacts.contactToAddPubKey
|
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: contactPubKey
|
|
|
|
|
text: profileModel.contacts.contactToAddPubKey
|
|
|
|
|
anchors.left: contactUsername.right
|
|
|
|
|
width: 100
|
|
|
|
|
font.pixelSize: 12
|
|
|
|
|
elide: Text.ElideMiddle
|
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
|
visible: !!profileModel.contacts.contactToAddPubKey
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2021-01-28 11:04:10 +00:00
|
|
|
|
footer: StatusButton {
|
2021-01-14 20:09:07 +00:00
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
//% "Add contact"
|
2021-01-28 11:04:10 +00:00
|
|
|
|
text: qsTrId("add-contact")
|
|
|
|
|
enabled: contactToAddInfo.visible
|
2021-01-14 20:09:07 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
onClicked: {
|
2021-01-19 19:20:59 +00:00
|
|
|
|
profileModel.contacts.addContact(profileModel.contacts.contactToAddPubKey);
|
2021-01-14 20:09:07 +00:00
|
|
|
|
addContactModal.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
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-01 12:06:21 +00:00
|
|
|
|
text: qsTr("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
|
|
|
|
}
|
|
|
|
|
##^##*/
|