summaryrefslogtreecommitdiffstats
path: root/resources/qml/Reactions.qml
blob: c70519a4d169784a38d0727d044878344d0de15d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import QtQuick 2.6
import QtQuick.Controls 2.2

Flow {
	anchors.left: parent.left
	anchors.right: parent.right
	spacing: 4

	property alias reactions: repeater.model

	Repeater {
		id: repeater

		Button {
			id: reaction
			text: model.key
			hoverEnabled: true
			implicitWidth: contentItem.childrenRect.width + contentItem.padding*2
			implicitHeight: contentItem.childrenRect.height + contentItem.padding*2

			ToolTip.visible: hovered
			ToolTip.text: model.users

			contentItem: Row {
				anchors.centerIn: parent
				spacing: 2
				padding: 4

				Text {
					anchors.baseline: reactionCounter.baseline
					id: reactionText
					text: reaction.text
					font.family: settings.emoji_font_family
					opacity: enabled ? 1.0 : 0.3
					color: reaction.hovered ? colors.highlight : colors.text
					horizontalAlignment: Text.AlignHCenter
					verticalAlignment: Text.AlignVCenter
					elide: Text.ElideRight
				}

				Rectangle {
					height: reactionText.implicitHeight
					width: 1
					color: reaction.hovered ? colors.highlight : colors.text
				}

				Text {
					id: reactionCounter
					text: model.counter
					font: reaction.font
					opacity: enabled ? 1.0 : 0.3
					color: reaction.hovered ? colors.highlight : colors.text
					horizontalAlignment: Text.AlignHCenter
					verticalAlignment: Text.AlignVCenter
					elide: Text.ElideRight
				}
			}

			background: Rectangle {
				anchors.centerIn: parent
				implicitWidth: reaction.implicitWidth
				implicitHeight: reaction.implicitHeight
				opacity: enabled ? 1 : 0.3
				border.color: (reaction.hovered || model.selfReacted )? colors.highlight : colors.text
				color: colors.base
				border.width: 1
				radius: reaction.height / 2.0
			}
		}
	}
}