fix: fix chat height being too high in compact mode

This commit is contained in:
Jonathan Rainville 2020-09-30 16:40:54 -04:00 committed by Iuri Matias
parent fe3995bb3d
commit 261460f8fb
5 changed files with 111 additions and 102 deletions

View File

@ -1,26 +1,12 @@
import QtQuick 2.3 import QtQuick 2.3
import "../../../../../imports" import "../../../../../imports"
Rectangle { ImageLoader {
property int chatVerticalPadding: 12 property int chatVerticalPadding: 12
property int chatHorizontalPadding: 12 property int chatHorizontalPadding: 12
property int imageWidth: 250
property string imageSource: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAAAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhZWiAAAAAAAABvogAAOPUAAAOQWFlaIAAAAAAAAGKZAAC3hQAAGNpYWVogAAAAAAAAJKAAAA+EAAC2z3BhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABYWVogAAAAAAAA9tYAAQAAAADTLW1sdWMAAAAAAAAAAQAAAAxlblVTAAAAIAAAABwARwBvAG8AZwBsAGUAIABJAG4AYwAuACAAMgAwADEANv/bAEMADQkKCwoIDQsKCw4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3IztyDmMnPqK/+U0zw4xTEkVZZgk70VG1G5duRt2z5puDPB6voc0VO1FUYVC4R8nP2oormxbTTR6CcVKLRE1dv4kohJVwYOauTFpHkP3CuWsJhDJ3xvipz/ty+j/FdGLtJnBnHrJpml4QhcuxNgCWPye9ahWV4UBduS9Afvn3CtWkz9hR9C2v/t2/95/DWR4jLFm3HdJXIiH59q0vEbsITtwlIMjLHfsH8tYviMrl+VosCkVkrg3xgN/q1IpsjaCF2ennFtwVyoLydz704eM6WRl08hxxs5rPtl3rPjyCWHGA++/4pW7j40ulyZ5/mim2lhfElJtNHu9AWbWmNX/UTtkhjFQMZQ9c+fkUV4qxrNTattm3qLkLUneBNBzztRSHN2ao8Cr2WUUZopB0ziT5hLCfvVumt6i+THoSAKZRTu/bb81DtVumvFjURuIsTaQdx/7+1NhyOOXhl8jx4zTklpdpr9/RNyc7JcsyDPQvVE33B55z+Kcl4zZuWOrSyJ3HbCIj5uTH70hc8TtEJSSbccqMcC/nisiELifEjLpkqgD677ccU9a7ZzGnHGau7JnNZSk5Vd1rtKabWRufJc+WZ+GmFlISOY57p7U9VWCWnelGrugEIp1ZznypSnv0tvpTLn/Vnel7unnbFPmPM7UicZPTTwzilX2U0UUUqjVY6m9FFFIOiFHNFFQorvWi5FOHGM12xCcomRiGDIpnG3b6fu0UVp8fTm+bFJJl8LMISZhmTzJ3WrOOcUUVqOaR6s/0i+vBRheXPobFFFQoU1Nrol1xDpex2aKKKzzirN3HJ9T/2Q=="
id: imageChatBox
height: imageMessage.height + imageChatBox.chatVerticalPadding
width: imageMessage.width + 2 * chatHorizontalPadding
radius: 16
visible: isImage
color: "transparent"
ImageLoader {
id: imageMessage id: imageMessage
verticalPadding: imageChatBox.chatVerticalPadding verticalPadding: chatVerticalPadding
anchors.top: parent.top
anchors.topMargin: imageChatBox.chatVerticalPadding
source: imageSource source: imageSource
imageWidth: imageChatBox.imageWidth
}
} }

View File

@ -2,11 +2,18 @@ import QtQuick 2.3
import "../../../../../shared" import "../../../../../shared"
import "../../../../../imports" import "../../../../../imports"
Rectangle { Loader {
property alias textField: lblReplyMessage property int textFieldWidth: item ? item.textField.width : 0
property bool longReply: false property bool longReply: false
property color elementsColor: isCurrentUser ? Style.current.chatReplyCurrentUser : Style.current.secondaryText property color elementsColor: isCurrentUser ? Style.current.chatReplyCurrentUser : Style.current.secondaryText
id: root
active: responseTo != "" && replyMessageIndex > -1
sourceComponent: Component {
Rectangle {
property alias textField: lblReplyMessage
id: chatReply id: chatReply
visible: responseTo != "" && replyMessageIndex > -1 visible: responseTo != "" && replyMessageIndex > -1
// childrenRect.height shows a binding loop for soem reason, so we use heights instead // childrenRect.height shows a binding loop for soem reason, so we use heights instead
@ -16,7 +23,7 @@ Rectangle {
StyledTextEdit { StyledTextEdit {
id: lblReplyAuthor id: lblReplyAuthor
text: "↳" + repliedMessageAuthor text: "↳" + repliedMessageAuthor
color: chatReply.elementsColor color: root.elementsColor
readOnly: true readOnly: true
selectByMouse: true selectByMouse: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
@ -42,12 +49,12 @@ Rectangle {
anchors.topMargin: 5 anchors.topMargin: 5
text: Emoji.parse(Utils.linkifyAndXSS(repliedMessageContent), "26x26"); text: Emoji.parse(Utils.linkifyAndXSS(repliedMessageContent), "26x26");
textFormat: Text.RichText textFormat: Text.RichText
color: chatReply.elementsColor color: root.elementsColor
readOnly: true readOnly: true
selectByMouse: true selectByMouse: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
anchors.left: parent.left anchors.left: parent.left
anchors.right: chatReply.longReply ? parent.right : undefined anchors.right: root.longReply ? parent.right : undefined
z: 51 z: 51
} }
@ -57,6 +64,9 @@ Rectangle {
anchors.left: lblReplyMessage.left anchors.left: lblReplyMessage.left
anchors.right: lblReplyMessage.right anchors.right: lblReplyMessage.right
anchors.rightMargin: chatTextItem.chatHorizontalPadding anchors.rightMargin: chatTextItem.chatHorizontalPadding
color: chatReply.elementsColor color: root.elementsColor
}
}
} }
} }

View File

@ -159,7 +159,7 @@ Item {
active: emojiReactions !== "" active: emojiReactions !== ""
anchors.top: chatText.bottom anchors.top: chatText.bottom
anchors.left: chatText.left anchors.left: chatText.left
anchors.topMargin: 2 anchors.topMargin: active ? 2 : 0
sourceComponent: Component { sourceComponent: Component {
EmojiReactions {} EmojiReactions {}

View File

@ -61,7 +61,7 @@ Item {
return h; return h;
} }
width: { width: {
switch(contentType){ switch(contentType) {
case Constants.stickerType: case Constants.stickerType:
return stickerId.width + (2 * chatBox.chatHorizontalPadding); return stickerId.width + (2 * chatBox.chatHorizontalPadding);
case Constants.imageType: case Constants.imageType:
@ -71,8 +71,8 @@ Item {
return 400; return 400;
} }
let baseWidth = chatText.width; let baseWidth = chatText.width;
if (chatReply.visible && chatText.width < chatReply.textField.width) { if (chatReply.visible && chatText.width < chatReply.textFieldWidth) {
baseWidth = chatReply.textField.width baseWidth = chatReply.textFieldWidth
} }
return baseWidth + 2 * chatHorizontalPadding return baseWidth + 2 * chatHorizontalPadding
} }
@ -113,17 +113,24 @@ Item {
Loader { Loader {
id: chatImageContent id: chatImageContent
active: isImage active: isImage && !!image
sourceComponent: chatImageComponent anchors.top: parent.top
} anchors.topMargin: Style.current.smallPadding
anchors.left: parent.left
anchors.leftMargin: chatBox.chatHorizontalPadding
Component { sourceComponent: Component {
id: chatImageComponent Item {
width: chatImageComponent.width + 2 * chatBox.chatHorizontalPadding
height: chatImageComponent.height
ChatImage { ChatImage {
id: chatImageComponent
imageSource: image imageSource: image
imageWidth: 250 imageWidth: 250
} }
} }
}
}
Loader { Loader {
id: audioPlayerLoader id: audioPlayerLoader

View File

@ -2,9 +2,13 @@ import QtQuick 2.3
import "../../../../../shared" import "../../../../../shared"
import "../../../../../imports" import "../../../../../imports"
Rectangle { Loader {
active: isMessage && authorCurrentMsg !== authorPrevMsg
height: active ? item.height : 0
sourceComponent: Component {
Rectangle {
id: chatImage id: chatImage
visible: isMessage && authorCurrentMsg != authorPrevMsg
width: identiconImage.width width: identiconImage.width
height: identiconImage.height height: identiconImage.height
border.width: 1 border.width: 1
@ -14,7 +18,7 @@ Rectangle {
Image { Image {
id: identiconImage id: identiconImage
width: 36 width: 36
height: chatImage.visible ? 36 : 0 height: 36
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
source: !isCurrentUser ? identicon : profileModel.profile.identicon source: !isCurrentUser ? identicon : profileModel.profile.identicon
mipmap: true mipmap: true
@ -30,4 +34,6 @@ Rectangle {
} }
} }
} }
}
}
} }