fix: code review

This commit is contained in:
Richard Ramos 2020-07-20 13:34:20 -04:00 committed by Iuri Matias
parent 5351fb62dc
commit a31610742c
9 changed files with 34 additions and 17 deletions

View File

@ -5,7 +5,7 @@ import ../status/libstatus/settings as status_settings
import ../status/libstatus/types as status_types import ../status/libstatus/types as status_types
import ../status/chat/[chat, message] import ../status/chat/[chat, message]
import ../status/profile/[profile, devices] import ../status/profile/[profile, devices]
import types import types
proc toMessage*(jsonMsg: JsonNode): Message proc toMessage*(jsonMsg: JsonNode): Message

View File

@ -26,9 +26,10 @@ Item {
property bool isEmoji: contentType === Constants.emojiType property bool isEmoji: contentType === Constants.emojiType
property bool isImage: contentType === Constants.imageType property bool isImage: contentType === Constants.imageType
property bool isMessage: contentType === Constants.messageType || contentType === Constants.stickerType
property bool isStatusMessage: contentType === Constants.systemMessagePrivateGroupType property bool isStatusMessage: contentType === Constants.systemMessagePrivateGroupType
property bool isSticker: contentType === Constants.stickerType property bool isSticker: contentType === Constants.stickerType
property bool isText: contentType === Constants.messageType
property bool isMessage: isEmoji || isImage || isSticker || isText
property bool isExpired: (outgoingStatus == "sending" && (Math.floor(timestamp) + 180000) < Date.now()) property bool isExpired: (outgoingStatus == "sending" && (Math.floor(timestamp) + 180000) < Date.now())

View File

@ -10,7 +10,7 @@ Rectangle {
color: Style.current.lightBlue color: Style.current.lightBlue
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
height: this.visible ? lblReplyAuthor.height + ((repliedMessageType == Constants.imageType ? imgReplyImage.height : lblReplyMessage.height) + 5 + 8) : 0 height: this.visible ? lblReplyAuthor.height + ((repliedMessageType === Constants.imageType ? imgReplyImage.height : lblReplyMessage.height) + 5 + 8) : 0
StyledTextEdit { StyledTextEdit {
id: lblReplyAuthor id: lblReplyAuthor

View File

@ -4,7 +4,7 @@ import "../../../../../imports"
StyledTextEdit { StyledTextEdit {
id: chatTime id: chatTime
visible: (isEmoji || isMessage || isSticker || isImage) visible: isMessage
color: Style.current.darkGrey color: Style.current.darkGrey
text: { text: {
let messageDate = new Date(Math.floor(timestamp)) let messageDate = new Date(Math.floor(timestamp))

View File

@ -57,13 +57,21 @@ Item {
anchors.rightMargin: chatTextItem.chatHorizontalPadding anchors.rightMargin: chatTextItem.chatHorizontalPadding
} }
ChatImage { Loader {
id: chatImageContent id: chatImageContent
imageWidth: 200 active: isImage
imageSource: image sourceComponent: chatImageComponent
anchors.left: chatImage.right anchors.left: chatImage.right
} }
Component {
id: chatImageComponent
ChatImage {
imageSource: image
imageWidth: 200
}
}
Rectangle { Rectangle {
id: stickerContainer id: stickerContainer
visible: contentType === Constants.stickerType visible: contentType === Constants.stickerType

View File

@ -18,7 +18,7 @@ Item {
UserImage { UserImage {
id: chatImage id: chatImage
visible: (isMessage || isEmoji || isImage) && authorCurrentMsg != authorPrevMsg && !isCurrentUser visible: isMessage && authorCurrentMsg != authorPrevMsg && !isCurrentUser
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: Style.current.padding anchors.leftMargin: Style.current.padding
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
@ -27,7 +27,7 @@ Item {
UsernameLabel { UsernameLabel {
id: chatName id: chatName
visible: (isMessage || isEmoji || isImage) && authorCurrentMsg != authorPrevMsg && !isCurrentUser visible: isMessage && authorCurrentMsg != authorPrevMsg && !isCurrentUser
text: userName text: userName
anchors.leftMargin: 20 anchors.leftMargin: 20
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
@ -83,7 +83,7 @@ Item {
anchors.rightMargin: !isCurrentUser ? 0 : Style.current.padding anchors.rightMargin: !isCurrentUser ? 0 : Style.current.padding
anchors.top: authorCurrentMsg != authorPrevMsg && !isCurrentUser ? chatImage.top : (dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top) anchors.top: authorCurrentMsg != authorPrevMsg && !isCurrentUser ? chatImage.top : (dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top)
anchors.topMargin: 0 anchors.topMargin: 0
visible: isMessage || isEmoji || isImage visible: isMessage
ChatReply { ChatReply {
id: chatReply id: chatReply
@ -110,12 +110,20 @@ Item {
color: !isCurrentUser ? Style.current.textColor : Style.current.currentUserTextColor color: !isCurrentUser ? Style.current.textColor : Style.current.currentUserTextColor
} }
ChatImage { Loader {
id: chatImageContent id: chatImageContent
imageWidth: 250 active: isImage
imageSource: image sourceComponent: chatImageComponent
} }
Component {
id: chatImageComponent
ChatImage {
imageSource: image
imageWidth: 250
}
}
Sticker { Sticker {
id: stickerId id: stickerId
anchors.left: parent.left anchors.left: parent.left
@ -130,7 +138,7 @@ Item {
RectangleCorner { RectangleCorner {
// TODO find a way to show the corner for stickers since they have a border // TODO find a way to show the corner for stickers since they have a border
visible: isMessage || isEmoji visible: isMessage
} }
} }

View File

@ -4,7 +4,7 @@ import "../../../../../imports"
StyledText { StyledText {
id: sentMessage id: sentMessage
visible: isCurrentUser && !timeout && (isEmoji || isMessage || isSticker || isImage) visible: isCurrentUser && !timeout && isMessage
color: Style.current.darkGrey color: Style.current.darkGrey
text: outgoingStatus == "sent" ? text: outgoingStatus == "sent" ?
//% "Sent" //% "Sent"

View File

@ -4,7 +4,7 @@ import "../../../../../imports"
Rectangle { Rectangle {
id: chatImage id: chatImage
visible: (isMessage || isEmoji) && authorCurrentMsg != authorPrevMsg visible: isMessage && authorCurrentMsg != authorPrevMsg
width: identiconImage.width width: identiconImage.width
height: identiconImage.height height: identiconImage.height
border.width: 1 border.width: 1

View File

@ -4,7 +4,7 @@ import "../../../../../imports"
StyledTextEdit { StyledTextEdit {
id: chatName id: chatName
visible: (isMessage || isEmoji) && authorCurrentMsg != authorPrevMsg visible: isMessage && authorCurrentMsg != authorPrevMsg
height: this.visible ? 18 : 0 height: this.visible ? 18 : 0
//% "You" //% "You"
text: !isCurrentUser ? userName : qsTrId("You") text: !isCurrentUser ? userName : qsTrId("You")