2020-12-11 15:29:46 -05:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.3
|
2021-07-19 13:21:05 +02:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
2021-09-28 18:04:06 +03:00
|
|
|
import utils 1.0
|
2021-10-28 00:27:49 +03:00
|
|
|
import shared 1.0
|
2020-12-11 15:29:46 -05:00
|
|
|
|
2021-07-19 13:21:05 +02:00
|
|
|
StatusModal {
|
2020-12-11 15:29:46 -05:00
|
|
|
id: popup
|
|
|
|
|
2021-10-22 23:49:47 +03:00
|
|
|
property var communitiesList
|
|
|
|
signal setActiveCommunity(string id)
|
|
|
|
signal setObservedCommunity(string id)
|
2022-05-10 19:04:25 +03:00
|
|
|
signal openCommunityDetail()
|
|
|
|
signal importCommunityClicked()
|
|
|
|
signal createCommunityClicked()
|
2021-10-22 23:49:47 +03:00
|
|
|
|
2020-12-11 15:29:46 -05:00
|
|
|
onOpened: {
|
2021-09-07 15:42:50 +02:00
|
|
|
contentItem.searchBox.input.text = "";
|
|
|
|
contentItem.searchBox.input.forceActiveFocus(Qt.MouseFocusReason)
|
2020-12-11 15:29:46 -05:00
|
|
|
}
|
|
|
|
|
2022-04-04 13:26:30 +02:00
|
|
|
header.title: qsTr("Communities")
|
2021-07-19 13:21:05 +02:00
|
|
|
headerActionButton: StatusFlatRoundButton {
|
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
icon.name: "more"
|
|
|
|
|
|
|
|
onClicked: contextMenu.popup(-contextMenu.width+width, height + 4)
|
|
|
|
|
2022-12-01 19:58:37 +03:00
|
|
|
StatusMenu {
|
2021-07-19 13:21:05 +02:00
|
|
|
id: contextMenu
|
2022-04-13 13:54:53 +03:00
|
|
|
width: 230
|
2022-12-01 19:58:37 +03:00
|
|
|
StatusAction {
|
2021-07-19 13:21:05 +02:00
|
|
|
icon.name: "download"
|
2022-04-04 13:26:30 +02:00
|
|
|
text: qsTr("Access existing community")
|
2022-05-10 19:04:25 +03:00
|
|
|
onTriggered: {
|
|
|
|
popup.importCommunityClicked();
|
|
|
|
}
|
2021-07-19 13:21:05 +02:00
|
|
|
}
|
2021-02-12 13:19:31 -05:00
|
|
|
}
|
2021-07-19 13:21:05 +02:00
|
|
|
}
|
2021-02-12 13:19:31 -05:00
|
|
|
|
2022-06-06 18:42:12 +03:00
|
|
|
contentItem: Item {
|
|
|
|
Column {
|
|
|
|
id: contentItem
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
property alias searchBox: searchBox
|
|
|
|
|
|
|
|
Item {
|
|
|
|
height: 8
|
|
|
|
width: parent.width
|
|
|
|
}
|
2021-02-12 13:19:31 -05:00
|
|
|
|
2022-06-06 18:42:12 +03:00
|
|
|
StatusInput {
|
|
|
|
id: searchBox
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2022-07-22 13:28:04 +03:00
|
|
|
placeholderText: qsTr("Search for communities or topics")
|
2022-08-11 14:55:08 +03:00
|
|
|
input.asset.name: "search"
|
2022-06-06 18:42:12 +03:00
|
|
|
}
|
2020-12-11 15:29:46 -05:00
|
|
|
|
2022-06-06 18:42:12 +03:00
|
|
|
StatusModalDivider { topPadding: 8 }
|
2021-06-22 14:30:51 -04:00
|
|
|
|
2022-07-13 15:29:38 +03:00
|
|
|
StatusScrollView {
|
2022-06-06 18:42:12 +03:00
|
|
|
width: parent.width
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
topPadding: 8
|
|
|
|
bottomPadding: 8
|
|
|
|
height: 400
|
2020-12-11 15:29:46 -05:00
|
|
|
|
2022-07-14 14:03:36 +03:00
|
|
|
StatusListView {
|
2022-06-06 18:42:12 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
model: communitiesDelegateModel
|
|
|
|
spacing: 4
|
|
|
|
id: communitiesList
|
|
|
|
|
|
|
|
section.property: "name"
|
|
|
|
section.criteria: ViewSection.FirstCharacter
|
|
|
|
section.delegate: Column {
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 16
|
|
|
|
text: section.toUpperCase()
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.weight: Font.Medium
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
2021-03-23 15:13:36 -04:00
|
|
|
|
2022-06-06 18:42:12 +03:00
|
|
|
StatusModalDivider {
|
|
|
|
bottomPadding: 8
|
|
|
|
}
|
2021-03-23 15:13:36 -04:00
|
|
|
}
|
2022-06-06 18:42:12 +03:00
|
|
|
}
|
2021-03-23 15:13:36 -04:00
|
|
|
|
2022-06-06 18:42:12 +03:00
|
|
|
DelegateModelGeneralized {
|
|
|
|
id: communitiesDelegateModel
|
|
|
|
lessThan: [
|
|
|
|
function(left, right) {
|
|
|
|
return left.name.toLowerCase() < right.name.toLowerCase()
|
2021-07-19 13:21:05 +02:00
|
|
|
}
|
2022-06-06 18:42:12 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
model: popup.communitiesList
|
|
|
|
delegate: StatusListItem {
|
|
|
|
visible: {
|
|
|
|
if (!searchBox.input.text) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
const lowerCaseSearchStr = searchBox.input.text.toLowerCase()
|
|
|
|
return model.name.toLowerCase().includes(lowerCaseSearchStr) || model.description.toLowerCase().includes(lowerCaseSearchStr)
|
|
|
|
}
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
title: model.name
|
|
|
|
subTitle: model.description
|
2022-09-15 17:49:13 +02:00
|
|
|
tertiaryTitle: qsTr("%n member(s)", "", model.members.count)
|
2022-06-06 18:42:12 +03:00
|
|
|
statusListItemTitle.font.weight: Font.Bold
|
|
|
|
statusListItemTitle.font.pixelSize: 17
|
2022-08-11 14:55:08 +03:00
|
|
|
asset.name: model.image
|
|
|
|
asset.isImage: !!model.image
|
|
|
|
asset.isLetterIdenticon: !model.image
|
|
|
|
asset.bgColor: model.color || Theme.palette.primaryColor1
|
2022-06-06 18:42:12 +03:00
|
|
|
|
2022-08-24 17:37:05 +03:00
|
|
|
onClicked: {
|
2022-06-06 18:42:12 +03:00
|
|
|
if (model.joined && model.isMember) {
|
|
|
|
popup.setActiveCommunity(model.id);
|
|
|
|
} else {
|
|
|
|
popup.setObservedCommunity(model.id);
|
2022-05-10 19:04:25 +03:00
|
|
|
popup.openCommunityDetail();
|
2022-06-06 18:42:12 +03:00
|
|
|
}
|
|
|
|
popup.close()
|
2020-12-11 15:29:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-11 15:38:10 -05:00
|
|
|
|
2021-07-19 13:21:05 +02:00
|
|
|
rightButtons: [
|
|
|
|
StatusButton {
|
2022-04-04 13:26:30 +02:00
|
|
|
text: qsTr("Create a community")
|
2021-07-19 13:21:05 +02:00
|
|
|
onClicked: {
|
2022-05-10 19:04:25 +03:00
|
|
|
popup.createCommunityClicked();
|
2021-07-19 13:21:05 +02:00
|
|
|
popup.close()
|
|
|
|
}
|
2020-12-11 15:29:46 -05:00
|
|
|
}
|
2021-07-19 13:21:05 +02:00
|
|
|
]
|
2020-12-11 15:29:46 -05:00
|
|
|
}
|
|
|
|
|