2020-12-11 20:29:46 +00:00
|
|
|
|
import QtQuick 2.12
|
|
|
|
|
import QtQuick.Dialogs 1.3
|
|
|
|
|
import "../../../../imports"
|
|
|
|
|
import "../../../../shared"
|
|
|
|
|
import "../../../../shared/status"
|
|
|
|
|
import "../ContactsColumn"
|
|
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
|
property QtObject community: chatsModel.observedCommunity
|
|
|
|
|
property string communityId: community.id
|
|
|
|
|
property string name: community.name
|
|
|
|
|
property string description: community.description
|
2020-12-11 20:38:10 +00:00
|
|
|
|
property int access: community.access
|
2020-12-11 20:29:46 +00:00
|
|
|
|
// TODO get the real image once it's available
|
|
|
|
|
property string source: "../../../img/ens-header-dark@2x.png"
|
2020-12-11 20:38:10 +00:00
|
|
|
|
property int nbMembers: community.nbMembers
|
2020-12-11 20:29:46 +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 {
|
|
|
|
|
// TODO get this from access property
|
2020-12-11 20:38:10 +00:00
|
|
|
|
text: {
|
|
|
|
|
switch(access) {
|
|
|
|
|
case Constants.communityChatPublicAccess: return qsTr("Public community");
|
|
|
|
|
case Constants.communityChatInvitationOnlyAccess: return qsTr("Invitation only community");
|
|
|
|
|
case Constants.communityChatOnRequestAccess: return qsTr("On request community");
|
|
|
|
|
default: return qsTr("Unknown community");
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-11 20:29:46 +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
|
2020-12-15 16:04:19 +00:00
|
|
|
|
wrapMode: Text.Wrap
|
2020-12-11 20:29:46 +00:00
|
|
|
|
width: parent.width
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
font.weight: Font.Thin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: memberContainer
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: memberImage.height
|
|
|
|
|
anchors.top: descriptionText.bottom
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
|
id: memberImage
|
|
|
|
|
source: "../../../img/member.svg"
|
|
|
|
|
width: 16
|
|
|
|
|
height: 16
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StyledText {
|
2020-12-15 16:04:19 +00:00
|
|
|
|
text: nbMembers === 1 ?
|
|
|
|
|
qsTr("1 member") :
|
|
|
|
|
qsTr("%1 members").arg(popup.nbMembers)
|
2020-12-11 20:29:46 +00:00
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.left: memberImage.right
|
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
font.weight: Font.Medium
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
|
id: sep1
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.top: memberContainer.bottom
|
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: chatsTitle
|
|
|
|
|
text: qsTr("Chats")
|
|
|
|
|
anchors.top: sep1.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
font.weight: Font.Thin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
|
id: chatsList
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.top: chatsTitle.bottom
|
|
|
|
|
anchors.topMargin: 4
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
clip: true
|
|
|
|
|
model: community.chats
|
2020-12-15 16:04:19 +00:00
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
2020-12-11 20:29:46 +00:00
|
|
|
|
delegate: Channel {
|
|
|
|
|
id: channelItem
|
|
|
|
|
unviewedMessagesCount: ""
|
|
|
|
|
width: parent.width
|
|
|
|
|
name: model.name
|
|
|
|
|
lastMessage: model.description
|
|
|
|
|
contentType: Constants.messageType
|
|
|
|
|
border.width: 0
|
|
|
|
|
color: Style.current.transparent
|
2020-12-15 16:04:19 +00:00
|
|
|
|
enableMouseArea: false
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
footer: Item {
|
2021-01-13 19:15:52 +00:00
|
|
|
|
width: parent.width
|
|
|
|
|
height: backButton.height
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
|
|
|
|
StatusIconButton {
|
|
|
|
|
id: backButton
|
|
|
|
|
icon.name: "leave_chat"
|
|
|
|
|
width: 44
|
|
|
|
|
height: 44
|
|
|
|
|
iconColor: Style.current.primary
|
|
|
|
|
highlighted: true
|
|
|
|
|
icon.color: Style.current.primary
|
|
|
|
|
icon.width: 28
|
|
|
|
|
icon.height: 28
|
|
|
|
|
radius: width / 2
|
|
|
|
|
onClicked: {
|
|
|
|
|
openPopup(communitiesPopupComponent)
|
|
|
|
|
popup.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
|
text: qsTr("Join ‘%1’").arg(popup.name)
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
onClicked: {
|
|
|
|
|
const error = chatsModel.joinCommunity(popup.communityId)
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
joiningError.text = error
|
|
|
|
|
return joiningError.open()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
popup.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
|
id: joiningError
|
|
|
|
|
title: qsTr("Error joining the community")
|
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|