2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
2022-09-15 16:34:41 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0 as ChatStores
|
|
|
|
|
|
|
|
import mainui.activitycenter.stores 1.0
|
|
|
|
|
2022-09-15 16:34:41 +00:00
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2022-11-30 11:15:29 +00:00
|
|
|
/* required */ property int filteredIndex
|
|
|
|
/* required */ property var notification
|
2024-05-22 08:13:39 +00:00
|
|
|
/* required */ property ChatStores.RootStore store
|
|
|
|
/* required */ property ActivityCenterStore 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-09-15 16:34:41 +00:00
|
|
|
|
2022-11-16 17:17:38 +00:00
|
|
|
signal closeActivityCenter()
|
|
|
|
|
2023-01-23 09:00:06 +00:00
|
|
|
implicitHeight: Math.max(60, bodyLoader.height + bodyLoader.anchors.topMargin * 2 +
|
2022-10-20 11:57:41 +00:00
|
|
|
(dateGroupLabel.visible ? dateGroupLabel.height : 0) +
|
2024-10-15 19:26:12 +00:00
|
|
|
(badgeLoader.item ? badgeLoader.height + Theme.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
|
2022-11-30 11:15:29 +00:00
|
|
|
messageTimestamp: notification ? notification.timestamp : 0
|
|
|
|
previousMessageTimestamp: !notification || filteredIndex === 0 || !notification.previousTimestamp ?
|
|
|
|
0 : notification.previousTimestamp
|
2022-10-19 12:54:45 +00:00
|
|
|
visible: text !== ""
|
|
|
|
}
|
2022-09-15 16:34:41 +00:00
|
|
|
|
2023-01-23 09:00:06 +00:00
|
|
|
Rectangle {
|
|
|
|
id: backgroundRect
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: dateGroupLabel.visible ? dateGroupLabel.height : 0
|
|
|
|
radius: 6
|
|
|
|
color: notification && !notification.read ? Theme.palette.primaryColor3 : "transparent"
|
|
|
|
Behavior on color { ColorAnimation { duration: 200 } }
|
|
|
|
}
|
|
|
|
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.smallPadding
|
2022-09-27 16:21:00 +00:00
|
|
|
anchors.right: ctaLoader.left
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.rightMargin: Theme.smallPadding
|
2022-09-23 12:24:50 +00:00
|
|
|
anchors.left: parent.left
|
2023-02-15 12:24:18 +00:00
|
|
|
clip: true
|
2022-09-23 12:24:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: badgeLoader
|
2022-10-01 12:07:14 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.bottomMargin: Theme.smallPadding
|
2022-09-23 12:24:50 +00:00
|
|
|
anchors.left: parent.left
|
2022-11-16 17:17:38 +00:00
|
|
|
anchors.leftMargin: 50 // TODO find a way to align with the text of the message
|
2022-09-23 12:24:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.rightMargin: Theme.padding
|
2022-09-23 12:24:50 +00:00
|
|
|
|
|
|
|
sourceComponent: StatusFlatRoundButton {
|
2022-10-26 16:00:20 +00:00
|
|
|
icon.width: 20
|
|
|
|
icon.height: 20
|
2022-11-29 11:57:07 +00:00
|
|
|
icon.name: "checkmark"
|
2022-11-30 11:15:29 +00:00
|
|
|
icon.color: notification && notification.read ? icon.disabledColor : Theme.palette.primaryColor1
|
|
|
|
tooltip.text: notification && notification.read ? qsTr("Mark as Unread") : qsTr("Mark as Read")
|
2022-09-23 12:24:50 +00:00
|
|
|
tooltip.orientation: StatusToolTip.Orientation.Left
|
2024-10-15 19:26:12 +00:00
|
|
|
tooltip.x: -tooltip.width - Theme.padding
|
2022-09-23 12:24:50 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2022-11-29 11:57:07 +00:00
|
|
|
}
|