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

103 lines
3.3 KiB
QML
Raw Normal View History

2020-12-11 20:29:46 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import "../../../../shared"
import "../../../../shared/status"
import "../../../../imports"
import "../components"
Rectangle {
property string communityId: ""
property string name: "channelName"
2020-12-11 20:38:10 +00:00
property string description: "channel description"
property string unviewedMessagesCount: "0"
2020-12-11 20:29:46 +00:00
property string image: "../../../img/ens-header-dark@2x.png"
property bool hasMentions: false
property string searchStr: ""
property bool isCompact: appSettings.compactMode
property bool hovered: false
2020-12-11 20:38:10 +00:00
id: communityButton
2020-12-11 20:29:46 +00:00
color: {
2020-12-11 20:38:10 +00:00
if (communityButton.hovered) {
2020-12-11 20:29:46 +00:00
return Style.current.secondaryBackground
}
return Style.current.transparent
}
anchors.right: parent.right
anchors.top: applicationWindow.top
anchors.left: parent.left
radius: Style.current.radius
// Hide the box if it is filtered out
2020-12-11 20:38:10 +00:00
property bool isVisible: searchStr === "" ||
communityButton.name.toLowerCase().includes(searchStr) ||
communityButton.description.toLowerCase().includes(searchStr)
2020-12-11 20:29:46 +00:00
visible: isVisible ? true : false
height: isVisible ? !isCompact ? 64 : communityImage.height + Style.current.smallPadding * 2 : 0
RoundedImage {
id: communityImage
height: !isCompact ? 40 : 20
width: !isCompact ? 40 : 20
2020-12-11 20:38:10 +00:00
source: communityButton.image
2020-12-11 20:29:46 +00:00
anchors.left: parent.left
anchors.leftMargin: !isCompact ? Style.current.padding : Style.current.smallPadding
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
id: contactInfo
2020-12-11 20:38:10 +00:00
text: communityButton.name
2020-12-11 20:29:46 +00:00
anchors.right: contactNumberChatsCircle.left
anchors.rightMargin: Style.current.smallPadding
elide: Text.ElideRight
font.weight: Font.Medium
font.pixelSize: 15
anchors.left: communityImage.right
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
}
Rectangle {
id: contactNumberChatsCircle
width: 22
height: 22
radius: 50
anchors.right: parent.right
anchors.rightMargin: !isCompact ? Style.current.padding : Style.current.smallPadding
anchors.verticalCenter: parent.verticalCenter
color: Style.current.primary
2020-12-11 20:38:10 +00:00
visible: (unviewedMessagesCount > 0) || communityButton.hasMentions
2020-12-11 20:29:46 +00:00
StyledText {
id: contactNumberChats
2020-12-11 20:38:10 +00:00
text: communityButton.hasMentions ? '@' : (communityButton.unviewedMessagesCount < 100 ? communityButton.unviewedMessagesCount : "99")
2020-12-11 20:29:46 +00:00
font.pixelSize: 12
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
color: Style.current.white
}
}
MouseArea {
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
anchors.fill: parent
hoverEnabled: true
onEntered: {
2020-12-11 20:38:10 +00:00
communityButton.hovered = true
2020-12-11 20:29:46 +00:00
}
onExited: {
2020-12-11 20:38:10 +00:00
communityButton.hovered = false
2020-12-11 20:29:46 +00:00
}
onClicked: {
chatsModel.setActiveCommunity(communityId)
}
}
}
/*##^##
Designer {
D{i:0;formeditorColor:"#ffffff";height:64;width:640}
}
##^##*/