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"
|
2020-06-02 09:54:46 +00:00
|
|
|
import "../components"
|
2020-05-28 11:10:12 +00:00
|
|
|
|
|
|
|
Rectangle {
|
2020-06-18 18:06:02 +00:00
|
|
|
property string name: "channelName"
|
|
|
|
property string lastMessage: "My latest message\n with a return"
|
|
|
|
property string timestamp: "20/2/2020"
|
2020-06-19 19:03:43 +00:00
|
|
|
property string unviewedMessagesCount: "2"
|
2020-07-09 11:46:25 +00:00
|
|
|
property bool hasMentions: false
|
2020-06-19 19:03:43 +00:00
|
|
|
property int chatType: Constants.chatTypePublic
|
2020-06-18 18:06:02 +00:00
|
|
|
property string searchStr: ""
|
|
|
|
|
2020-05-28 11:10:12 +00:00
|
|
|
id: wrapper
|
2020-07-02 15:14:31 +00:00
|
|
|
color: ListView.isCurrentItem ? Style.current.lightBlue : Style.current.transparent
|
2020-05-28 11:10:12 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: applicationWindow.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-02 09:54:46 +00:00
|
|
|
ChannelIcon {
|
2020-05-28 12:04:16 +00:00
|
|
|
id: contactImage
|
|
|
|
height: 40
|
2020-06-02 09:54:46 +00:00
|
|
|
width: 40
|
|
|
|
topMargin: 12
|
|
|
|
bottomMargin: 12
|
2020-06-18 18:06:02 +00:00
|
|
|
channelName: wrapper.name
|
|
|
|
channelType: wrapper.chatType
|
2020-06-02 12:00:38 +00:00
|
|
|
channelIdenticon: identicon
|
2020-05-28 11:10:12 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 13:23:17 +00:00
|
|
|
SVGImage {
|
2020-06-12 01:00:28 +00:00
|
|
|
id: channelIcon
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2020-06-18 18:06:02 +00:00
|
|
|
source: "../../../img/channel-icon-" + (wrapper.chatType === Constants.chatTypePublic ? "public-chat.svg" : "group.svg")
|
2020-06-12 01:00:28 +00:00
|
|
|
anchors.left: contactImage.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-06-12 01:00:28 +00:00
|
|
|
anchors.top: parent.top
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2020-06-19 19:03:43 +00:00
|
|
|
visible: wrapper.chatType !== Constants.chatTypeOneToOne
|
2020-06-12 01:00:28 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-05-28 11:10:12 +00:00
|
|
|
id: contactInfo
|
2020-06-26 01:23:38 +00:00
|
|
|
text: wrapper.chatType !== Constants.chatTypePublic ? Emoji.parse(wrapper.name, "26x26") : "#" + wrapper.name
|
2020-05-28 11:10:12 +00:00
|
|
|
anchors.right: contactTime.left
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
2020-05-28 11:10:12 +00:00
|
|
|
elide: Text.ElideRight
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 15
|
2020-06-12 01:00:28 +00:00
|
|
|
anchors.left: channelIcon.visible ? channelIcon.right : contactImage.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: channelIcon.visible ? 2 : Style.current.padding
|
2020-05-28 11:10:12 +00:00
|
|
|
anchors.top: parent.top
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2020-05-28 11:10:12 +00:00
|
|
|
color: "black"
|
|
|
|
}
|
2020-06-09 15:48:17 +00:00
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-05-28 11:10:12 +00:00
|
|
|
id: lastChatMessage
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "No messages"
|
|
|
|
text: lastMessage ? Emoji.parse(lastMessage, "26x26").replace(/\n|\r/g, ' ') : qsTrId("no-messages")
|
2020-07-06 15:03:41 +00:00
|
|
|
clip: true // This is needed because emojis don't ellide correctly
|
2020-05-28 11:10:12 +00:00
|
|
|
anchors.right: contactNumberChatsCircle.left
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
2020-05-28 11:10:12 +00:00
|
|
|
elide: Text.ElideRight
|
|
|
|
anchors.bottom: parent.bottom
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.bottomMargin: Style.current.smallPadding
|
2020-05-28 11:10:12 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.left: contactImage.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
color: Style.current.darkGrey
|
2020-05-28 11:10:12 +00:00
|
|
|
}
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-05-28 11:10:12 +00:00
|
|
|
id: contactTime
|
2020-06-24 13:04:29 +00:00
|
|
|
text: {
|
|
|
|
let now = new Date()
|
|
|
|
let yesterday = new Date()
|
|
|
|
yesterday.setDate(now.getDate()-1)
|
|
|
|
let messageDate = new Date(Math.floor(wrapper.timestamp))
|
|
|
|
let lastWeek = new Date()
|
|
|
|
lastWeek.setDate(now.getDate()-7)
|
|
|
|
|
2020-07-01 13:47:15 +00:00
|
|
|
let minutes = messageDate.getMinutes();
|
|
|
|
let hours = messageDate.getHours();
|
|
|
|
|
2020-06-24 13:04:29 +00:00
|
|
|
if (now.toDateString() == messageDate.toDateString()) {
|
2020-07-01 13:47:15 +00:00
|
|
|
return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes)
|
2020-06-24 13:04:29 +00:00
|
|
|
} else if (yesterday.toDateString() == messageDate.toDateString()) {
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Yesterday"
|
|
|
|
return qsTrId("yesterday")
|
2020-06-24 13:04:29 +00:00
|
|
|
} else if (lastWeek.getTime() < messageDate.getTime()) {
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Sunday"
|
|
|
|
//% "Monday"
|
|
|
|
//% "Tuesday"
|
|
|
|
//% "Wednesday"
|
|
|
|
//% "Thursday"
|
|
|
|
//% "Friday"
|
|
|
|
//% "Saturday"
|
|
|
|
let days = [qsTrId("sunday"), qsTrId("monday"), qsTrId("tuesday"), qsTrId("wednesday"), qsTrId("thursday"), qsTrId("friday"), qsTrId("saturday")];
|
2020-06-24 13:04:29 +00:00
|
|
|
return days[messageDate.getDay()];
|
|
|
|
} else {
|
|
|
|
return messageDate.getMonth()+1+"/"+messageDate.getDay()+"/"+messageDate.getFullYear()
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 11:10:12 +00:00
|
|
|
anchors.right: parent.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
2020-05-28 11:10:12 +00:00
|
|
|
anchors.top: parent.top
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2020-05-28 11:10:12 +00:00
|
|
|
font.pixelSize: 11
|
2020-07-02 15:14:31 +00:00
|
|
|
color: Style.current.darkGrey
|
2020-05-28 11:10:12 +00:00
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
id: contactNumberChatsCircle
|
|
|
|
width: 22
|
|
|
|
height: 22
|
|
|
|
radius: 50
|
|
|
|
anchors.bottom: parent.bottom
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.bottomMargin: Style.current.smallPadding
|
2020-05-28 11:10:12 +00:00
|
|
|
anchors.right: parent.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
color: Style.current.blue
|
2020-07-09 11:46:25 +00:00
|
|
|
visible: (unviewedMessagesCount > 0) || wrapper.hasMentions
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-05-28 11:10:12 +00:00
|
|
|
id: contactNumberChats
|
2020-07-09 11:46:25 +00:00
|
|
|
text: wrapper.hasMentions ? '@' : (wrapper.unviewedMessagesCount < 100 ? wrapper.unviewedMessagesCount : "99")
|
2020-06-19 18:21:02 +00:00
|
|
|
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-18 18:06:02 +00:00
|
|
|
|
|
|
|
|
2020-06-17 19:18:31 +00:00
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-06-18 18:06:02 +00:00
|
|
|
D{i:0;formeditorColor:"#ffffff";height:64;width:640}
|
2020-06-17 19:18:31 +00:00
|
|
|
}
|
|
|
|
##^##*/
|