2020-07-20 19:29:57 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
|
2021-02-01 20:37:50 +00:00
|
|
|
Rectangle {
|
|
|
|
property alias source: reactionImage.source
|
2020-08-12 17:58:19 +00:00
|
|
|
property var closeModal: function () {}
|
2020-07-20 19:29:57 +00:00
|
|
|
property int emojiId
|
2021-02-01 20:37:50 +00:00
|
|
|
property bool reactedByUser: false
|
|
|
|
property bool isHovered: value
|
|
|
|
|
|
|
|
id: root
|
|
|
|
width: reactionImage.width + Style.current.halfPadding
|
|
|
|
height: width
|
|
|
|
color: reactedByUser ? Style.current.secondaryBackground :
|
|
|
|
(isHovered ? Style.current.backgroundHover : Style.current.transparent)
|
|
|
|
border.width: reactedByUser ? 1 : 0
|
|
|
|
border.color: Style.current.borderTertiary
|
|
|
|
radius: Style.current.radius
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: reactionImage
|
|
|
|
width: 32
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2020-07-20 19:29:57 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2021-02-01 20:37:50 +00:00
|
|
|
hoverEnabled: !reactedByUser
|
|
|
|
onEntered: root.isHovered = true
|
|
|
|
onExited: root.isHovered = false
|
2020-07-20 19:29:57 +00:00
|
|
|
onClicked: {
|
2021-01-14 16:03:00 +00:00
|
|
|
chatsModel.toggleReaction(SelectedMessage.messageId, emojiId)
|
2021-02-01 20:37:50 +00:00
|
|
|
root.closeModal()
|
2020-07-20 19:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|