2020-12-11 20:29:46 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.3
|
2021-07-19 11:21:05 +00: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
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
|
2021-07-19 11:21:05 +00:00
|
|
|
StatusModal {
|
2020-12-11 20:29:46 +00:00
|
|
|
id: popup
|
|
|
|
|
|
|
|
onOpened: {
|
2021-08-17 10:00:02 +00:00
|
|
|
contentComponent.searchBox.input.text = "";
|
|
|
|
contentComponent.searchBox.input.forceActiveFocus(Qt.MouseFocusReason)
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Communities"
|
|
|
|
header.title: qsTrId("communities")
|
2021-07-19 11:21:05 +00:00
|
|
|
headerActionButton: StatusFlatRoundButton {
|
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
icon.name: "more"
|
|
|
|
|
|
|
|
onClicked: contextMenu.popup(-contextMenu.width+width, height + 4)
|
|
|
|
|
|
|
|
StatusPopupMenu {
|
|
|
|
id: contextMenu
|
|
|
|
StatusMenuItem {
|
|
|
|
icon.name: "download"
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Access existing community"
|
|
|
|
text: qsTrId("access-existing-community")
|
2021-07-19 11:21:05 +00:00
|
|
|
onTriggered: openPopup(importCommunitiesPopupComponent)
|
|
|
|
}
|
2021-02-12 18:19:31 +00:00
|
|
|
}
|
2021-07-19 11:21:05 +00:00
|
|
|
}
|
2021-02-12 18:19:31 +00:00
|
|
|
|
2021-07-19 11:21:05 +00:00
|
|
|
content: Column {
|
|
|
|
width: popup.width
|
2021-07-26 13:34:19 +00:00
|
|
|
property alias searchBox: searchBox
|
2021-02-12 18:19:31 +00:00
|
|
|
|
2021-08-17 10:00:02 +00:00
|
|
|
Item {
|
|
|
|
height: 8
|
|
|
|
width: parent.width
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: searchBox
|
|
|
|
input.placeholderText: qsTr("Search for communities or topics")
|
|
|
|
input.icon.name: "search"
|
|
|
|
input.height: 36
|
|
|
|
input.topPadding: 9
|
|
|
|
input.bottomPadding: 0
|
2021-02-12 18:19:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-17 10:00:02 +00:00
|
|
|
StatusModalDivider { topPadding: 8 }
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-07-19 11:21:05 +00:00
|
|
|
ScrollView {
|
|
|
|
width: parent.width
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
topPadding: 8
|
|
|
|
bottomPadding: 8
|
|
|
|
height: 400
|
2020-12-11 20:29:46 +00:00
|
|
|
clip: true
|
2021-06-22 18:30:51 +00:00
|
|
|
|
2021-07-19 11:21:05 +00:00
|
|
|
ListView {
|
|
|
|
anchors.fill: parent
|
|
|
|
model: communitiesDelegateModel
|
|
|
|
spacing: 4
|
|
|
|
clip: true
|
|
|
|
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-06-22 18:30:51 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-07-23 09:01:09 +00:00
|
|
|
StatusModalDivider {
|
|
|
|
bottomPadding: 8
|
|
|
|
}
|
2021-03-23 19:13:36 +00:00
|
|
|
}
|
2021-07-19 11:21:05 +00:00
|
|
|
}
|
2021-03-23 19:13:36 +00:00
|
|
|
|
2021-07-19 11:21:05 +00:00
|
|
|
DelegateModelGeneralized {
|
|
|
|
id: communitiesDelegateModel
|
|
|
|
lessThan: [
|
|
|
|
function(left, right) {
|
|
|
|
return left.name.toLowerCase() < right.name.toLowerCase()
|
2021-03-23 19:13:36 +00:00
|
|
|
}
|
2021-07-19 11:21:05 +00:00
|
|
|
]
|
2021-03-23 19:13:36 +00:00
|
|
|
|
2021-07-19 11:21:05 +00:00
|
|
|
model: chatsModel.communities.list
|
|
|
|
delegate: StatusListItem {
|
|
|
|
visible: {
|
2021-08-17 10:00:02 +00:00
|
|
|
if (!searchBox.input.text) {
|
2021-07-19 11:21:05 +00:00
|
|
|
return true
|
|
|
|
}
|
2021-08-17 10:00:02 +00:00
|
|
|
const lowerCaseSearchStr = searchBox.input.text.toLowerCase()
|
2021-07-19 11:21:05 +00:00
|
|
|
return name.toLowerCase().includes(lowerCaseSearchStr) || description.toLowerCase().includes(lowerCaseSearchStr)
|
2021-03-23 19:13:36 +00:00
|
|
|
}
|
2021-07-19 11:21:05 +00:00
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
title: name
|
2021-07-23 09:01:09 +00:00
|
|
|
subTitle: description
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "%1 members"
|
|
|
|
tertiaryTitle: qsTrId("-1-members").arg(nbMembers)
|
2021-07-23 09:01:09 +00:00
|
|
|
statusListItemTitle.font.weight: Font.Bold
|
|
|
|
statusListItemTitle.font.pixelSize: 17
|
2021-07-19 11:21:05 +00:00
|
|
|
image.source: thumbnailImage
|
|
|
|
icon.isLetterIdenticon: !!!thumbnailImage
|
|
|
|
icon.background.color: communityColor
|
|
|
|
|
|
|
|
sensor.onClicked: {
|
2021-02-10 20:37:17 +00:00
|
|
|
if (joined && isMember) {
|
2021-02-11 20:37:31 +00:00
|
|
|
chatsModel.communities.setActiveCommunity(id)
|
2020-12-11 20:29:46 +00:00
|
|
|
} else {
|
2021-02-11 20:37:31 +00:00
|
|
|
chatsModel.communities.setObservedCommunity(id)
|
2020-12-11 20:29:46 +00:00
|
|
|
openPopup(communityDetailPopup)
|
|
|
|
}
|
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2021-07-19 11:21:05 +00:00
|
|
|
rightButtons: [
|
|
|
|
StatusButton {
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Create a community"
|
|
|
|
text: qsTrId("create-community")
|
2021-07-19 11:21:05 +00:00
|
|
|
onClicked: {
|
|
|
|
openPopup(createCommunitiesPopupComponent)
|
|
|
|
popup.close()
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2021-07-19 11:21:05 +00:00
|
|
|
]
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|