fix: chat reply width when content is smaller than author

This commit is contained in:
Richard Ramos 2020-12-10 16:59:00 -04:00 committed by Iuri Matias
parent 5ad54b057b
commit a901351e7e
2 changed files with 17 additions and 1 deletions

View File

@ -1,9 +1,11 @@
import QtQuick 2.3
import QtQuick 2.14
import "../../../../../shared"
import "../../../../../imports"
Loader {
property int textFieldWidth: item ? item.textField.width : 0
property int authorWidth: item ? item.authorMetrics.width : 0
property bool longReply: false
property color elementsColor: isCurrentUser ? Style.current.chatReplyCurrentUser : Style.current.secondaryText
@ -13,6 +15,7 @@ Loader {
sourceComponent: Component {
Rectangle {
property alias textField: lblReplyMessage
property alias authorMetrics: txtAuthorMetrics
id: chatReply
visible: responseTo != "" && replyMessageIndex > -1
@ -20,6 +23,12 @@ Loader {
height: this.visible ? lblReplyAuthor.height + ((repliedMessageType === Constants.imageType ? imgReplyImage.height : lblReplyMessage.height) + 5 + 8) : 0
color: Style.current.transparent
TextMetrics {
id: txtAuthorMetrics
font: lblReplyAuthor.font
text: lblReplyAuthor.text
}
StyledTextEdit {
id: lblReplyAuthor
text: "↳" + repliedMessageAuthor

View File

@ -96,6 +96,13 @@ Item {
if (chatReply.visible && chatText.width < chatReply.textFieldWidth) {
baseWidth = chatReply.textFieldWidth
}
if (chatReply.visible && chatText.width < chatReply.authorWidth) {
if(chatReply.authorWidth > baseWidth){
baseWidth = chatReply.authorWidth + 20
}
}
return baseWidth + 2 * chatHorizontalPadding
}
}