2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-06-13 13:49:20 +00:00
|
|
|
import "./samples/"
|
|
|
|
import "../../../../../imports"
|
|
|
|
import "../../../../../shared"
|
2020-06-17 21:54:03 +00:00
|
|
|
import "../../../Chat/components"
|
2020-06-18 13:54:08 +00:00
|
|
|
import "."
|
2020-06-13 13:49:20 +00:00
|
|
|
|
|
|
|
ListView {
|
2020-06-16 18:04:56 +00:00
|
|
|
id: contactList
|
2020-06-13 13:49:20 +00:00
|
|
|
property var contacts: ContactsData {}
|
2020-07-24 11:27:26 +00:00
|
|
|
property string searchStr: ""
|
2020-07-21 21:03:22 +00:00
|
|
|
property string searchString: ""
|
|
|
|
property string lowerCaseSearchString: searchString.toLowerCase()
|
2020-08-10 13:06:46 +00:00
|
|
|
property string contactToRemove: ""
|
2020-06-13 13:49:20 +00:00
|
|
|
|
2021-04-12 11:40:38 +00:00
|
|
|
property Component profilePopupComponent: ProfilePopup {
|
|
|
|
id: profilePopup
|
|
|
|
onClosed: destroy()
|
|
|
|
}
|
|
|
|
|
2020-07-21 21:03:22 +00:00
|
|
|
width: parent.width
|
2020-06-13 13:49:20 +00:00
|
|
|
|
|
|
|
model: contacts
|
2020-10-02 14:37:51 +00:00
|
|
|
|
2020-06-13 13:49:20 +00:00
|
|
|
delegate: Contact {
|
2020-08-07 19:26:51 +00:00
|
|
|
name: Utils.removeStatusEns(model.name)
|
2020-06-13 13:49:20 +00:00
|
|
|
address: model.address
|
2020-09-16 19:52:48 +00:00
|
|
|
localNickname: model.localNickname
|
2020-11-30 17:03:52 +00:00
|
|
|
identicon: model.thumbnailImage || model.identicon
|
2020-06-22 12:16:44 +00:00
|
|
|
isContact: model.isContact
|
2020-07-24 11:27:26 +00:00
|
|
|
isBlocked: model.isBlocked
|
2021-04-12 11:40:38 +00:00
|
|
|
profileClick: function (showFooter, userName, fromAuthor, identicon, textParam, nickName) {
|
|
|
|
var popup = profilePopupComponent.createObject(contactList);
|
|
|
|
popup.openPopup(showFooter, userName, fromAuthor, identicon, textParam, nickName);
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
visible: searchString === "" ||
|
|
|
|
model.name.toLowerCase().includes(lowerCaseSearchString) ||
|
|
|
|
model.address.toLowerCase().includes(lowerCaseSearchString)
|
2020-08-10 11:56:16 +00:00
|
|
|
onBlockContactActionTriggered: {
|
|
|
|
blockContactConfirmationDialog.contactName = name
|
|
|
|
blockContactConfirmationDialog.contactAddress = address
|
|
|
|
blockContactConfirmationDialog.open()
|
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
onRemoveContactActionTriggered: {
|
2020-10-02 14:37:51 +00:00
|
|
|
removeContactConfirmationDialog.value = address
|
2020-08-10 12:15:57 +00:00
|
|
|
removeContactConfirmationDialog.open()
|
|
|
|
}
|
2020-06-17 21:54:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 14:37:51 +00:00
|
|
|
// TODO: Make BlockContactConfirmationDialog a dynamic component on a future refactor
|
2020-08-10 11:56:16 +00:00
|
|
|
BlockContactConfirmationDialog {
|
|
|
|
id: blockContactConfirmationDialog
|
|
|
|
onBlockButtonClicked: {
|
2020-12-06 22:15:51 +00:00
|
|
|
profileModel.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
|
2020-08-10 11:56:16 +00:00
|
|
|
blockContactConfirmationDialog.close()
|
|
|
|
}
|
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
|
2020-10-02 14:37:51 +00:00
|
|
|
// TODO: Make ConfirmationDialog a dynamic component on a future refactor
|
2020-08-10 13:06:46 +00:00
|
|
|
ConfirmationDialog {
|
2020-08-10 12:15:57 +00:00
|
|
|
id: removeContactConfirmationDialog
|
2021-05-26 17:36:24 +00:00
|
|
|
title: qsTr("Remove contact")
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Are you sure you want to remove this contact?"
|
|
|
|
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
2020-08-10 13:06:46 +00:00
|
|
|
onConfirmButtonClicked: {
|
2020-12-06 22:15:51 +00:00
|
|
|
if (profileModel.contacts.isAdded(removeContactConfirmationDialog.value)) {
|
|
|
|
profileModel.contacts.removeContact(removeContactConfirmationDialog.value);
|
2020-08-10 12:15:57 +00:00
|
|
|
}
|
|
|
|
removeContactConfirmationDialog.close()
|
|
|
|
}
|
|
|
|
}
|
2020-06-13 13:49:20 +00:00
|
|
|
}
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|