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