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

Emoji Picker: correct position

GitLab: #1431

Change-Id: I5d86598da3120df5b34b375e1019bb0d0c8d88f0
parent 74120737
Branches
Tags
No related merge requests found
...@@ -40,7 +40,7 @@ BaseContextMenu { ...@@ -40,7 +40,7 @@ BaseContextMenu {
property bool closeWithoutAnimation: false property bool closeWithoutAnimation: false
property var emojiPicker property var emojiPicker
function xPositionProvider(width) { function xPosition(width) {
// Use the width at function scope to retrigger property evaluation. // Use the width at function scope to retrigger property evaluation.
const listViewWidth = listView.width; const listViewWidth = listView.width;
const parentX = parent.x; const parentX = parent.x;
...@@ -51,9 +51,30 @@ BaseContextMenu { ...@@ -51,9 +51,30 @@ BaseContextMenu {
} }
} }
x: xPositionProvider(width) x: xPosition(width)
y: parent.y y: parent.y
function xPositionProvider(width) {
// Use the width at function scope to retrigger property evaluation.
const listViewWidth = listView.width;
if (isOutgoing) {
return -5 - width;
} else {
const rightMargin = listViewWidth - (msgBubble.x + width);
return width > rightMargin + 35 ? -5 - width : 35;
}
}
function yPositionProvider(height) {
const topOffset = msgBubble.mapToItem(listView, 0, 0).y;
const listViewHeight = listView.height;
const bottomMargin = listViewHeight - height - topOffset;
if (bottomMargin < 0 || (topOffset < 0 && topOffset + height > 0)) {
return 30 - height;
} else {
return 0;
}
}
signal addMoreEmoji signal addMoreEmoji
onAddMoreEmoji: { onAddMoreEmoji: {
JamiQmlUtils.updateMessageBarButtonsPoints(); JamiQmlUtils.updateMessageBarButtonsPoints();
...@@ -74,7 +95,6 @@ BaseContextMenu { ...@@ -74,7 +95,6 @@ BaseContextMenu {
}); });
if (emojiPicker !== null) { if (emojiPicker !== null) {
root.opacity = 0; root.opacity = 0;
emojiPicker.closed.connect(() => close());
emojiPicker.x = xPositionProvider(JamiTheme.emojiPickerWidth); emojiPicker.x = xPositionProvider(JamiTheme.emojiPickerWidth);
emojiPicker.y = yPositionProvider(JamiTheme.emojiPickerHeight); emojiPicker.y = yPositionProvider(JamiTheme.emojiPickerHeight);
emojiPicker.open(); emojiPicker.open();
...@@ -83,11 +103,8 @@ BaseContextMenu { ...@@ -83,11 +103,8 @@ BaseContextMenu {
} }
} }
// Close the picker when listView vertical properties change.
property real listViewHeight: listView.height property real listViewHeight: listView.height
onListViewHeightChanged: close()
property bool isScrolling: listView.verticalScrollBar.active property bool isScrolling: listView.verticalScrollBar.active
onIsScrollingChanged: close()
onOpened: root.closeWithoutAnimation = false onOpened: root.closeWithoutAnimation = false
onClosed: if (emojiPicker) onClosed: if (emojiPicker)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment