2021-02-08 12:21:23 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.status 1.0
|
2021-12-08 21:20:43 +00:00
|
|
|
import shared.stores 1.0
|
2021-03-31 19:14:09 +00:00
|
|
|
// TODO move Contact into shared to get rid of that import
|
2021-10-27 21:27:49 +00:00
|
|
|
import "../../../app/AppLayouts/Chat/controls"
|
2021-02-08 12:21:23 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
property string filterText: ""
|
|
|
|
property bool expanded: true
|
2021-03-31 19:14:09 +00:00
|
|
|
property bool showCheckbox: false
|
2021-05-17 09:56:55 +00:00
|
|
|
property bool hideCommunityMembers: false
|
2021-03-31 19:14:09 +00:00
|
|
|
property var pubKeys: ([])
|
2021-02-08 12:21:23 +00:00
|
|
|
signal contactClicked(var contact)
|
|
|
|
|
|
|
|
function matchesAlias(name, filter) {
|
|
|
|
let parts = name.split(" ")
|
|
|
|
return parts.some(p => p.startsWith(filter))
|
|
|
|
}
|
|
|
|
|
|
|
|
height: Math.min(contactListView.contentHeight, (expanded ? 320 : 192))
|
2021-06-10 21:07:41 +00:00
|
|
|
|
2021-02-08 12:21:23 +00:00
|
|
|
ScrollView {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.vertical.policy: contactListView.contentHeight > contactListView.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
clip: true
|
|
|
|
id: contactListView
|
2021-11-15 15:15:21 +00:00
|
|
|
model: contactsModule.model.list
|
2021-02-08 12:21:23 +00:00
|
|
|
delegate: Contact {
|
2021-03-31 19:14:09 +00:00
|
|
|
showCheckbox: root.showCheckbox
|
|
|
|
isChecked: root.pubKeys.indexOf(model.pubKey) > -1
|
2021-02-08 12:21:23 +00:00
|
|
|
pubKey: model.pubKey
|
|
|
|
isContact: model.isContact
|
|
|
|
isUser: false
|
|
|
|
name: model.name
|
|
|
|
address: model.address
|
|
|
|
identicon: model.thumbnailImage || model.identicon
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// visible: model.isContact && !model.isBlocked && (root.filterText === "" ||
|
|
|
|
// root.matchesAlias(model.name.toLowerCase(), root.filterText.toLowerCase()) ||
|
|
|
|
// model.name.toLowerCase().includes(root.filterText.toLowerCase()) ||
|
|
|
|
// model.address.toLowerCase().includes(root.filterText.toLowerCase())) &&
|
2021-12-08 21:20:43 +00:00
|
|
|
// (!root.hideCommunityMembers || !RootStore.chatsModelInst.communities.activeCommunity.hasMember(model.pubKey))
|
2021-02-08 12:21:23 +00:00
|
|
|
onContactClicked: function () {
|
|
|
|
root.contactClicked(model)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|