2022-03-23 15:38:23 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.controls.chat 1.0
|
|
|
|
|
|
|
|
import "../../layouts"
|
|
|
|
|
|
|
|
SettingsPageLayout {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var membersModel
|
|
|
|
|
|
|
|
property bool editable: true
|
|
|
|
property int pendingRequests
|
|
|
|
|
|
|
|
signal membershipRequestsClicked()
|
|
|
|
signal userProfileClicked(string id)
|
|
|
|
signal kickUserClicked(string id)
|
|
|
|
signal banUserClicked(string id)
|
|
|
|
|
|
|
|
title: qsTr("Members")
|
|
|
|
|
|
|
|
content: ColumnLayout {
|
|
|
|
spacing: 8
|
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: memberSearch
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
leftPadding: 0
|
|
|
|
rightPadding: 0
|
|
|
|
input.placeholderText: qsTr("Member name")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusContactRequestsIndicatorListItem {
|
|
|
|
id: memberRequestsButton
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
visible: root.editable && root.pendingRequests > 0
|
|
|
|
//% "Membership requests"
|
|
|
|
title: qsTrId("membership-requests")
|
|
|
|
requestsCount: root.pendingRequests
|
|
|
|
sensor.onClicked: root.membershipRequestsClicked()
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
implicitHeight: 1
|
|
|
|
visible: memberRequestsButton.visible
|
|
|
|
color: Theme.palette.statusPopupMenu.separatorColor
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
visible: memberList.count === 0
|
|
|
|
//% "Community members will appear here"
|
|
|
|
text: qsTrId("community-members-will-appear-here")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
visible: !!memberSearch.input.text && memberList.height == 0
|
|
|
|
//% "No contacts found"
|
|
|
|
text: qsTrId("no-contacts-found")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: memberList
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
model: root.membersModel
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
// TODO: use StatusMemberListItem (it does not behave correctly right now)
|
|
|
|
delegate: StatusListItem {
|
|
|
|
id: memberItem
|
|
|
|
|
2022-06-03 13:24:49 +00:00
|
|
|
readonly property bool itsMe: model.pubKey.toLowerCase() === userProfile.pubKey.toLowerCase()
|
2022-03-23 15:38:23 +00:00
|
|
|
readonly property bool isOnline: model.onlineStatus === Constants.userStatus.online
|
|
|
|
|
|
|
|
width: memberList.width
|
|
|
|
|
|
|
|
// FIXME: use QSortFilterProxyModel instead
|
|
|
|
visible: memberSearch.input.text === "" || title.toLowerCase().includes(memberSearch.input.text.toLowerCase())
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
|
|
|
|
title: {
|
|
|
|
if (memberItem.itsMe) {
|
|
|
|
//% "You"
|
|
|
|
return qsTrId("You")
|
|
|
|
}
|
2022-06-03 13:24:49 +00:00
|
|
|
return !model.displayName.endsWith(".eth") ? model.displayName : Utils.removeStatusEns(model.displayName)
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
2022-06-03 13:24:49 +00:00
|
|
|
subTitle: Utils.getElidedCompressedPk(model.pubKey)
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
statusListItemIcon {
|
2022-06-03 13:24:49 +00:00
|
|
|
name: model.displayName
|
2022-03-23 15:38:23 +00:00
|
|
|
badge {
|
|
|
|
visible: true
|
|
|
|
color: memberItem.isOnline ? Theme.palette.successColor1 : Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
image {
|
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
source: model.icon
|
|
|
|
}
|
|
|
|
|
|
|
|
icon {
|
|
|
|
width: 40
|
|
|
|
height: 40
|
2022-06-03 13:24:49 +00:00
|
|
|
color: Utils.colorForPubkey(model.pubKey)
|
2022-03-23 15:38:23 +00:00
|
|
|
letterSize: Math.max(4, root.imageWidth / 2.4)
|
|
|
|
charactersLen: 2
|
|
|
|
isLetterIdenticon: true
|
|
|
|
}
|
|
|
|
|
|
|
|
ringSettings {
|
2022-06-03 13:24:49 +00:00
|
|
|
ringSpecModel: Utils.getColorHashAsJson(model.pubKey)
|
2022-03-23 15:38:23 +00:00
|
|
|
ringPxSize: Math.max(icon.width / 24.0)
|
|
|
|
}
|
|
|
|
|
2022-06-03 13:24:49 +00:00
|
|
|
onClicked: root.userProfileClicked(model.pubKey)
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
components: [
|
|
|
|
StatusButton {
|
|
|
|
visible: root.editable && !memberItem.itsMe
|
|
|
|
text: qsTr("Ban")
|
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
size: StatusBaseButton.Size.Tiny
|
|
|
|
|
2022-06-03 13:24:49 +00:00
|
|
|
onClicked: root.banUserClicked(model.pubKey)
|
2022-03-23 15:38:23 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
visible: root.editable && !memberItem.itsMe
|
|
|
|
text: qsTr("Kick")
|
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
size: StatusBaseButton.Size.Tiny
|
|
|
|
|
2022-06-03 13:24:49 +00:00
|
|
|
onClicked: root.kickUserClicked(model.pubKey)
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|