uiux: Refactor chat images so they look like they've been designed

Fixes: #1114
This commit is contained in:
Pascal Precht 2020-11-12 15:08:40 +01:00 committed by Jonathan Rainville
parent 4ac8400038
commit be2aadb4e2
2 changed files with 47 additions and 3 deletions

View File

@ -1,10 +1,12 @@
import QtQuick 2.3 import QtQuick 2.3
import QtGraphicalEffects 1.13
import "../../../../../shared" import "../../../../../shared"
import "../../../../../imports" import "../../../../../imports"
Item { Item {
property int verticalPadding: 0 property int verticalPadding: 0
property int imageWidth: 350 property int imageWidth: 350
property bool isCurrentUser: false
property url source property url source
signal clicked(string source) signal clicked(string source)
@ -49,6 +51,39 @@ Item {
} }
} }
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: imageMessage.width
height: imageMessage.height
Rectangle {
anchors.top: parent.top
anchors.left: parent.left
width: imageMessage.width
height: imageMessage.height
radius: 16
}
Rectangle {
anchors.bottom: parent.bottom
anchors.left: parent.left
width: 32
height: 32
radius: 4
visible: !imageContainer.isCurrentUser
}
Rectangle {
anchors.bottom: parent.bottom
anchors.right: parent.right
width: 32
height: 32
radius: 4
visible: imageContainer.isCurrentUser
}
}
}
MouseArea { MouseArea {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
anchors.fill: parent anchors.fill: parent

View File

@ -35,13 +35,21 @@ Item {
} }
Rectangle { Rectangle {
property int chatVerticalPadding: 7 property int chatVerticalPadding: isImage ? 4 : 7
property int chatHorizontalPadding: 12 property int chatHorizontalPadding: isImage ? 0 : 12
property bool longReply: chatReply.visible && repliedMessageContent.length > 54 property bool longReply: chatReply.visible && repliedMessageContent.length > 54
property bool longChatText: chatsModel.plainText(message).length > 54 property bool longChatText: chatsModel.plainText(message).length > 54
id: chatBox id: chatBox
color: isSticker ? Style.current.background : (isCurrentUser ? Style.current.blue : Style.current.secondaryBackground) color: {
if (isSticker) {
return Style.current.background
}
if (isImage) {
return "transparent"
}
return isCurrentUser ? Style.current.primary : Style.current.secondaryBackground
}
border.color: isSticker ? Style.current.border : Style.current.transparent border.color: isSticker ? Style.current.border : Style.current.transparent
border.width: 1 border.width: 1
height: { height: {
@ -131,6 +139,7 @@ Item {
id: chatImageComponent id: chatImageComponent
imageSource: image imageSource: image
imageWidth: 250 imageWidth: 250
isCurrentUser: messageItem.isCurrentUser
} }
} }
} }