Files
status-app/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/CompactMessage.qml
T

180 lines
5.4 KiB
QML
Raw Normal View History

import QtQuick 2.13
import "../../../../../shared"
import "../../../../../imports"
Item {
property var clickMessage: function () {}
property int chatHorizontalPadding: 12
property int chatVerticalPadding: 7
2020-12-08 10:38:53 +11:00
property string linkUrls: ""
property int contentType: 2
property var container
property bool isCurrentUser: false
2020-12-08 10:38:53 +11:00
id: root
anchors.top: parent.top
anchors.topMargin: authorCurrentMsg != authorPrevMsg ? Style.current.smallPadding : 0
height: childrenRect.height + this.anchors.topMargin
width: parent.width
// FIXME @jonathanr: Adding this breaks the first line. Need to fix the height somehow
// DateGroup {
// id: dateGroupLbl
// }
UserImage {
id: chatImage
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
// anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
anchors.top: parent.top
}
UsernameLabel {
id: chatName
2020-12-08 10:38:53 +11:00
anchors.leftMargin: root.chatHorizontalPadding
// anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
anchors.top: parent.top
anchors.left: chatImage.right
}
ChatReply {
id: chatReply
// anchors.top: chatName.visible ? chatName.bottom : (dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top)
anchors.top: chatName.visible ? chatName.bottom : parent.top
2020-12-08 10:38:53 +11:00
anchors.topMargin: chatName.visible && this.visible ? root.chatVerticalPadding : 0
anchors.left: chatImage.right
2020-12-08 10:38:53 +11:00
anchors.leftMargin: root.chatHorizontalPadding
anchors.right: parent.right
2020-12-08 10:38:53 +11:00
anchors.rightMargin: root.chatHorizontalPadding
container: root.container
chatHorizontalPadding: root.chatHorizontalPadding
}
ChatText {
id: chatText
anchors.top: chatReply.bottom
2020-12-08 10:38:53 +11:00
anchors.topMargin: chatName.visible && this.visible ? root.chatVerticalPadding : 0
anchors.left: chatImage.right
2020-12-08 10:38:53 +11:00
anchors.leftMargin: root.chatHorizontalPadding
anchors.right: parent.right
2020-12-08 10:38:53 +11:00
anchors.rightMargin: root.chatHorizontalPadding
}
2020-07-20 13:34:20 -04:00
Loader {
id: chatImageContent
2020-07-20 13:34:20 -04:00
active: isImage
2020-09-30 14:16:16 -04:00
anchors.left: chatText.left
anchors.leftMargin: 8
anchors.top: chatReply.bottom
2020-11-27 10:38:58 -05:00
z: 51
2020-09-30 14:16:16 -04:00
sourceComponent: Component {
ChatImage {
imageSource: image
imageWidth: 200
2020-12-08 10:38:53 +11:00
onClicked: root.clickMessage(false, false, true, image)
container: root.container
2020-09-30 14:16:16 -04:00
}
2020-07-20 13:34:20 -04:00
}
}
Loader {
id: stickerLoader
active: contentType === Constants.stickerType
anchors.left: chatText.left
anchors.top: chatName.visible ? chatName.bottom : parent.top
2020-12-08 10:38:53 +11:00
anchors.topMargin: this.visible && chatName.visible ? root.chatVerticalPadding : 0
sourceComponent: Component {
Rectangle {
id: stickerContainer
color: Style.current.transparent
border.color: Style.current.grey
border.width: 1
radius: 16
2020-12-08 10:38:53 +11:00
width: stickerId.width + 2 * root.chatVerticalPadding
height: stickerId.height + 2 * root.chatVerticalPadding
Sticker {
id: stickerId
anchors.top: parent.top
2020-12-08 10:38:53 +11:00
anchors.topMargin: root.chatVerticalPadding
anchors.left: parent.left
2020-12-08 10:38:53 +11:00
anchors.leftMargin: root.chatVerticalPadding
contentType: root.contentType
container: root.container
}
}
}
}
MessageMouseArea {
anchors.fill: stickerLoader.active ? stickerLoader : chatText
}
// TODO show date for not the first messsage (on hover maybe)
ChatTime {
id: chatTime
visible: authorCurrentMsg != authorPrevMsg
anchors.verticalCenter: chatName.verticalCenter
anchors.left: chatName.right
anchors.leftMargin: Style.current.padding
}
SentMessage {
id: sentMessage
visible: isCurrentUser && !timeout && !isExpired && isMessage && outgoingStatus !== "sent"
anchors.verticalCenter: chatTime.verticalCenter
anchors.left: chatTime.right
anchors.leftMargin: 8
}
2020-07-14 11:35:21 -04:00
Retry {
id: retry
anchors.right: chatTime.right
anchors.rightMargin: 5
}
2020-10-23 15:46:44 -04:00
Loader {
id: linksLoader
2020-12-08 10:38:53 +11:00
active: !!root.linkUrls
2020-10-23 15:46:44 -04:00
anchors.left: chatText.left
anchors.leftMargin: 8
anchors.top: chatText.bottom
sourceComponent: Component {
2020-12-08 10:38:53 +11:00
LinksMessage {
linkUrls: root.linkUrls
container: root.container
isCurrentUser: root.isCurrentUser
2020-12-08 10:38:53 +11:00
}
2020-10-23 15:46:44 -04:00
}
}
2020-07-30 12:07:41 -04:00
Loader {
id: audioPlayerLoader
active: isAudio
anchors.top: chatName.visible ? chatName.bottom : parent.top
anchors.left: chatImage.right
2020-09-30 14:45:45 -04:00
sourceComponent: Component {
AudioPlayer {
audioSource: audio
}
2020-07-30 12:07:41 -04:00
}
}
Loader {
id: emojiReactionLoader
active: emojiReactions !== ""
anchors.top: chatText.bottom
anchors.left: chatText.left
anchors.topMargin: active ? 2 : 0
2020-09-30 14:45:45 -04:00
sourceComponent: Component {
EmojiReactions {}
}
}
}