2020-12-15 16:04:19 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Dialogs 1.3
|
2020-12-16 18:56:48 +00:00
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtGraphicalEffects 1.13
|
2020-12-15 16:04:19 +00:00
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../shared/status"
|
|
|
|
import "../ContactsColumn"
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
property QtObject community: chatsModel.activeCommunity
|
|
|
|
property string communityId: community.id
|
|
|
|
property string name: community.name
|
|
|
|
property string description: community.description
|
|
|
|
property int access: community.access
|
|
|
|
// TODO get the real image once it's available
|
|
|
|
property string source: "../../../img/ens-header-dark@2x.png"
|
|
|
|
property int nbMembers: community.nbMembers
|
2020-12-17 13:24:33 +00:00
|
|
|
property bool isAdmin: true // TODO:
|
2020-12-18 20:15:00 +00:00
|
|
|
height: isAdmin ? 640 : 509
|
2020-12-15 16:04:19 +00:00
|
|
|
|
|
|
|
id: popup
|
|
|
|
|
|
|
|
header: Item {
|
|
|
|
height: childrenRect.height
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
RoundedImage {
|
|
|
|
id: communityImg
|
|
|
|
source: popup.source
|
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: communityName
|
|
|
|
text: popup.name
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 2
|
|
|
|
anchors.left: communityImg.right
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 17
|
|
|
|
readOnly: true
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
text: {
|
|
|
|
switch(access) {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Public community"
|
|
|
|
case Constants.communityChatPublicAccess: return qsTrId("public-community");
|
|
|
|
//% "Invitation only community"
|
|
|
|
case Constants.communityChatInvitationOnlyAccess: return qsTrId("invitation-only-community");
|
|
|
|
//% "On request community"
|
|
|
|
case Constants.communityChatOnRequestAccess: return qsTrId("on-request-community");
|
|
|
|
//% "Unknown community"
|
|
|
|
default: return qsTrId("unknown-community");
|
2020-12-15 16:04:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
anchors.left: communityName.left
|
|
|
|
anchors.top: communityName.bottom
|
|
|
|
anchors.topMargin: 2
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.weight: Font.Thin
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: descriptionText
|
|
|
|
text: popup.description
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
width: parent.width
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.weight: Font.Thin
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
id: sep1
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: descriptionText.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
}
|
|
|
|
|
2020-12-16 18:56:48 +00:00
|
|
|
TextWithLabel {
|
|
|
|
id: shareCommunity
|
2020-12-15 16:04:19 +00:00
|
|
|
anchors.top: sep1.bottom
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Share community"
|
|
|
|
label: qsTrId("share-community")
|
2020-12-16 18:56:48 +00:00
|
|
|
text: "https://join.status.im/u/TODO"
|
|
|
|
textToCopy: text
|
2020-12-15 16:04:19 +00:00
|
|
|
}
|
|
|
|
|
2020-12-16 18:56:48 +00:00
|
|
|
Separator {
|
|
|
|
id: sep2
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: shareCommunity.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
anchors.top: sep2.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
width: parent.width
|
|
|
|
spacing: Style.current.padding
|
|
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
active: isAdmin
|
|
|
|
width: parent.width
|
2021-02-11 19:06:39 +00:00
|
|
|
sourceComponent: Component {
|
|
|
|
CommunityPopupButton {
|
|
|
|
id: memberBtn
|
|
|
|
label: qsTr("Members")
|
|
|
|
iconName: "members"
|
|
|
|
txtColor: Style.current.textColor
|
|
|
|
onClicked: openPopup(communityMembersPopup)
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communityMembersPopup
|
|
|
|
CommunityMembersPopup {}
|
2020-12-16 18:56:48 +00:00
|
|
|
}
|
|
|
|
|
2021-02-11 19:06:39 +00:00
|
|
|
Item {
|
|
|
|
property int nbRequests: chatsModel.activeCommunity.communityMembershipRequests.nbRequests
|
|
|
|
|
|
|
|
id: memberBlock
|
2020-12-16 18:56:48 +00:00
|
|
|
anchors.top: parent.top
|
2021-02-11 19:06:39 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 0
|
|
|
|
width: childrenRect.width
|
|
|
|
height: memberBtn.height
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: nbMemberText
|
|
|
|
text: nbMembers.toString()
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
padding: 0
|
|
|
|
font.pixelSize: 15
|
2020-12-16 18:56:48 +00:00
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
2021-02-11 19:06:39 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: badge
|
|
|
|
visible: memberBlock.nbRequests > 0
|
|
|
|
anchors.left: nbMemberText.right
|
|
|
|
anchors.leftMargin: visible ? Style.current.halfPadding : 0
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
color: Style.current.blue
|
|
|
|
width: visible ? 22 : 0
|
|
|
|
height: 22
|
|
|
|
radius: width / 2
|
|
|
|
Text {
|
|
|
|
font.pixelSize: 12
|
|
|
|
color: Style.current.white
|
|
|
|
anchors.centerIn: parent
|
|
|
|
text: memberBlock.nbRequests
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: caret
|
|
|
|
anchors.left: badge.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
source: "../../../img/caret.svg"
|
|
|
|
width: 13
|
|
|
|
height: 7
|
|
|
|
rotation: -90
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
}
|
2020-12-16 18:56:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
active: isAdmin
|
|
|
|
width: parent.width
|
|
|
|
sourceComponent: CommunityPopupButton {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Roles"
|
|
|
|
label: qsTrId("roles")
|
2020-12-16 18:56:48 +00:00
|
|
|
iconName: "roles"
|
|
|
|
width: parent.width
|
|
|
|
onClicked: console.log("TODO:")
|
|
|
|
txtColor: Style.current.textColor
|
|
|
|
SVGImage {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 0
|
|
|
|
source: "../../../img/caret.svg"
|
|
|
|
width: 13
|
|
|
|
height: 7
|
|
|
|
rotation: -90
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-18 20:15:00 +00:00
|
|
|
|
2020-12-16 18:56:48 +00:00
|
|
|
CommunityPopupButton {
|
|
|
|
id: notificationsBtn
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Notifications"
|
|
|
|
label: qsTrId("notifications")
|
2020-12-16 18:56:48 +00:00
|
|
|
iconName: "notifications"
|
|
|
|
width: parent.width
|
|
|
|
txtColor: Style.current.textColor
|
|
|
|
onClicked: function(){
|
|
|
|
notificationSwitch.checked = !notificationSwitch.checked
|
|
|
|
}
|
|
|
|
StatusSwitch {
|
|
|
|
id: notificationSwitch
|
|
|
|
anchors.right: parent.right
|
|
|
|
onCheckedChanged: function(value) {
|
|
|
|
// TODO: enable/disable notifications
|
|
|
|
console.log("TODO: toggle")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-18 20:15:00 +00:00
|
|
|
|
2020-12-16 18:56:48 +00:00
|
|
|
Separator {
|
|
|
|
width: parent.width
|
|
|
|
}
|
2020-12-18 20:15:00 +00:00
|
|
|
|
2020-12-16 18:56:48 +00:00
|
|
|
Loader {
|
|
|
|
active: isAdmin
|
|
|
|
width: parent.width
|
|
|
|
sourceComponent: CommunityPopupButton {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Edit community"
|
|
|
|
label: qsTrId("edit-community")
|
2020-12-16 18:56:48 +00:00
|
|
|
iconName: "edit"
|
2020-12-17 13:24:33 +00:00
|
|
|
onClicked: openPopup(editCommunityPopup)
|
|
|
|
Component {
|
|
|
|
id: editCommunityPopup
|
|
|
|
CreateCommunityPopup {
|
|
|
|
isEdit: true
|
|
|
|
}
|
|
|
|
}
|
2020-12-16 18:56:48 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-18 20:15:00 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
property string exportResult: ""
|
|
|
|
|
|
|
|
active: isAdmin
|
|
|
|
width: parent.width
|
|
|
|
sourceComponent: !exportResult ? exportBtn : resultComponent
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: exportBtn
|
|
|
|
CommunityPopupButton {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Export community"
|
|
|
|
label: qsTrId("export-community")
|
2020-12-18 20:15:00 +00:00
|
|
|
iconName: "../fetch"
|
|
|
|
onClicked: exportResult = chatsModel.exportComumnity()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: resultComponent
|
|
|
|
StyledText {
|
|
|
|
property bool isError: !exportResult.startsWith("0x")
|
|
|
|
|
|
|
|
text: exportResult
|
|
|
|
color: isError ? Style.current.danger : Style.current.textColor
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.smallPadding + copyToClipboardBtn.width
|
|
|
|
wrapMode: TextEdit.WrapAnywhere
|
|
|
|
|
|
|
|
CopyToClipBoardButton {
|
|
|
|
id: copyToClipboardBtn
|
|
|
|
visible: !isError
|
|
|
|
textToCopy: exportResult
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.right
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-16 18:56:48 +00:00
|
|
|
CommunityPopupButton {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Leave community"
|
|
|
|
label: qsTrId("leave-community")
|
2020-12-16 18:56:48 +00:00
|
|
|
iconName: "leave"
|
|
|
|
}
|
2020-12-18 20:15:00 +00:00
|
|
|
|
2020-12-16 18:56:48 +00:00
|
|
|
Loader {
|
|
|
|
active: isAdmin
|
|
|
|
width: parent.width
|
|
|
|
sourceComponent: CommunityPopupButton {
|
|
|
|
id: deleteBtn
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Delete"
|
|
|
|
label: qsTrId("delete")
|
2020-12-16 18:56:48 +00:00
|
|
|
iconName: "delete"
|
|
|
|
txtColor: Style.current.red
|
|
|
|
//btnColor: Style.current.red // TODO: statusroundbutton should support changing color
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-15 16:04:19 +00:00
|
|
|
}
|
|
|
|
|