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

59 lines
1.7 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"
StatusIconTabButton {
2020-12-11 20:29:46 +00:00
property string communityId: ""
property string name: "channelName"
property int unviewedMessagesCount: 0
property string image
2020-12-11 20:29:46 +00:00
property bool hasMentions: false
2020-12-11 20:38:10 +00:00
id: communityButton
anchors.horizontalCenter: parent.horizontalCenter
iconSource: communityButton.image
anchors.topMargin: 0
2020-12-11 20:29:46 +00:00
section: Constants.community
checked: chatsModel.communities.activeCommunity.active && chatsModel.communities.activeCommunity.id === communityId
2020-12-11 20:29:46 +00:00
borderOnChecked: true
doNotHandleClick: true
onClicked: {
appMain.changeAppSection(Constants.chat)
chatsModel.communities.setActiveCommunity(communityId)
2020-12-11 20:29:46 +00:00
}
StatusToolTip {
visible: communityButton.hovered
text: communityButton.name
delay: 50
}
2020-12-11 20:29:46 +00:00
Rectangle {
id: chatBadge
visible: unviewedMessagesCount > 0
anchors.top: parent.top
anchors.left: parent.right
anchors.leftMargin: -17
anchors.topMargin: 1
radius: height / 2
color: Style.current.blue
border.color: Style.current.background
border.width: 2
width: unviewedMessagesCount < 10 ? 22 : messageCount.width + 14
2020-12-11 20:29:46 +00:00
height: 22
Text {
id: messageCount
font.pixelSize: chatsModel.unreadMessagesCount > 99 ? 10 : 12
2020-12-11 20:29:46 +00:00
color: Style.current.white
anchors.centerIn: parent
text: unviewedMessagesCount > 99 ? "99+" : unviewedMessagesCount
2020-12-11 20:29:46 +00:00
}
}
}