status-desktop/ui/app/AppLayouts/Chat/CommunityComponents/CommunityProfilePopup.qml

160 lines
5.0 KiB
QML
Raw Normal View History

2020-12-15 16:04:19 +00:00
import QtQuick 2.12
import QtQuick.Controls 2.12
2020-12-15 16:04:19 +00:00
import QtQuick.Dialogs 1.3
2020-12-16 18:56:48 +00:00
import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.13
2020-12-15 16:04:19 +00:00
import "../../../../imports"
import "../../../../shared"
import "../../../../shared/status"
import "../ContactsColumn"
ModalPopup {
property QtObject community: chatsModel.communities.activeCommunity
2020-12-15 16:04:19 +00:00
property string communityId: community.id
property string name: community.name
property string description: community.description
property int access: community.access
property string source: ""
property string communityColor: ""
2020-12-15 16:04:19 +00:00
property int nbMembers: community.nbMembers
property bool isAdmin: false
height: stack.currentItem.height + modalHeader.height + modalFooter.height + Style.current.padding * 3
2020-12-15 16:04:19 +00:00
id: popup
onClosed: {
while (stack.depth > 1) {
stack.pop()
}
}
2020-12-15 16:04:19 +00:00
header: Item {
id: modalHeader
2020-12-15 16:04:19 +00:00
height: childrenRect.height
width: parent.width
property string title: stack.currentItem.headerTitle
property string description: stack.currentItem.headerDescription
property string imageSource: stack.currentItem.headerImageSource
property bool useLetterIdenticon: !!stack.currentItem.useLetterIdenticon
Loader {
2020-12-15 16:04:19 +00:00
id: communityImg
sourceComponent: !modalHeader.useLetterIdenticon ? commmunityImgCmp : letterIdenticonCmp
active: !!modalHeader.imageSource || modalHeader.useLetterIdenticon
2020-12-15 16:04:19 +00:00
}
Component {
id: commmunityImgCmp
RoundedImage {
source: modalHeader.imageSource
width: 40
height: 40
visible: !!modalHeader.imageSource
}
}
Component {
id: letterIdenticonCmp
StatusLetterIdenticon {
width: 40
height: 40
chatName: popup.name
color: popup.communityColor || Style.current.blue
}
}
2020-12-15 16:04:19 +00:00
StyledTextEdit {
id: communityName
text: modalHeader.title
2020-12-15 16:04:19 +00:00
anchors.top: parent.top
anchors.topMargin: 2
anchors.left: communityImg.active ? communityImg.right : parent.left
anchors.leftMargin: communityImg.active ? Style.current.smallPadding : 0
2020-12-15 16:04:19 +00:00
font.bold: true
font.pixelSize: 17
readOnly: true
}
StyledText {
id: headerDescription
text: modalHeader.description
2020-12-15 16:04:19 +00:00
anchors.left: communityName.left
anchors.top: communityName.bottom
anchors.topMargin: 2
font.pixelSize: 15
font.weight: Font.Thin
color: Style.current.secondaryText
}
Separator {
anchors.top: headerDescription.bottom
anchors.topMargin: Style.current.padding
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: -Style.current.padding
anchors.leftMargin: -Style.current.padding
}
2020-12-15 16:04:19 +00:00
}
StackView {
id: stack
initialItem: profileOverview
width: parent.width
2020-12-16 18:56:48 +00:00
pushEnter: Transition { enabled: false }
pushExit: Transition { enabled: false }
popEnter: Transition { enabled: false }
popExit: Transition { enabled: false }
2020-12-18 20:15:00 +00:00
Component {
id: membersList
CommunityProfilePopupMembersList {
headerTitle: qsTr("Members")
headerDescription: popup.nbMembers.toString()
2020-12-16 18:56:48 +00:00
}
}
2020-12-18 20:15:00 +00:00
Component {
id: profileOverview
CommunityProfilePopupOverview {
property bool useLetterIdenticon: !!!popup.source
headerTitle: popup.name
headerDescription: {
switch(access) {
//% "Public community"
case Constants.communityChatPublicAccess: return qsTrId("public-community");
//% "Invitation only community"
case Constants.communityChatInvitationOnlyAccess: return qsTrId("invitation-only-community");
//% "On request community"
case Constants.communityChatOnRequestAccess: return qsTrId("on-request-community");
//% "Unknown community"
default: return qsTrId("unknown-community");
2020-12-17 13:24:33 +00:00
}
}
headerImageSource: popup.source
description: popup.description
2020-12-16 18:56:48 +00:00
}
}
}
2020-12-18 20:15:00 +00:00
footer: Item {
id: modalFooter
visible: stack.depth > 1
width: parent.width
height: modalFooter.visible ? btnBack.height : 0
StatusRoundButton {
id: btnBack
anchors.left: parent.left
icon.name: "arrow-right"
icon.width: 20
icon.height: 16
rotation: 180
onClicked: {
stack.pop()
2020-12-16 18:56:48 +00:00
}
}
}
2020-12-15 16:04:19 +00:00
}