2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2022-09-28 15:25:49 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
2022-10-15 17:54:30 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2022-09-28 15:25:49 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2023-06-23 06:17:04 +00:00
|
|
|
import AppLayouts.Communities.controls 1.0
|
2024-05-10 14:55:20 +00:00
|
|
|
import AppLayouts.Communities.helpers 1.0
|
2023-04-18 14:22:27 +00:00
|
|
|
|
2022-09-28 15:25:49 +00:00
|
|
|
StatusScrollView {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var model
|
|
|
|
property bool searchLayout: false
|
|
|
|
|
2023-04-18 14:22:27 +00:00
|
|
|
property var assetsModel
|
|
|
|
property var collectiblesModel
|
|
|
|
|
2022-10-20 06:49:21 +00:00
|
|
|
readonly property bool isEmpty: !featuredRepeater.count && !popularRepeater.count
|
|
|
|
|
2022-09-28 15:25:49 +00:00
|
|
|
signal cardClicked(string communityId)
|
|
|
|
|
|
|
|
clip: false
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
// values from the design
|
|
|
|
readonly property int scrollViewTopMargin: 20
|
|
|
|
readonly property int subtitlePixelSize: 17
|
|
|
|
}
|
|
|
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
id: featuredModel
|
|
|
|
|
|
|
|
sourceModel: root.model
|
|
|
|
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "featured"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
id: popularModel
|
|
|
|
|
|
|
|
sourceModel: root.model
|
|
|
|
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "featured"
|
|
|
|
value: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communityCardDelegate
|
|
|
|
|
|
|
|
StatusCommunityCard {
|
2023-04-18 14:22:27 +00:00
|
|
|
id: card
|
|
|
|
|
2022-10-15 17:54:30 +00:00
|
|
|
readonly property string tags: model.tags
|
2023-04-18 14:22:27 +00:00
|
|
|
readonly property var permissionsList: model.permissionsModel
|
2024-05-10 14:55:20 +00:00
|
|
|
readonly property bool isTokenGatedCommunity: PermissionsHelpers.isTokenGatedCommunity(permissionsList)
|
2022-10-15 17:54:30 +00:00
|
|
|
|
|
|
|
JSONListModel {
|
|
|
|
id: tagsJson
|
|
|
|
json: tags
|
|
|
|
}
|
|
|
|
|
2022-10-18 08:50:58 +00:00
|
|
|
communityId: model.id
|
2022-09-28 15:25:49 +00:00
|
|
|
loaded: model.available
|
2024-02-15 09:25:40 +00:00
|
|
|
asset.source: model.icon
|
2022-09-29 12:47:11 +00:00
|
|
|
banner: model.banner
|
2022-10-18 08:50:58 +00:00
|
|
|
communityColor: model.color
|
2022-09-28 15:25:49 +00:00
|
|
|
name: model.name
|
|
|
|
description: model.description
|
|
|
|
members: model.members
|
2023-03-30 12:54:13 +00:00
|
|
|
activeUsers: model.activeMembers
|
2022-09-28 15:25:49 +00:00
|
|
|
popularity: model.popularity
|
2022-10-15 17:54:30 +00:00
|
|
|
categories: tagsJson.model
|
2024-04-29 12:08:57 +00:00
|
|
|
memberCountVisible: model.joined || !model.encrypted
|
2022-09-28 15:25:49 +00:00
|
|
|
|
2023-06-16 18:38:32 +00:00
|
|
|
// Community restrictions
|
2024-05-10 14:55:20 +00:00
|
|
|
Binding {
|
|
|
|
target: card
|
|
|
|
property: "rigthHeaderComponent"
|
|
|
|
when: card.isTokenGatedCommunity
|
|
|
|
value: Component {
|
|
|
|
PermissionsRow {
|
|
|
|
readonly property int eligibleToJoinAs: PermissionsHelpers.isEligibleToJoinAs(card.permissionsList)
|
|
|
|
|
|
|
|
assetsModel: root.assetsModel
|
|
|
|
collectiblesModel: root.collectiblesModel
|
|
|
|
model: card.permissionsList
|
|
|
|
requirementsMet: eligibleToJoinAs === PermissionTypes.Type.Member
|
|
|
|
|| eligibleToJoinAs === PermissionTypes.Type.Admin
|
|
|
|
|| eligibleToJoinAs === PermissionTypes.Type.Owner
|
|
|
|
overlappingBorder: 0
|
|
|
|
}
|
|
|
|
}
|
2023-04-18 14:22:27 +00:00
|
|
|
}
|
|
|
|
|
2022-09-28 15:25:49 +00:00
|
|
|
onClicked: root.cardClicked(communityId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: contentColumn
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: featuredLabel
|
2022-10-20 06:49:21 +00:00
|
|
|
visible: !root.searchLayout && featuredRepeater.count
|
2022-09-28 15:25:49 +00:00
|
|
|
Layout.topMargin: d.scrollViewTopMargin
|
2023-03-03 12:51:21 +00:00
|
|
|
//: Featured communities
|
2022-09-28 15:25:49 +00:00
|
|
|
text: qsTr("Featured")
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: d.subtitlePixelSize
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
Layout.topMargin: root.searchLayout
|
|
|
|
? featuredLabel.height + contentColumn.spacing + featuredLabel.Layout.topMargin
|
|
|
|
: 0
|
|
|
|
columns: 3
|
2024-10-15 19:26:12 +00:00
|
|
|
columnSpacing: Theme.padding
|
|
|
|
rowSpacing: Theme.padding
|
2022-10-20 06:49:21 +00:00
|
|
|
visible: featuredRepeater.count
|
2022-09-28 15:25:49 +00:00
|
|
|
|
|
|
|
Repeater {
|
2022-10-20 06:49:21 +00:00
|
|
|
id: featuredRepeater
|
2022-09-28 15:25:49 +00:00
|
|
|
model: root.searchLayout ? root.model : featuredModel
|
|
|
|
delegate: communityCardDelegate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
2022-10-20 06:49:21 +00:00
|
|
|
visible: !root.searchLayout && popularRepeater.count
|
2022-09-28 15:25:49 +00:00
|
|
|
Layout.topMargin: 20
|
2023-03-03 12:51:21 +00:00
|
|
|
//: All communities
|
|
|
|
text: qsTr("All")
|
2022-09-28 15:25:49 +00:00
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: d.subtitlePixelSize
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
visible: !root.searchLayout
|
|
|
|
columns: 3
|
2024-10-15 19:26:12 +00:00
|
|
|
columnSpacing: Theme.padding
|
|
|
|
rowSpacing: Theme.padding
|
2022-09-28 15:25:49 +00:00
|
|
|
|
|
|
|
Repeater {
|
2022-10-20 06:49:21 +00:00
|
|
|
id: popularRepeater
|
2022-09-28 15:25:49 +00:00
|
|
|
model: popularModel
|
|
|
|
delegate: communityCardDelegate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|