2022-09-28 15:25:49 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
StatusScrollView {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var locale
|
|
|
|
property var model
|
|
|
|
property bool searchLayout: false
|
|
|
|
|
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 {
|
2022-10-15 17:54:30 +00:00
|
|
|
readonly property string tags: model.tags
|
|
|
|
|
|
|
|
JSONListModel {
|
|
|
|
id: tagsJson
|
|
|
|
json: tags
|
|
|
|
}
|
|
|
|
|
2022-09-28 15:25:49 +00:00
|
|
|
locale: root.locale
|
2022-10-18 08:50:58 +00:00
|
|
|
communityId: model.id
|
2022-09-28 15:25:49 +00:00
|
|
|
loaded: model.available
|
|
|
|
logo: 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
|
|
|
|
popularity: model.popularity
|
2022-10-15 17:54:30 +00:00
|
|
|
categories: tagsJson.model
|
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
|
|
|
|
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
|
|
|
|
columnSpacing: Style.current.padding
|
|
|
|
rowSpacing: Style.current.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
|
|
|
|
text: qsTr("Popular")
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: d.subtitlePixelSize
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
visible: !root.searchLayout
|
|
|
|
columns: 3
|
|
|
|
columnSpacing: Style.current.padding
|
|
|
|
rowSpacing: Style.current.padding
|
|
|
|
|
|
|
|
Repeater {
|
2022-10-20 06:49:21 +00:00
|
|
|
id: popularRepeater
|
2022-09-28 15:25:49 +00:00
|
|
|
model: popularModel
|
|
|
|
delegate: communityCardDelegate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|