2024-02-27 17:11:03 +00:00
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
|
|
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
2024-10-03 16:50:43 +00:00
|
|
|
|
import AppLayouts.Communities.controls 1.0
|
|
|
|
|
import AppLayouts.Communities.helpers 1.0
|
|
|
|
|
|
2024-02-27 17:11:03 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
required property string mainDisplayName
|
|
|
|
|
required property bool readOnly
|
|
|
|
|
required property var communitiesProxyModel
|
|
|
|
|
required property var globalAssetsModel
|
|
|
|
|
required property var globalCollectiblesModel
|
|
|
|
|
|
|
|
|
|
property alias cellWidth: communitiesView.cellWidth
|
|
|
|
|
property alias cellHeight: communitiesView.cellHeight
|
|
|
|
|
|
|
|
|
|
signal copyToClipboard(string text)
|
|
|
|
|
signal closeRequested()
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
visible: (communitiesView.count === 0)
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
text: qsTr("%1 has not shared any communities").arg(root.mainDisplayName)
|
|
|
|
|
}
|
|
|
|
|
StatusGridView {
|
|
|
|
|
id: communitiesView
|
|
|
|
|
|
|
|
|
|
anchors.fill: parent
|
2024-10-15 19:26:12 +00:00
|
|
|
|
topMargin: Theme.bigPadding
|
|
|
|
|
bottomMargin: Theme.bigPadding
|
|
|
|
|
leftMargin: Theme.bigPadding
|
2024-02-27 17:11:03 +00:00
|
|
|
|
|
|
|
|
|
visible: count
|
|
|
|
|
model: root.communitiesProxyModel
|
|
|
|
|
ScrollBar.vertical: StatusScrollBar { anchors.right: parent.right; anchors.rightMargin: width / 2 }
|
|
|
|
|
delegate: StatusCommunityCard {
|
|
|
|
|
id: profileDialogCommunityCard
|
|
|
|
|
readonly property var permissionsList: model.permissionsModel
|
2024-10-03 16:50:43 +00:00
|
|
|
|
readonly property bool isTokenGatedCommunity: PermissionsHelpers.isTokenGatedCommunity(permissionsList)
|
|
|
|
|
|
2024-02-27 17:11:03 +00:00
|
|
|
|
cardSize: StatusCommunityCard.Size.Small
|
2024-10-15 19:26:12 +00:00
|
|
|
|
implicitWidth: GridView.view.cellWidth - Theme.padding
|
|
|
|
|
implicitHeight: GridView.view.cellHeight - Theme.padding
|
2024-02-27 17:11:03 +00:00
|
|
|
|
titleFontSize: 15
|
|
|
|
|
communityId: model.id ?? ""
|
2024-04-07 22:00:16 +00:00
|
|
|
|
loaded: !!model.id && !model.isShowcaseLoading
|
2024-02-27 17:11:03 +00:00
|
|
|
|
asset.source: model.image ?? ""
|
|
|
|
|
asset.isImage: !!model.image
|
|
|
|
|
asset.width: 32
|
|
|
|
|
asset.height: 32
|
|
|
|
|
name: model.name ?? ""
|
2024-10-03 16:50:43 +00:00
|
|
|
|
memberCountVisible: model.joined || !model.encrypted
|
2024-02-27 17:11:03 +00:00
|
|
|
|
banner: model.bannerImageData ?? ""
|
|
|
|
|
descriptionFontSize: 12
|
|
|
|
|
descriptionFontColor: Theme.palette.baseColor1
|
|
|
|
|
description: {
|
|
|
|
|
switch (model.memberRole) {
|
|
|
|
|
case (Constants.memberRole.owner):
|
|
|
|
|
return qsTr("Owner");
|
|
|
|
|
case (Constants.memberRole.admin) :
|
|
|
|
|
return qsTr("Admin");
|
|
|
|
|
case (Constants.memberRole.tokenMaster):
|
|
|
|
|
return qsTr("Token Master");
|
|
|
|
|
default:
|
|
|
|
|
return qsTr("Member");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
communityColor: model.color ?? ""
|
|
|
|
|
// Community restrictions
|
|
|
|
|
bottomRowComponent: (model.joined && !root.readOnly) ?
|
|
|
|
|
communityMembershipComponent :
|
2024-10-03 16:50:43 +00:00
|
|
|
|
isTokenGatedCommunity ? permissionsRowComponent : null
|
2024-02-27 17:11:03 +00:00
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: communityMembershipComponent
|
|
|
|
|
Item {
|
|
|
|
|
width: 125
|
|
|
|
|
height: 24
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
radius: 20
|
|
|
|
|
color: Theme.palette.successColor1
|
|
|
|
|
opacity: .1
|
|
|
|
|
border.color: Theme.palette.successColor1
|
|
|
|
|
}
|
|
|
|
|
Row {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
spacing: 2
|
|
|
|
|
StatusIcon {
|
|
|
|
|
width: 16
|
|
|
|
|
height: 16
|
|
|
|
|
color: Theme.palette.successColor1
|
|
|
|
|
icon: "tiny/checkmark"
|
|
|
|
|
}
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize
|
|
|
|
|
color: Theme.palette.successColor1
|
|
|
|
|
text: qsTr("You’re there too")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: permissionsRowComponent
|
|
|
|
|
PermissionsRow {
|
2024-10-03 16:50:43 +00:00
|
|
|
|
readonly property int eligibleToJoinAs: PermissionsHelpers.isEligibleToJoinAs(profileDialogCommunityCard.permissionsList)
|
|
|
|
|
|
2024-02-27 17:11:03 +00:00
|
|
|
|
assetsModel: root.globalAssetsModel
|
|
|
|
|
collectiblesModel: root.globalCollectiblesModel
|
|
|
|
|
model: profileDialogCommunityCard.permissionsList
|
2024-10-03 16:50:43 +00:00
|
|
|
|
requirementsMet: eligibleToJoinAs === PermissionTypes.Type.Member
|
|
|
|
|
|| eligibleToJoinAs === PermissionTypes.Type.Admin
|
|
|
|
|
|| eligibleToJoinAs === PermissionTypes.Type.Owner
|
2024-02-27 17:11:03 +00:00
|
|
|
|
backgroundBorderColor: Theme.palette.baseColor2
|
|
|
|
|
backgroundRadius: 20
|
2024-10-03 16:50:43 +00:00
|
|
|
|
fontPixelSize: 10
|
2024-02-27 17:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
|
if (root.readOnly)
|
|
|
|
|
return
|
2024-05-01 13:19:57 +00:00
|
|
|
|
Global.switchToCommunity(model.id)
|
|
|
|
|
root.closeRequested()
|
|
|
|
|
}
|
|
|
|
|
onRightClicked: {
|
|
|
|
|
if (root.readOnly)
|
|
|
|
|
return
|
|
|
|
|
Global.openMenu(delegatesActionsMenu, this, { communityId: model.id, url: Utils.getCommunityShareLink(model.id) })
|
2024-02-27 17:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: delegatesActionsMenu
|
|
|
|
|
StatusMenu {
|
|
|
|
|
id: contextMenu
|
|
|
|
|
|
|
|
|
|
property string url
|
|
|
|
|
property string communityId
|
|
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
|
text: qsTr("Visit community")
|
|
|
|
|
icon.name: "arrow-right"
|
|
|
|
|
onTriggered: {
|
|
|
|
|
Global.switchToCommunity(contextMenu.communityId);
|
|
|
|
|
root.closeRequested();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
|
text: qsTr("Invite People")
|
|
|
|
|
icon.name: "share-ios"
|
|
|
|
|
onTriggered: {
|
|
|
|
|
Global.openInviteFriendsToCommunityByIdPopup(contextMenu.communityId, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusSuccessAction {
|
|
|
|
|
id: copyAddressAction
|
|
|
|
|
successText: qsTr("Copied")
|
|
|
|
|
text: qsTr("Copy link to community")
|
|
|
|
|
icon.name: "copy"
|
|
|
|
|
onTriggered: {
|
|
|
|
|
root.copyToClipboard(contextMenu.url)
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-03 16:50:43 +00:00
|
|
|
|
|
|
|
|
|
onClosed: destroy()
|
2024-02-27 17:11:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|