2022-03-23 10:56:25 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2022-03-23 10:56:25 +00:00
|
|
|
id: root
|
|
|
|
|
|
|
|
property bool hasAddedContacts: false
|
|
|
|
|
|
|
|
signal inviteFriends(var communityData)
|
2022-07-25 15:39:09 +00:00
|
|
|
signal leaveCommunityClicked(string communityId)
|
|
|
|
signal setCommunityMutedClicked(string communityId, bool muted)
|
|
|
|
signal setActiveCommunityClicked(string communityId)
|
2022-03-23 10:56:25 +00:00
|
|
|
|
|
|
|
interactive: false
|
|
|
|
implicitHeight: contentItem.childrenRect.height
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
delegate: StatusListItem {
|
|
|
|
id: statusCommunityItem
|
|
|
|
width: parent.width
|
|
|
|
title: model.name
|
2022-09-15 15:49:13 +00:00
|
|
|
statusListItemTitle.font.pixelSize: 17
|
|
|
|
statusListItemTitle.font.bold: true
|
2022-03-23 10:56:25 +00:00
|
|
|
subTitle: model.description
|
2022-09-15 15:49:13 +00:00
|
|
|
tertiaryTitle: qsTr("%n member(s)", "", model.members.count)
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.name: model.image
|
|
|
|
asset.isLetterIdenticon: !model.image
|
|
|
|
asset.bgColor: model.color || Theme.palette.primaryColor1
|
2022-09-21 11:19:50 +00:00
|
|
|
asset.width: 40
|
|
|
|
asset.height: 40
|
2022-03-23 10:56:25 +00:00
|
|
|
visible: model.joined
|
|
|
|
height: visible ? implicitHeight: 0
|
|
|
|
|
2022-09-15 15:49:13 +00:00
|
|
|
onClicked: setActiveCommunityClicked(model.id)
|
2022-07-25 15:39:09 +00:00
|
|
|
|
2022-03-23 10:56:25 +00:00
|
|
|
components: [
|
|
|
|
StatusFlatButton {
|
2022-08-11 12:24:49 +00:00
|
|
|
objectName: "CommunitiesListPanel_leaveCommunityPopupButton"
|
2022-03-23 10:56:25 +00:00
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
type: StatusBaseButton.Type.Danger
|
2022-09-13 07:37:09 +00:00
|
|
|
borderColor: "transparent"
|
2022-09-15 15:49:13 +00:00
|
|
|
text: qsTr("Leave Community")
|
2022-03-23 10:56:25 +00:00
|
|
|
onClicked: {
|
|
|
|
Global.openPopup(leaveCommunityPopup, {
|
|
|
|
community: model.name,
|
|
|
|
communityId: model.id
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2022-09-15 15:49:13 +00:00
|
|
|
StatusFlatButton {
|
2023-04-12 19:08:42 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
size: StatusBaseButton.Size.Small
|
2022-09-15 15:49:13 +00:00
|
|
|
icon.name: model.muted ? "notification-muted" : "notification"
|
2022-07-25 15:39:09 +00:00
|
|
|
onClicked: root.setCommunityMutedClicked(model.id, !model.muted)
|
2022-03-23 10:56:25 +00:00
|
|
|
},
|
2022-09-15 15:49:13 +00:00
|
|
|
StatusFlatButton {
|
2023-04-12 19:08:42 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
size: StatusBaseButton.Size.Small
|
2022-03-23 10:56:25 +00:00
|
|
|
icon.name: "invite-users"
|
|
|
|
onClicked: root.inviteFriends(model)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
} // StatusListItem
|
|
|
|
|
|
|
|
property Component leaveCommunityPopup: StatusModal {
|
|
|
|
id: leavePopup
|
2022-07-25 15:39:09 +00:00
|
|
|
|
2022-03-23 10:56:25 +00:00
|
|
|
property string community: ""
|
2022-07-25 15:39:09 +00:00
|
|
|
property string communityId: ""
|
|
|
|
|
2022-03-23 10:56:25 +00:00
|
|
|
anchors.centerIn: parent
|
2023-05-23 12:46:16 +00:00
|
|
|
headerSettings.title: qsTr("Leave %1").arg(community)
|
2022-03-23 10:56:25 +00:00
|
|
|
contentItem: Item {
|
|
|
|
implicitWidth: 368
|
|
|
|
implicitHeight: msg.implicitHeight + 32
|
|
|
|
StatusBaseText {
|
|
|
|
id: msg
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.margins: 16
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
text: qsTr("Are you sure you want to leave? Once you leave, you will have to request to rejoin if you change your mind.")
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rightButtons: [
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
onClicked: leavePopup.close()
|
|
|
|
},
|
|
|
|
StatusButton {
|
2022-08-11 12:24:49 +00:00
|
|
|
objectName: "CommunitiesListPanel_leaveCommunityButtonInPopup"
|
2022-03-23 10:56:25 +00:00
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
text: qsTr("Leave community")
|
|
|
|
onClicked: {
|
2022-06-21 14:08:24 +00:00
|
|
|
root.leaveCommunityClicked(leavePopup.communityId)
|
2022-03-23 10:56:25 +00:00
|
|
|
leavePopup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
} // ListView
|