2020-12-11 20:29:46 +00:00
|
|
|
|
import QtQuick 2.12
|
2021-07-19 12:25:52 +00:00
|
|
|
|
import QtQuick.Controls 2.3
|
2020-12-11 20:29:46 +00:00
|
|
|
|
import QtQuick.Dialogs 1.3
|
2021-07-19 12:25:52 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
|
|
import utils 1.0
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
StatusModal {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property var store
|
|
|
|
|
property QtObject community: root.store.chatsModelInst.communities.observedCommunity
|
2020-12-11 20:29:46 +00:00
|
|
|
|
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
|
2021-02-10 20:37:17 +00:00
|
|
|
|
property string source: community.thumbnailImage
|
2020-12-11 20:38:10 +00:00
|
|
|
|
property int nbMembers: community.nbMembers
|
2021-02-10 20:37:17 +00:00
|
|
|
|
property bool ensOnly: community.ensOnly
|
|
|
|
|
property bool canJoin: community.canJoin
|
|
|
|
|
property bool canRequestAccess: community.canRequestAccess
|
2021-03-09 11:50:45 +00:00
|
|
|
|
property bool isMember: community.isMember
|
2021-03-23 19:13:36 +00:00
|
|
|
|
property string communityColor: community.communityColor || Style.current.blue
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
header.title: name
|
|
|
|
|
header.subTitle: {
|
|
|
|
|
let subTitle = ""
|
|
|
|
|
switch(access) {
|
|
|
|
|
case Constants.communityChatPublicAccess:
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "Public community"
|
|
|
|
|
subTitle = qsTrId("public-community");
|
2021-07-19 12:25:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case Constants.communityChatInvitationOnlyAccess:
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "Invitation only community"
|
|
|
|
|
subTitle = qsTrId("invitation-only-community");
|
2021-07-19 12:25:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case Constants.communityChatOnRequestAccess:
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "On request community"
|
|
|
|
|
subTitle = qsTrId("on-request-community");
|
2021-07-19 12:25:52 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
subTitle = qsTrId("Unknown community");
|
|
|
|
|
break;
|
2021-03-23 19:13:36 +00:00
|
|
|
|
}
|
2021-07-19 12:25:52 +00:00
|
|
|
|
if (ensOnly) {
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% " - ENS only"
|
|
|
|
|
subTitle += qsTrId("---ens-only")
|
2021-03-23 19:13:36 +00:00
|
|
|
|
}
|
2021-07-19 12:25:52 +00:00
|
|
|
|
return subTitle
|
|
|
|
|
}
|
2021-03-23 19:13:36 +00:00
|
|
|
|
|
2021-09-02 14:40:10 +00:00
|
|
|
|
contentItem: Column {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
width: root.width
|
2021-07-19 12:25:52 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
height: childrenRect.height + 8
|
|
|
|
|
width: parent.width - 32
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: description
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 16
|
2021-10-22 20:49:47 +00:00
|
|
|
|
text: root.description
|
2021-07-19 12:25:52 +00:00
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
wrapMode: Text.WordWrap
|
2021-07-26 13:53:39 +00:00
|
|
|
|
width: parent.width
|
2021-03-23 19:13:36 +00:00
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
StatusIcon {
|
|
|
|
|
id: statusIcon
|
|
|
|
|
anchors.top: description.bottom
|
|
|
|
|
anchors.topMargin: 16
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
icon: "tiny/contact"
|
|
|
|
|
width: 16
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
StatusBaseText {
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "%1 members"
|
|
|
|
|
text: qsTrId("-1-members").arg(nbMembers)
|
2021-07-19 12:25:52 +00:00
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
font.weight: Font.Medium
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
anchors.left: statusIcon.right
|
|
|
|
|
anchors.leftMargin: 2
|
|
|
|
|
anchors.verticalCenter: statusIcon.verticalCenter
|
2020-12-11 20:38:10 +00:00
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
StatusModalDivider {
|
|
|
|
|
topPadding: 8
|
|
|
|
|
bottomPadding: 8
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
Item {
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
width: parent.width - 32
|
|
|
|
|
height: 34
|
|
|
|
|
StatusBaseText {
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "Channels"
|
|
|
|
|
text: qsTrId("channels")
|
2021-07-19 12:25:52 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.bottomMargin: 4
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
ScrollView {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
width: root.width
|
2021-07-19 12:25:52 +00:00
|
|
|
|
height: 300
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
clip: true
|
|
|
|
|
ListView {
|
|
|
|
|
id: chatList
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
clip: true
|
|
|
|
|
model: community.chats
|
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
|
|
|
delegate: StatusListItem {
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
title: "#" + model.name
|
|
|
|
|
subTitle: model.description
|
|
|
|
|
icon.isLetterIdenticon: true
|
2021-10-22 20:49:47 +00:00
|
|
|
|
icon.background.color: root.communityColor
|
2021-07-19 12:25:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
leftButtons: [
|
|
|
|
|
StatusRoundButton {
|
2020-12-11 20:29:46 +00:00
|
|
|
|
id: backButton
|
2021-07-19 12:25:52 +00:00
|
|
|
|
icon.name: "arrow-right"
|
|
|
|
|
icon.height: 16
|
|
|
|
|
icon.width: 20
|
|
|
|
|
rotation: 180
|
2020-12-11 20:29:46 +00:00
|
|
|
|
onClicked: {
|
2021-11-02 14:11:35 +00:00
|
|
|
|
openPopup(communitiesPopupComponent)
|
2021-10-22 20:49:47 +00:00
|
|
|
|
root.close()
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-19 12:25:52 +00:00
|
|
|
|
]
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
rightButtons: [
|
2020-12-11 20:29:46 +00:00
|
|
|
|
StatusButton {
|
2021-02-10 20:37:17 +00:00
|
|
|
|
property bool isPendingRequest: {
|
|
|
|
|
if (access !== Constants.communityChatOnRequestAccess) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2021-10-22 20:49:47 +00:00
|
|
|
|
return root.store.chatsModelInst.communities.isCommunityRequestPending(root.communityId)
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
text: {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
if (root.ensOnly && !root.store.profileModelInst.profile.ensVerified) {
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "Membership requires an ENS username"
|
|
|
|
|
return qsTrId("membership-requires-an-ens-username")
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
2021-10-22 20:49:47 +00:00
|
|
|
|
if (root.canJoin) {
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "Join ‘%1’"
|
2021-10-22 20:49:47 +00:00
|
|
|
|
return qsTrId("join---1-").arg(root.name);
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
if (isPendingRequest) {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Pending"
|
|
|
|
|
return qsTrId("invite-chat-pending")
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
2021-10-22 20:49:47 +00:00
|
|
|
|
switch(root.access) {
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "Join ‘%1’"
|
2021-10-22 20:49:47 +00:00
|
|
|
|
case Constants.communityChatPublicAccess: return qsTrId("join---1-").arg(root.name);
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "You need to be invited"
|
|
|
|
|
case Constants.communityChatInvitationOnlyAccess: return qsTrId("you-need-to-be-invited");
|
|
|
|
|
//% "Request to join ‘%1’"
|
2021-10-22 20:49:47 +00:00
|
|
|
|
case Constants.communityChatOnRequestAccess: return qsTrId("request-to-join---1-").arg(root.name);
|
2021-07-22 15:03:59 +00:00
|
|
|
|
//% "Unknown community"
|
|
|
|
|
default: return qsTrId("unknown-community");
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
enabled: {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
if (root.ensOnly && !root.store.profileModelInst.profile.ensVerified) {
|
2021-02-10 20:37:17 +00:00
|
|
|
|
return false
|
|
|
|
|
}
|
2021-10-22 20:49:47 +00:00
|
|
|
|
if (root.access === Constants.communityChatInvitationOnlyAccess || isPendingRequest) {
|
2021-02-10 20:37:17 +00:00
|
|
|
|
return false
|
|
|
|
|
}
|
2021-04-29 19:54:09 +00:00
|
|
|
|
if (canJoin) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
|
return true
|
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
onClicked: {
|
2021-02-10 20:37:17 +00:00
|
|
|
|
let error
|
2021-10-22 20:49:47 +00:00
|
|
|
|
if (access === Constants.communityChatOnRequestAccess && !root.isMember) {
|
2021-12-01 12:46:21 +00:00
|
|
|
|
error = root.store.chatsModelInst.communities.requestToJoinCommunity(root.communityId, userProfile.name)
|
2021-02-10 20:37:17 +00:00
|
|
|
|
if (!error) {
|
|
|
|
|
enabled = false
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Pending"
|
|
|
|
|
text = qsTrId("invite-chat-pending")
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
error = root.store.chatsModelInst.communities.joinCommunity(root.communityId, true)
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
joiningError.text = error
|
|
|
|
|
return joiningError.open()
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-22 20:49:47 +00:00
|
|
|
|
root.close()
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-19 12:25:52 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
|
id: joiningError
|
|
|
|
|
//% "Error joining the community"
|
|
|
|
|
title: qsTrId("error-joining-the-community")
|
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
|
standardButtons: StandardButton.Ok
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|