2020-07-15 21:04:14 +00:00
|
|
|
import QtQuick 2.3
|
|
|
|
import "../../../../../shared"
|
|
|
|
import "../../../../../imports"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
property var clickMessage: function () {}
|
2020-09-15 17:42:23 +00:00
|
|
|
property bool showImages: appSettings.displayChatImages && imageUrls != ""
|
2020-07-15 21:04:14 +00:00
|
|
|
|
|
|
|
id: chatTextItem
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: authorCurrentMsg != authorPrevMsg ? Style.current.smallPadding : 0
|
2020-07-23 16:11:48 +00:00
|
|
|
height: childrenRect.height + this.anchors.topMargin + (dateGroupLbl.visible ? dateGroupLbl.height : 0)
|
2020-07-15 21:04:14 +00:00
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
DateGroup {
|
|
|
|
id: dateGroupLbl
|
|
|
|
}
|
|
|
|
|
|
|
|
UserImage {
|
|
|
|
id: chatImage
|
2020-07-23 16:17:14 +00:00
|
|
|
visible: chatsModel.activeChannel.chatType !== Constants.chatTypeOneToOne && isMessage && authorCurrentMsg != authorPrevMsg && !isCurrentUser
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
|
|
|
anchors.topMargin: 20
|
|
|
|
}
|
|
|
|
|
|
|
|
UsernameLabel {
|
|
|
|
id: chatName
|
2020-07-23 16:17:14 +00:00
|
|
|
visible: chatsModel.activeChannel.chatType !== Constants.chatTypeOneToOne && isMessage && authorCurrentMsg != authorPrevMsg && !isCurrentUser
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.leftMargin: 20
|
|
|
|
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
|
|
|
anchors.topMargin: 0
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
property int chatVerticalPadding: 7
|
|
|
|
property int chatHorizontalPadding: 12
|
2020-07-20 21:26:29 +00:00
|
|
|
property bool longReply: chatReply.visible && repliedMessageContent.length > 54
|
2020-09-22 19:42:06 +00:00
|
|
|
property bool longChatText: chatsModel.plainText(message).length > 54
|
2020-07-15 21:04:14 +00:00
|
|
|
|
|
|
|
id: chatBox
|
|
|
|
color: isSticker ? Style.current.background : (isCurrentUser ? Style.current.blue : Style.current.secondaryBackground)
|
|
|
|
border.color: isSticker ? Style.current.border : Style.current.transparent
|
|
|
|
border.width: 1
|
2020-07-17 19:44:25 +00:00
|
|
|
height: {
|
|
|
|
let h = (3 * chatVerticalPadding)
|
|
|
|
switch(contentType){
|
|
|
|
case Constants.stickerType:
|
|
|
|
h += stickerId.height;
|
|
|
|
break;
|
2020-07-30 16:07:41 +00:00
|
|
|
case Constants.audioType:
|
|
|
|
h += audioPlayerLoader.height;
|
|
|
|
break;
|
2020-07-17 19:44:25 +00:00
|
|
|
default:
|
|
|
|
h += chatText.visible ? chatText.height : 0;
|
|
|
|
h += chatImageContent.visible ? chatImageContent.height: 0;
|
|
|
|
h += chatReply.visible ? chatReply.height : 0;
|
|
|
|
}
|
|
|
|
return h;
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
width: {
|
|
|
|
switch(contentType){
|
|
|
|
case Constants.stickerType:
|
|
|
|
return stickerId.width + (2 * chatBox.chatHorizontalPadding);
|
2020-07-17 19:44:25 +00:00
|
|
|
case Constants.imageType:
|
|
|
|
return chatImageContent.width
|
2020-07-15 21:04:14 +00:00
|
|
|
default:
|
2020-07-20 21:26:29 +00:00
|
|
|
if (longChatText || longReply) {
|
|
|
|
return 400;
|
|
|
|
}
|
|
|
|
let baseWidth = chatText.width;
|
|
|
|
if (chatReply.visible && chatText.width < chatReply.textField.width) {
|
|
|
|
baseWidth = chatReply.textField.width
|
|
|
|
}
|
|
|
|
return baseWidth + 2 * chatHorizontalPadding
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
radius: 16
|
|
|
|
anchors.left: !isCurrentUser ? chatImage.right : undefined
|
|
|
|
anchors.leftMargin: !isCurrentUser ? 8 : 0
|
|
|
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
|
|
|
anchors.rightMargin: !isCurrentUser ? 0 : Style.current.padding
|
|
|
|
anchors.top: authorCurrentMsg != authorPrevMsg && !isCurrentUser ? chatImage.top : (dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top)
|
2020-08-14 12:08:09 +00:00
|
|
|
anchors.topMargin: 0
|
2020-07-20 17:34:20 +00:00
|
|
|
visible: isMessage
|
2020-07-15 21:04:14 +00:00
|
|
|
|
|
|
|
ChatReply {
|
|
|
|
id: chatReply
|
2020-07-20 21:26:29 +00:00
|
|
|
longReply: chatBox.longReply
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: chatReply.visible ? chatBox.chatVerticalPadding : 0
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: chatBox.chatHorizontalPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatText {
|
|
|
|
id: chatText
|
2020-09-25 19:44:40 +00:00
|
|
|
longChatText: chatBox.longChatText
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.top: chatReply.bottom
|
|
|
|
anchors.topMargin: chatBox.chatVerticalPadding
|
|
|
|
anchors.left: parent.left
|
2020-07-20 21:26:29 +00:00
|
|
|
anchors.leftMargin: chatBox.chatHorizontalPadding
|
|
|
|
anchors.right: chatBox.longChatText ? parent.right : undefined
|
|
|
|
anchors.rightMargin: chatBox.longChatText ? chatBox.chatHorizontalPadding : 0
|
2020-09-25 19:44:40 +00:00
|
|
|
textField.horizontalAlignment: !isCurrentUser ? Text.AlignLeft : Text.AlignRight
|
|
|
|
textField.color: !isCurrentUser ? Style.current.textColor : Style.current.currentUserTextColor
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 17:34:20 +00:00
|
|
|
Loader {
|
2020-07-17 19:44:25 +00:00
|
|
|
id: chatImageContent
|
2020-07-20 17:34:20 +00:00
|
|
|
active: isImage
|
|
|
|
sourceComponent: chatImageComponent
|
2020-07-17 19:44:25 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 17:34:20 +00:00
|
|
|
Component {
|
|
|
|
id: chatImageComponent
|
|
|
|
ChatImage {
|
|
|
|
imageSource: image
|
|
|
|
imageWidth: 250
|
|
|
|
}
|
|
|
|
}
|
2020-07-30 16:07:41 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: audioPlayerLoader
|
|
|
|
active: isAudio
|
|
|
|
sourceComponent: audioPlayer
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: audioPlayer
|
|
|
|
AudioPlayer {
|
|
|
|
audioSource: audio
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-15 21:04:14 +00:00
|
|
|
Sticker {
|
|
|
|
id: stickerId
|
|
|
|
anchors.left: parent.left
|
2020-07-20 21:26:29 +00:00
|
|
|
anchors.leftMargin: chatBox.chatHorizontalPadding
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: chatBox.chatVerticalPadding
|
2020-09-23 08:18:23 +00:00
|
|
|
color: Style.current.transparent
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageMouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
2020-07-16 14:51:12 +00:00
|
|
|
|
|
|
|
RectangleCorner {
|
|
|
|
// TODO find a way to show the corner for stickers since they have a border
|
2020-07-20 17:34:20 +00:00
|
|
|
visible: isMessage
|
2020-07-16 14:51:12 +00:00
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ChatTime {
|
|
|
|
id: chatTime
|
|
|
|
anchors.top: showImages ? imageLoader.bottom : chatBox.bottom
|
|
|
|
anchors.topMargin: 4
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
anchors.right: showImages ? imageLoader.right : chatBox.right
|
|
|
|
anchors.rightMargin: isCurrentUser ? 5 : Style.current.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
SentMessage {
|
|
|
|
id: sentMessage
|
|
|
|
anchors.top: chatTime.top
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
anchors.right: chatTime.left
|
|
|
|
anchors.rightMargin: 5
|
|
|
|
}
|
2020-07-14 15:35:21 +00:00
|
|
|
|
|
|
|
Retry {
|
|
|
|
id: retry
|
|
|
|
anchors.top: chatTime.top
|
|
|
|
anchors.right: chatTime.left
|
|
|
|
anchors.rightMargin: 5
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
}
|
|
|
|
|
2020-07-15 21:04:14 +00:00
|
|
|
Loader {
|
|
|
|
id: imageLoader
|
|
|
|
active: showImages
|
|
|
|
sourceComponent: imageComponent
|
|
|
|
anchors.left: !isCurrentUser ? chatImage.right : undefined
|
|
|
|
anchors.leftMargin: !isCurrentUser ? 8 : 0
|
|
|
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
|
|
|
anchors.rightMargin: !isCurrentUser ? 0 : Style.current.padding
|
2020-07-16 14:51:12 +00:00
|
|
|
anchors.top: chatBox.bottom
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: imageComponent
|
|
|
|
ImageMessage {}
|
|
|
|
}
|
2020-08-12 15:01:03 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: emojiReactionLoader
|
|
|
|
active: emojiReactions !== ""
|
|
|
|
sourceComponent: emojiReactionsComponent
|
|
|
|
anchors.left: !isCurrentUser ? chatBox.left : undefined
|
|
|
|
anchors.right: !isCurrentUser ? undefined : chatBox.right
|
|
|
|
anchors.top: chatBox.bottom
|
|
|
|
anchors.topMargin: 2
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: emojiReactionsComponent
|
|
|
|
EmojiReactions {}
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|