2022-07-25 18:07:19 +03:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
2021-09-28 18:04:06 +03:00
|
|
|
|
2022-07-13 15:29:38 +03:00
|
|
|
import StatusQ.Core 0.1
|
2022-08-23 17:57:37 +03:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-07-13 15:29:38 +03:00
|
|
|
|
2021-09-28 18:04:06 +03:00
|
|
|
import utils 1.0
|
2021-10-28 00:27:49 +03:00
|
|
|
import shared.status 1.0
|
2021-12-08 23:20:43 +02:00
|
|
|
import shared.stores 1.0
|
2021-03-31 15:14:09 -04:00
|
|
|
// TODO move Contact into shared to get rid of that import
|
2022-03-08 13:49:33 -05:00
|
|
|
import AppLayouts.Chat.controls 1.0
|
2021-02-08 13:21:23 +01:00
|
|
|
|
2022-12-02 00:04:28 +01:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2021-02-08 13:21:23 +01:00
|
|
|
Item {
|
|
|
|
id: root
|
2022-01-04 13:06:05 +01:00
|
|
|
|
2022-09-16 10:30:08 +02:00
|
|
|
property var rootStore
|
2022-01-04 13:06:05 +01:00
|
|
|
property var contactsStore
|
2022-09-16 10:30:08 +02:00
|
|
|
property string communityId
|
2022-01-04 13:06:05 +01:00
|
|
|
|
2021-02-08 13:21:23 +01:00
|
|
|
property string filterText: ""
|
|
|
|
property bool expanded: true
|
2021-03-31 15:14:09 -04:00
|
|
|
property bool showCheckbox: false
|
2021-05-17 11:56:55 +02:00
|
|
|
property bool hideCommunityMembers: false
|
2021-03-31 15:14:09 -04:00
|
|
|
property var pubKeys: ([])
|
2022-07-25 16:22:09 +03:00
|
|
|
|
2022-07-25 18:07:19 +03:00
|
|
|
readonly property alias count: contactListView.count
|
|
|
|
|
2021-02-08 13:21:23 +01:00
|
|
|
signal contactClicked(var contact)
|
|
|
|
|
|
|
|
function matchesAlias(name, filter) {
|
|
|
|
let parts = name.split(" ")
|
|
|
|
return parts.some(p => p.startsWith(filter))
|
|
|
|
}
|
|
|
|
|
2022-07-25 18:07:19 +03:00
|
|
|
implicitWidth: contactListView.implicitWidth + contactListView.margins
|
2022-07-25 16:22:09 +03:00
|
|
|
implicitHeight: visible ? Math.min(contactListView.contentHeight, (expanded ? 320 : 192)) : 0
|
|
|
|
|
2022-07-14 14:03:36 +03:00
|
|
|
StatusListView {
|
|
|
|
id: contactListView
|
2022-10-25 14:39:21 -04:00
|
|
|
objectName: "ExistingContacts_ListView"
|
2021-02-08 13:21:23 +01:00
|
|
|
anchors.fill: parent
|
2022-07-25 18:07:19 +03:00
|
|
|
rightMargin: 0
|
2022-08-23 17:57:37 +03:00
|
|
|
leftMargin: 0
|
|
|
|
spacing: Style.current.padding
|
2021-02-08 13:21:23 +01:00
|
|
|
|
2022-12-02 00:04:28 +01:00
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.contactsStore.myContactsModel
|
|
|
|
filters: [
|
|
|
|
ExpressionFilter {
|
|
|
|
expression: {
|
|
|
|
root.filterText
|
|
|
|
root.hideCommunityMembers
|
|
|
|
root.communityId
|
|
|
|
|
|
|
|
if (!model.isContact || model.isBlocked)
|
|
|
|
return false
|
|
|
|
|
|
|
|
const filter = root.filterText.toLowerCase()
|
|
|
|
const filterAccepted = root.filterText === ""
|
|
|
|
|| root.matchesAlias(model.alias.toLowerCase(), filter)
|
|
|
|
|| model.displayName.toLowerCase().includes(filter)
|
|
|
|
|| model.ensName.toLowerCase().includes(filter)
|
|
|
|
|| model.localNickname.toLowerCase().includes(filter)
|
|
|
|
|| model.pubKey.toLowerCase().includes(filter)
|
|
|
|
|
|
|
|
if (!filterAccepted)
|
|
|
|
return false
|
|
|
|
|
|
|
|
return !root.hideCommunityMembers ||
|
|
|
|
!root.rootStore.communityHasMember(root.communityId, model.pubKey)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2022-08-23 17:57:37 +03:00
|
|
|
delegate: StatusMemberListItem {
|
2022-07-25 16:22:09 +03:00
|
|
|
width: contactListView.availableWidth
|
2023-04-19 18:48:57 +02:00
|
|
|
pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey)
|
2022-07-14 14:03:36 +03:00
|
|
|
isContact: model.isContact
|
2022-08-23 17:57:37 +03:00
|
|
|
status: model.onlineStatus
|
|
|
|
height: visible ? implicitHeight : 0
|
2023-07-25 17:25:41 +02:00
|
|
|
color: sensor.containsMouse ? Theme.palette.baseColor2 : "transparent"
|
2022-12-05 10:56:44 +01:00
|
|
|
nickName: model.localNickname
|
|
|
|
userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias)
|
2022-08-11 14:55:08 +03:00
|
|
|
asset.name: model.icon
|
2022-09-16 10:30:08 +02:00
|
|
|
asset.isImage: (asset.name !== "")
|
|
|
|
asset.isLetterIdenticon: (asset.name === "")
|
2022-08-11 14:55:08 +03:00
|
|
|
asset.width: 40
|
|
|
|
asset.height: 40
|
2022-09-06 17:06:33 +02:00
|
|
|
asset.color: Utils.colorForColorId(model.colorId)
|
2023-04-19 18:48:57 +02:00
|
|
|
ringSettings.ringSpecModel: model.colorHash
|
2022-08-23 17:57:37 +03:00
|
|
|
statusListItemIcon.badge.border.color: Theme.palette.baseColor4
|
|
|
|
statusListItemIcon.badge.implicitHeight: 14 // 10 px + 2 px * 2 borders
|
|
|
|
statusListItemIcon.badge.implicitWidth: 14 // 10 px + 2 px * 2 borders
|
|
|
|
|
|
|
|
onClicked: {
|
2022-07-25 16:22:09 +03:00
|
|
|
root.contactClicked(model);
|
2021-02-08 13:21:23 +01:00
|
|
|
}
|
2022-08-23 17:57:37 +03:00
|
|
|
|
|
|
|
StatusCheckBox {
|
|
|
|
id: contactCheckbox
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
checked: root.pubKeys.indexOf(model.pubKey) > -1
|
|
|
|
onClicked: {
|
|
|
|
root.contactClicked(model);
|
|
|
|
}
|
|
|
|
}
|
2021-02-08 13:21:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|