2022-09-15 16:34:41 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import shared 1.0
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var notification
|
|
|
|
property var store
|
2022-10-26 16:00:20 +00:00
|
|
|
property var activityCenterStore
|
2022-09-15 16:34:41 +00:00
|
|
|
|
2022-09-23 12:24:50 +00:00
|
|
|
property alias bodyComponent: bodyLoader.sourceComponent
|
|
|
|
property alias badgeComponent: badgeLoader.sourceComponent
|
2022-09-27 16:21:00 +00:00
|
|
|
property alias ctaComponent: ctaLoader.sourceComponent
|
2022-10-19 12:54:45 +00:00
|
|
|
property alias previousNotificationIndex: dateGroupLabel.previousMessageIndex
|
2022-09-15 16:34:41 +00:00
|
|
|
|
2022-10-20 11:57:41 +00:00
|
|
|
implicitHeight: Math.max(60, bodyLoader.height +
|
|
|
|
(dateGroupLabel.visible ? dateGroupLabel.height : 0) +
|
2022-10-29 07:17:35 +00:00
|
|
|
(badgeLoader.item ? badgeLoader.height + Style.current.smallPadding : 0))
|
2022-10-19 12:54:45 +00:00
|
|
|
|
|
|
|
StatusDateGroupLabel {
|
|
|
|
id: dateGroupLabel
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
messageTimestamp: notification.timestamp
|
|
|
|
previousMessageTimestamp: root.previousNotificationIndex == 0 ? "" :
|
2022-10-26 16:00:20 +00:00
|
|
|
root.activityCenterStore.activityCenterList.getNotificationData(
|
|
|
|
previousNotificationIndex, "timestamp")
|
2022-10-19 12:54:45 +00:00
|
|
|
visible: text !== ""
|
|
|
|
}
|
2022-09-15 16:34:41 +00:00
|
|
|
|
2022-09-23 12:24:50 +00:00
|
|
|
Loader {
|
|
|
|
id: bodyLoader
|
2022-10-19 12:54:45 +00:00
|
|
|
anchors.top: dateGroupLabel.visible ? dateGroupLabel.bottom : parent.top
|
2022-09-27 16:21:00 +00:00
|
|
|
anchors.right: ctaLoader.left
|
2022-09-23 12:24:50 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: badgeLoader
|
2022-10-01 12:07:14 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2022-09-23 12:24:50 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 61 // TODO find a way to align with the text of the message
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
2022-09-27 16:21:00 +00:00
|
|
|
id: ctaLoader
|
2022-10-05 14:51:42 +00:00
|
|
|
anchors.verticalCenter: bodyLoader.verticalCenter
|
2022-09-15 16:34:41 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2022-09-23 12:24:50 +00:00
|
|
|
|
|
|
|
sourceComponent: StatusFlatRoundButton {
|
|
|
|
id: markReadBtn
|
2022-10-26 16:00:20 +00:00
|
|
|
icon.width: 20
|
|
|
|
icon.height: 20
|
2022-09-23 12:24:50 +00:00
|
|
|
icon.source: Style.svg("check-activity")
|
2022-10-26 16:00:20 +00:00
|
|
|
icon.color: root.notification.read ? icon.disabledColor : "transparent"
|
|
|
|
tooltip.text: !root.notification.read ? qsTr("Mark as Read") : qsTr("Mark as Unread")
|
2022-09-23 12:24:50 +00:00
|
|
|
tooltip.orientation: StatusToolTip.Orientation.Left
|
|
|
|
tooltip.x: -tooltip.width - Style.current.padding
|
|
|
|
tooltip.y: 4
|
|
|
|
onClicked: {
|
|
|
|
notification.read ?
|
2022-10-26 16:00:20 +00:00
|
|
|
root.activityCenterStore.markActivityCenterNotificationUnread(root.notification) :
|
|
|
|
root.activityCenterStore.markActivityCenterNotificationRead(root.notification)
|
2022-09-23 12:24:50 +00:00
|
|
|
}
|
2022-09-15 16:34:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|