status-desktop/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml

131 lines
3.9 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
2020-05-28 11:10:12 +00:00
import "../../../../shared"
import "../../../../imports"
import "../components"
2020-05-28 11:10:12 +00:00
Rectangle {
property string name: "channelName"
property string lastMessage: "My latest message\n with a return"
property string timestamp: "20/2/2020"
property string unviewedMessagesCount: "2"
property int chatType: Constants.chatTypePublic
property string searchStr: ""
2020-05-28 11:10:12 +00:00
id: wrapper
color: ListView.isCurrentItem ? Theme.lightBlue : Theme.transparent
anchors.right: parent.right
anchors.rightMargin: Theme.padding
anchors.top: applicationWindow.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: Theme.padding
radius: 8
// Hide the box if it is filtered out
property bool isVisible: searchStr == "" || name.includes(searchStr)
visible: isVisible ? true : false
height: isVisible ? 64 : 0
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: {
chatsModel.setActiveChannelByIndex(index)
chatGroupsListView.currentIndex = index
}
}
ChannelIcon {
id: contactImage
height: 40
width: 40
topMargin: 12
bottomMargin: 12
channelName: wrapper.name
channelType: wrapper.chatType
channelIdenticon: identicon
2020-05-28 11:10:12 +00:00
}
Image {
id: channelIcon
width: 16
height: 16
fillMode: Image.PreserveAspectFit
source: "../../../img/channel-icon-" + (wrapper.chatType === Constants.chatTypePublic ? "public-chat.svg" : "group.svg")
anchors.left: contactImage.right
anchors.leftMargin: Theme.padding
anchors.top: parent.top
anchors.topMargin: Theme.smallPadding
visible: wrapper.chatType !== Constants.chatTypeOneToOne
}
StyledText {
2020-05-28 11:10:12 +00:00
id: contactInfo
text: wrapper.chatType !== Constants.chatTypePublic ? wrapper.name : "#" + wrapper.name
2020-05-28 11:10:12 +00:00
anchors.right: contactTime.left
anchors.rightMargin: Theme.smallPadding
elide: Text.ElideRight
font.weight: Font.Medium
font.pixelSize: 15
anchors.left: channelIcon.visible ? channelIcon.right : contactImage.right
anchors.leftMargin: channelIcon.visible ? 2 : Theme.padding
2020-05-28 11:10:12 +00:00
anchors.top: parent.top
anchors.topMargin: Theme.smallPadding
color: "black"
}
StyledText {
2020-05-28 11:10:12 +00:00
id: lastChatMessage
text: lastMessage ? lastMessage.replace(/\n|\r/g, ' ') : qsTr("No messages")
2020-05-28 11:10:12 +00:00
anchors.right: contactNumberChatsCircle.left
anchors.rightMargin: Theme.smallPadding
elide: Text.ElideRight
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.smallPadding
font.pixelSize: 15
anchors.left: contactImage.right
anchors.leftMargin: Theme.padding
color: Theme.darkGrey
}
StyledText {
2020-05-28 11:10:12 +00:00
id: contactTime
text: wrapper.timestamp
2020-05-28 11:10:12 +00:00
anchors.right: parent.right
anchors.rightMargin: Theme.padding
anchors.top: parent.top
anchors.topMargin: Theme.smallPadding
font.pixelSize: 11
color: Theme.darkGrey
}
Rectangle {
id: contactNumberChatsCircle
width: 22
height: 22
radius: 50
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.smallPadding
anchors.right: parent.right
anchors.rightMargin: Theme.padding
color: Theme.blue
visible: unviewedMessagesCount > 0
StyledText {
2020-05-28 11:10:12 +00:00
id: contactNumberChats
text: wrapper.unviewedMessagesCount < 100 ? wrapper.unviewedMessagesCount : "99"
font.pixelSize: 12
2020-05-28 11:10:12 +00:00
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
color: "white"
}
}
}
2020-06-17 19:18:31 +00:00
2020-06-17 19:18:31 +00:00
/*##^##
Designer {
D{i:0;formeditorColor:"#ffffff";height:64;width:640}
2020-06-17 19:18:31 +00:00
}
##^##*/