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-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
|
|
|
|
|
Layout.fillHeight: true
|
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
|
2020-05-27 21:28:25 +00:00
|
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
|
SearchBox {
|
|
|
|
|
id: searchBox
|
2020-05-27 21:28:25 +00:00
|
|
|
|
anchors.top: parent.top
|
2020-07-21 21:03:22 +00:00
|
|
|
|
anchors.topMargin: 32
|
2020-07-24 11:27:26 +00:00
|
|
|
|
fontPixelSize: 15
|
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2020-07-24 11:27:26 +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
|
|
|
|
|
|
|
|
|
|
AddButton {
|
|
|
|
|
id: addButton
|
|
|
|
|
clickable: false
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
width: 40
|
|
|
|
|
height: 40
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: usernameText
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Add new contact"
|
|
|
|
|
text: qsTrId("add-new-contact")
|
2020-07-24 11:27:26 +00:00
|
|
|
|
color: Style.current.blue
|
|
|
|
|
anchors.left: addButton.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
anchors.verticalCenter: addButton.verticalCenter
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: {
|
|
|
|
|
addContactModal.open()
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: blockedContactsButton
|
|
|
|
|
anchors.top: addNewContact.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
|
width: blockButton.width + blockButtonLabel.width + Style.current.padding
|
|
|
|
|
height: addButton.height
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
|
IconButton {
|
|
|
|
|
id: blockButton
|
|
|
|
|
clickable: false
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
width: 40
|
|
|
|
|
height: 40
|
|
|
|
|
iconName: "block-icon"
|
|
|
|
|
color: Style.current.lightBlue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: blockButtonLabel
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Blocked contacts"
|
|
|
|
|
text: qsTrId("blocked-contacts")
|
2020-07-24 11:27:26 +00:00
|
|
|
|
color: Style.current.blue
|
|
|
|
|
anchors.left: blockButton.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
anchors.verticalCenter: blockButton.verticalCenter
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: {
|
|
|
|
|
blockedContactsModal.open()
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
|
id: blockedContactsModal
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Blocked contacts"
|
|
|
|
|
title: qsTrId("blocked-contacts")
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
|
|
|
|
ContactList {
|
2020-07-24 11:27:26 +00:00
|
|
|
|
anchors.top: parent.top
|
2020-07-21 21:03:22 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
2020-07-24 11:27:26 +00:00
|
|
|
|
contacts: profileModel.blockedContacts
|
2020-07-21 21:03:22 +00:00
|
|
|
|
selectable: false
|
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2020-09-17 08:47:14 +00:00
|
|
|
|
Connections {
|
|
|
|
|
target: profileModel
|
|
|
|
|
onContactToAddChanged: {
|
|
|
|
|
contactsContainer.isPending = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: loadingIndicator
|
|
|
|
|
LoadingImage {
|
|
|
|
|
width: 12
|
|
|
|
|
height: 12
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
|
ModalPopup {
|
|
|
|
|
id: addContactModal
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Add contact"
|
|
|
|
|
title: qsTrId("add-contact")
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2020-09-17 08:47:14 +00:00
|
|
|
|
property var lookupContact: Backpressure.debounce(addContactSearchInput, 400, function (value) {
|
|
|
|
|
profileModel.lookupContact(value)
|
|
|
|
|
})
|
|
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
|
Input {
|
|
|
|
|
id: addContactSearchInput
|
2020-09-14 12:12:47 +00:00
|
|
|
|
//% "Enter ENS username or chat key"
|
|
|
|
|
placeholderText: qsTrId("enter-contact-code")
|
2020-07-24 11:27:26 +00:00
|
|
|
|
customHeight: 44
|
|
|
|
|
fontPixelSize: 15
|
|
|
|
|
onEditingFinished: {
|
2020-09-17 08:47:14 +00:00
|
|
|
|
contactsContainer.isPending = true
|
|
|
|
|
profileModel.lookupContact(inputValue)
|
|
|
|
|
contactsContainer.isPending = false
|
|
|
|
|
}
|
|
|
|
|
onTextChanged: {
|
|
|
|
|
if (addContactSearchInput.text !== "") {
|
|
|
|
|
contactsContainer.isPending = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Keys.onReleased: {
|
|
|
|
|
Qt.callLater(addContactModal.lookupContact, addContactSearchInput.text)
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-17 08:47:14 +00:00
|
|
|
|
Loader {
|
|
|
|
|
sourceComponent: loadingIndicator
|
|
|
|
|
anchors.top: addContactSearchInput.bottom
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
active: contactsContainer.isPending
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 11:27:26 +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
|
2020-09-17 08:47:14 +00:00
|
|
|
|
visible: !contactsContainer.isPending && !!addContactSearchInput.text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
font.pixelSize: 12
|
|
|
|
|
color: Style.current.darkGrey
|
2020-09-18 06:33:20 +00:00
|
|
|
|
//% "User not found"
|
|
|
|
|
text: qsTrId("user-not-found")
|
2020-09-17 08:47:14 +00:00
|
|
|
|
visible: !contactsContainer.isPending && !!!profileModel.contactToAddUsername
|
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: contactUsername
|
|
|
|
|
text: profileModel.contactToAddUsername + " • "
|
|
|
|
|
font.pixelSize: 12
|
|
|
|
|
color: Style.current.darkGrey
|
2020-09-17 08:47:14 +00:00
|
|
|
|
visible: !!profileModel.contactToAddPubKey
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: contactPubKey
|
|
|
|
|
text: profileModel.contactToAddPubKey
|
|
|
|
|
anchors.left: contactUsername.right
|
|
|
|
|
width: 100
|
|
|
|
|
font.pixelSize: 12
|
|
|
|
|
elide: Text.ElideMiddle
|
|
|
|
|
color: Style.current.darkGrey
|
2020-09-17 08:47:14 +00:00
|
|
|
|
visible: !!profileModel.contactToAddPubKey
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
footer: StyledButton {
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Add contact"
|
|
|
|
|
label: qsTrId("add-contact")
|
2020-07-24 11:27:26 +00:00
|
|
|
|
disabled: !contactToAddInfo.visible
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
onClicked: {
|
|
|
|
|
profileModel.addContact(profileModel.contactToAddPubKey);
|
|
|
|
|
addContactModal.close()
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContactList {
|
|
|
|
|
id: contactListView
|
|
|
|
|
anchors.top: blockedContactsButton.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
contacts: profileModel.addedContacts
|
|
|
|
|
selectable: false
|
|
|
|
|
searchString: searchBox.text
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: element
|
|
|
|
|
visible: profileModel.contactList.rowCount() === 0
|
|
|
|
|
anchors.fill: parent
|
2020-05-27 21:28:25 +00:00
|
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: noFriendsText
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "You don’t have any contacts yet"
|
|
|
|
|
text: qsTrId("you-don-t-have-any-contacts-yet")
|
2020-07-24 11:27:26 +00:00
|
|
|
|
anchors.verticalCenterOffset: -Style.current.bigPadding
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledButton {
|
|
|
|
|
anchors.horizontalCenter: noFriendsText.horizontalCenter
|
|
|
|
|
anchors.top: noFriendsText.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Invite firends"
|
|
|
|
|
label: qsTrId("invite-firends")
|
2020-07-24 11:27:26 +00:00
|
|
|
|
onClicked: function () {
|
|
|
|
|
inviteFriendsPopup.open()
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
|
|
|
|
|
InviteFriendsPopup {
|
|
|
|
|
id: inviteFriendsPopup
|
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
##^##*/
|