Skip to content
Snippets Groups Projects
Commit 8c728374 authored by Sébastien Blin's avatar Sébastien Blin Committed by Liam Coursodon
Browse files

emojiReactions: change the emojis layout


Gitlab: #1230
Co-authored-by: default avatarCharles <charles-francis.damedey@savoirfairelinux.com>
Co-authored-by: default avatarSébastien Blin <sebastien.blin@savoirfairelinux.com>
Change-Id: I5bff3a811caa9bec8ee9b80733165aaaaae5db24
parent 3a693536
No related branches found
No related tags found
No related merge requests found
...@@ -24,9 +24,13 @@ import net.jami.Constants 1.1 ...@@ -24,9 +24,13 @@ import net.jami.Constants 1.1
Item { Item {
id: root id: root
width: reactionBubble.width
property var reactions property var reactions
property real contentHeight: bubble.height property real contentHeight: reactionBubble.height
property real contentWidth: bubble.width property real contentWidth: reactionBubble.width
property color borderColor: undefined
property int maxWidth: JamiTheme.defaulMaxWidthReaction
visible: emojis.length && Body !== "" visible: emojis.length && Body !== ""
...@@ -80,36 +84,30 @@ Item { ...@@ -80,36 +84,30 @@ Item {
return []; return [];
} }
// TODO:
// -order emojis based on the timestamp of the reaction and/or the quantity of emojis
Rectangle { Rectangle {
id: bubble id: reactionBubble
color: JamiTheme.emojiReactBubbleBgColor color: JamiTheme.emojiReactBubbleBgColor
width: textEmojis.width + 6 width: textEmojis.width + 10
height: textEmojis.height + 6 height: textEmojis.height + 10
radius: 10 anchors.centerIn: textEmojis
radius: 5
Text { border.color: root.borderColor
id: textEmojis border.width: 1
anchors.margins: 10
anchors.centerIn: bubble
font.pointSize: JamiTheme.emojiReactSize
color: JamiTheme.chatviewTextColor
text: root.emojis
}
} }
DropShadow { Text {
z: -1 id: textEmojis
anchors.margins: 10
anchors.centerIn: root
width: bubble.width font.pointSize: JamiTheme.emojiReactSize
height: bubble.height color: JamiTheme.chatviewTextColor
horizontalOffset: 3.0 text: root.emojis
verticalOffset: 3.0 width: Math.min(implicitWidth,root.maxWidth)
radius: bubble.radius * 4 wrapMode: Text.Wrap
color: JamiTheme.shadowColor
source: bubble
transparentBorder: true
samples: radius + 1
} }
} }
...@@ -64,6 +64,15 @@ Control { ...@@ -64,6 +64,15 @@ Control {
// then the root delegate is likely a Loader. // then the root delegate is likely a Loader.
readonly property ListView listView: ListView.view ? ListView.view : parent.ListView.view readonly property ListView listView: ListView.view ? ListView.view : parent.ListView.view
function getBaseColor() {
var baseColor = isOutgoing ? CurrentConversation.color : JamiTheme.messageInBgColor;
if (Id === MessagesAdapter.replyToId || Id === MessagesAdapter.editId) {
// If we are replying to or editing the message
return Qt.darker(baseColor, 1.5);
}
return baseColor;
}
rightPadding: hPadding rightPadding: hPadding
leftPadding: hPadding leftPadding: hPadding
...@@ -115,7 +124,7 @@ Control { ...@@ -115,7 +124,7 @@ Control {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height Layout.preferredHeight: childrenRect.height
Layout.topMargin: visible? JamiTheme.sbsMessageBaseReplyTopMargin : 0 Layout.topMargin: visible ? JamiTheme.sbsMessageBaseReplyTopMargin : 0
Layout.leftMargin: isOutgoing ? undefined : JamiTheme.sbsMessageBaseReplyMargin Layout.leftMargin: isOutgoing ? undefined : JamiTheme.sbsMessageBaseReplyMargin
Layout.rightMargin: !isOutgoing ? undefined : JamiTheme.sbsMessageBaseReplyMargin Layout.rightMargin: !isOutgoing ? undefined : JamiTheme.sbsMessageBaseReplyMargin
...@@ -201,7 +210,7 @@ Control { ...@@ -201,7 +210,7 @@ Control {
RowLayout { RowLayout {
id: msgRowlayout id: msgRowlayout
Layout.preferredHeight: innerContent.height + root.extraHeight Layout.preferredHeight: innerContent.height + root.extraHeight + (emojiReactions.emojis === "" ? 0 : emojiReactions.height - 8)
Layout.topMargin: ((seq === MsgSeq.first || seq === MsgSeq.single) && !root.isReply) ? 6 : 0 Layout.topMargin: ((seq === MsgSeq.first || seq === MsgSeq.single) && !root.isReply) ? 6 : 0
Item { Item {
...@@ -323,17 +332,7 @@ Control { ...@@ -323,17 +332,7 @@ Control {
out: isOutgoing out: isOutgoing
type: seq type: seq
isReply: root.isReply isReply: root.isReply
color: root.getBaseColor()
function getBaseColor() {
var baseColor = isOutgoing ? CurrentConversation.color : JamiTheme.messageInBgColor;
if (Id === MessagesAdapter.replyToId || Id === MessagesAdapter.editId) {
// If we are replying to or editing the message
return Qt.darker(baseColor, 1.5);
}
return baseColor;
}
color: getBaseColor()
radius: msgRadius radius: msgRadius
anchors.right: isOutgoing ? parent.right : undefined anchors.right: isOutgoing ? parent.right : undefined
anchors.top: parent.top anchors.top: parent.top
...@@ -342,6 +341,55 @@ Control { ...@@ -342,6 +341,55 @@ Control {
height: innerContent.childrenRect.height + (visible ? root.extraHeight : 0) height: innerContent.childrenRect.height + (visible ? root.extraHeight : 0)
} }
EmojiReactions {
id: emojiReactions
anchors.top: bubble.bottom
anchors.topMargin: -8
height: contentHeight + 5
reactions: Reactions
borderColor: root.getBaseColor()
maxWidth: 2/3 * maxMsgWidth - JamiTheme.emojiMargins
state: root.isOutgoing ? "anchorsRight" : (emojiReactions.width > bubble.width - JamiTheme.emojiMargins ? "anchorsLeft" : "anchorsRight")
TapHandler {
onTapped: {
reactionPopup.open();
}
}
states: [
State {
name: "anchorsRight"
AnchorChanges {
target: emojiReactions;
anchors.right: bubble.right
anchors.left: undefined
}
PropertyChanges {
target: emojiReactions;
anchors.rightMargin: JamiTheme.emojiMargins
anchors.leftMargin: 0
}
},
State {
name: "anchorsLeft"
AnchorChanges {
target: emojiReactions;
anchors.right: undefined
anchors.left: bubble.left
}
PropertyChanges {
target: emojiReactions;
anchors.rightMargin: 0
anchors.leftMargin: JamiTheme.emojiMargins
}
}
]
}
Rectangle { Rectangle {
id: bg id: bg
...@@ -440,25 +488,6 @@ Control { ...@@ -440,25 +488,6 @@ Control {
} }
} }
EmojiReactions {
id: emojiReactions
property bool isOutgoing: Author === CurrentAccount.uri
Layout.alignment: isOutgoing ? Qt.AlignRight : Qt.AlignLeft
Layout.rightMargin: isOutgoing ? status.width : undefined
Layout.leftMargin: !isOutgoing ? avatarBlock.width : undefined
Layout.topMargin: -contentHeight / 4
Layout.preferredHeight: contentHeight + 5
Layout.preferredWidth: contentWidth
reactions: Reactions
TapHandler {
onTapped: {
reactionPopup.open();
}
}
}
ListView { ListView {
id: infoCell id: infoCell
......
...@@ -265,12 +265,13 @@ Item { ...@@ -265,12 +265,13 @@ Item {
property real namePopupFontsize: calcSize(15) property real namePopupFontsize: calcSize(15)
property real avatarSize: 30 property real avatarSize: 30
property int emojiPushButtonSize: 30 property int emojiPushButtonSize: 30
property int emojiMargins: 20 property int emojiMargins: 16
property color emojiReactBubbleBgColor: darkTheme ? darkGreyColor : whiteColor property color emojiReactBubbleBgColor: darkTheme ? darkGreyColor : whiteColor
property color emojiReactPushButtonColor: darkTheme ? "#bbb" : "#003b4e" property color emojiReactPushButtonColor: darkTheme ? "#bbb" : "#003b4e"
property real messageOptionTextFontSize: calcSize(15) property real messageOptionTextFontSize: calcSize(15)
property int emojiPickerWidth: 400 property int emojiPickerWidth: 400
property int emojiPickerHeight: 425 property int emojiPickerHeight: 425
property int defaulMaxWidthReaction : 350
// Files To Send Container // Files To Send Container
property color removeFileButtonColor: Qt.rgba(96, 95, 97, 0.5) property color removeFileButtonColor: Qt.rgba(96, 95, 97, 0.5)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment