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
|
|
|
|
|
2022-03-07 20:34:59 +00:00
|
|
|
|
import StatusQ.Core 0.1
|
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
|
|
|
|
|
2021-12-31 12:29:51 +00:00
|
|
|
|
import "../stores"
|
2021-10-06 09:16:39 +00:00
|
|
|
|
import "../panels"
|
|
|
|
|
import "../popups"
|
2022-03-15 15:55:18 +00:00
|
|
|
|
// TODO remove this import when the ContactRequestPanel is moved to the the Profile completely
|
|
|
|
|
import "../../Chat/panels"
|
2020-05-27 21:28:25 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
2021-10-06 09:16:39 +00:00
|
|
|
|
id: root
|
|
|
|
|
|
2021-12-31 12:29:51 +00:00
|
|
|
|
property ContactsStore contactsStore
|
2021-12-09 13:28:02 +00:00
|
|
|
|
property int profileContentWidth
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|
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 {
|
2022-03-07 20:34:59 +00:00
|
|
|
|
height: parent.height
|
2021-12-09 13:28:02 +00:00
|
|
|
|
width: profileContentWidth
|
2021-04-08 15:44:58 +00:00
|
|
|
|
|
2021-03-18 09:33:39 +00:00
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2022-03-07 20:34:59 +00:00
|
|
|
|
StatusFlatButton {
|
|
|
|
|
icon.name: "arrow-left"
|
|
|
|
|
icon.width: 20
|
|
|
|
|
icon.height: 20
|
|
|
|
|
text: qsTr("Messaging")
|
|
|
|
|
size: StatusBaseButton.Size.Large
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 8
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: -40
|
|
|
|
|
onClicked: Global.changeAppSectionBySectionType(Constants.appSection.profile,
|
|
|
|
|
Constants.settingsSubsection.messaging)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: titleText
|
|
|
|
|
text: qsTr("Contacts")
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
font.pixelSize: 28
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 56
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
|
SearchBox {
|
|
|
|
|
id: searchBox
|
2022-03-07 20:34:59 +00:00
|
|
|
|
anchors.top: titleText.bottom
|
|
|
|
|
anchors.topMargin: 32
|
2021-01-14 20:09:07 +00:00
|
|
|
|
fontPixelSize: 15
|
2022-03-15 15:55:18 +00:00
|
|
|
|
placeholderText: qsTr("Search by a display name or chat key")
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
|
TabBar {
|
|
|
|
|
id: contactsTabBar
|
|
|
|
|
width: parent.width
|
2021-01-14 20:09:07 +00:00
|
|
|
|
anchors.top: searchBox.bottom
|
2022-03-15 15:55:18 +00:00
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
height: contactsBtn.height
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
color: Style.current.transparent
|
2020-07-21 21:03:22 +00:00
|
|
|
|
}
|
2022-03-15 15:55:18 +00:00
|
|
|
|
StatusTabButton {
|
|
|
|
|
id: contactsBtn
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
btnText: qsTr("Contacts")
|
2021-01-14 20:09:07 +00:00
|
|
|
|
}
|
2022-03-15 15:55:18 +00:00
|
|
|
|
StatusTabButton {
|
|
|
|
|
id: pendingRequestsBtn
|
|
|
|
|
enabled: root.contactsStore.contactRequestsModel.count > 0
|
|
|
|
|
anchors.left: contactsBtn.right
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
|
btnText: qsTr("Pending Requests")
|
|
|
|
|
}
|
|
|
|
|
StatusTabButton {
|
|
|
|
|
id: blockedBtn
|
|
|
|
|
enabled: root.contactsStore.blockedContactsModel.count > 0
|
|
|
|
|
anchors.left: pendingRequestsBtn.right
|
|
|
|
|
anchors.leftMargin: Style.current.bigPadding
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
btnText: qsTr("Blocked")
|
2021-01-14 20:09:07 +00:00
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
|
StackLayout {
|
|
|
|
|
id: stackLayout
|
2021-09-17 15:08:16 +00:00
|
|
|
|
width: parent.width
|
2022-03-15 15:55:18 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.top: contactsTabBar.bottom
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
currentIndex: contactsTabBar.currentIndex
|
|
|
|
|
|
|
|
|
|
// CONTACTS
|
|
|
|
|
Item {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
|
|
ContactsListPanel {
|
|
|
|
|
id: contactListView
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
contactsModel: root.contactsStore.myContactsModel
|
|
|
|
|
clip: true
|
|
|
|
|
hideBlocked: true
|
|
|
|
|
searchString: searchBox.text
|
|
|
|
|
showSendMessageButton: true
|
|
|
|
|
|
|
|
|
|
onContactClicked: {
|
|
|
|
|
root.contactsStore.joinPrivateChat(contact.pubKey)
|
|
|
|
|
}
|
2021-01-14 20:09:07 +00:00
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
|
onOpenProfilePopup: {
|
|
|
|
|
Global.openProfilePopup(contact.pubKey)
|
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
|
onSendMessageActionTriggered: {
|
|
|
|
|
root.contactsStore.joinPrivateChat(contact.pubKey)
|
|
|
|
|
}
|
|
|
|
|
onOpenChangeNicknamePopup: {
|
|
|
|
|
Global.openProfilePopup(contact.pubKey, null, true)
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
|
NoFriendsRectangle {
|
|
|
|
|
visible: root.contactsStore.myContactsModel.count === 0
|
|
|
|
|
//% "You don’t have any contacts yet"
|
|
|
|
|
text: qsTrId("you-don-t-have-any-contacts-yet")
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
}
|
2021-09-17 15:08:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
|
// PENDING REQUESTS
|
|
|
|
|
Item {
|
|
|
|
|
ListView {
|
|
|
|
|
id: contactList
|
|
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.leftMargin: -Style.current.halfPadding
|
|
|
|
|
anchors.rightMargin: -Style.current.halfPadding
|
|
|
|
|
|
|
|
|
|
model: root.contactsStore.contactRequestsModel
|
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
|
|
delegate: ContactRequestPanel {
|
|
|
|
|
contactName: model.name
|
|
|
|
|
contactIcon: model.icon
|
|
|
|
|
contactIconIsIdenticon: model.isIdenticon
|
|
|
|
|
onOpenProfilePopup: {
|
|
|
|
|
Global.openProfilePopup(model.pubKey)
|
|
|
|
|
}
|
|
|
|
|
onBlockContactActionTriggered: {
|
|
|
|
|
blockContactConfirmationDialog.contactName = model.name
|
|
|
|
|
blockContactConfirmationDialog.contactAddress = model.pubKey
|
|
|
|
|
blockContactConfirmationDialog.open()
|
|
|
|
|
}
|
|
|
|
|
onAcceptClicked: {
|
|
|
|
|
root.contactsStore.acceptContactRequest(model.pubKey)
|
|
|
|
|
}
|
|
|
|
|
onDeclineClicked: {
|
|
|
|
|
root.contactsStore.rejectContactRequest(model.pubKey)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-14 20:09:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
|
// BLOCKED
|
2021-10-06 09:16:39 +00:00
|
|
|
|
ContactsListPanel {
|
2022-03-15 15:55:18 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
|
height: parent.height
|
2022-03-11 13:22:21 +00:00
|
|
|
|
clip: true
|
2021-12-31 12:29:51 +00:00
|
|
|
|
contactsModel: root.contactsStore.blockedContactsModel
|
|
|
|
|
|
|
|
|
|
onOpenProfilePopup: {
|
|
|
|
|
Global.openProfilePopup(contact.pubKey)
|
|
|
|
|
}
|
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-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: {
|
2021-12-31 12:29:51 +00:00
|
|
|
|
root.contactsStore.blockContact(blockContactConfirmationDialog.contactAddress)
|
2021-10-06 09:16:39 +00:00
|
|
|
|
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: {
|
2022-01-04 12:06:05 +00:00
|
|
|
|
if (Utils.getContactDetailsAsJson(removeContactConfirmationDialog.value).isContact) {
|
2021-12-31 12:29:51 +00:00
|
|
|
|
root.contactsStore.removeContact(removeContactConfirmationDialog.value);
|
2021-10-06 09:16:39 +00:00
|
|
|
|
}
|
|
|
|
|
removeContactConfirmationDialog.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-16 18:04:56 +00:00
|
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|