2021-05-28 17:35:21 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2021-06-11 17:41:59 +00:00
|
|
|
import QtQml.Models 2.13
|
2021-07-29 19:20:49 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2021-05-28 17:35:21 +00:00
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../shared/status"
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-05-28 17:35:21 +00:00
|
|
|
import "./ChatComponents"
|
|
|
|
import "../components"
|
2021-06-11 17:41:59 +00:00
|
|
|
import "./MessageComponents"
|
2021-05-28 17:35:21 +00:00
|
|
|
|
|
|
|
Popup {
|
|
|
|
enum Filter {
|
|
|
|
All,
|
|
|
|
Mentions,
|
|
|
|
Replies,
|
|
|
|
ContactRequests
|
|
|
|
}
|
|
|
|
property int currentFilter: ActivityCenter.Filter.All
|
2021-06-11 19:50:52 +00:00
|
|
|
property bool hasMentions: false
|
|
|
|
property bool hasReplies: false
|
2021-07-27 17:59:01 +00:00
|
|
|
// property bool hasContactRequests: false
|
2021-05-28 17:35:21 +00:00
|
|
|
|
2021-06-10 15:15:38 +00:00
|
|
|
property bool hideReadNotifications: false
|
|
|
|
|
2021-05-28 17:35:21 +00:00
|
|
|
id: activityCenter
|
2021-07-29 19:20:49 +00:00
|
|
|
modal: false
|
2021-05-28 17:35:21 +00:00
|
|
|
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
parent: Overlay.overlay
|
2021-07-29 19:20:49 +00:00
|
|
|
|
2021-09-08 02:11:51 +00:00
|
|
|
dim: true
|
|
|
|
Overlay.modeless: MouseArea {}
|
|
|
|
|
2021-05-28 17:35:21 +00:00
|
|
|
width: 560
|
|
|
|
background: Rectangle {
|
|
|
|
color: Style.current.background
|
|
|
|
radius: Style.current.radius
|
2021-07-29 19:20:49 +00:00
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
verticalOffset: 3
|
|
|
|
radius: Style.current.radius
|
|
|
|
samples: 15
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: Style.current.dropShadow
|
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
x: applicationWindow.width - activityCenter.width - Style.current.halfPadding
|
|
|
|
onOpened: {
|
|
|
|
popupOpened = true
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
popupOpened = false
|
|
|
|
}
|
|
|
|
padding: 0
|
|
|
|
|
|
|
|
ActivityCenterTopBar {
|
|
|
|
id: activityCenterTopBar
|
|
|
|
}
|
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
ScrollView {
|
|
|
|
id: scrollView
|
2021-05-28 17:35:21 +00:00
|
|
|
anchors.top: activityCenterTopBar.bottom
|
|
|
|
anchors.topMargin: 13
|
2021-06-11 17:41:59 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: Style.current.smallPadding
|
2021-05-28 17:35:21 +00:00
|
|
|
width: parent.width
|
2021-06-11 17:41:59 +00:00
|
|
|
clip: true
|
2021-05-28 17:35:21 +00:00
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
2021-05-28 19:01:46 +00:00
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
Column {
|
|
|
|
id: notificationsContainer
|
|
|
|
width: parent.width
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
property Component profilePopupComponent: ProfilePopup {
|
|
|
|
id: profilePopup
|
|
|
|
onClosed: destroy()
|
2021-05-28 19:01:46 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
// TODO remove this once it is handled by the activity center
|
2021-07-27 17:59:01 +00:00
|
|
|
// Repeater {
|
|
|
|
// id: contactList
|
|
|
|
// model: profileModel.contacts.contactRequests
|
|
|
|
|
|
|
|
// delegate: ContactRequest {
|
|
|
|
// visible: !hideReadNotifications &&
|
|
|
|
// (activityCenter.currentFilter === ActivityCenter.Filter.All || activityCenter.currentFilter === ActivityCenter.Filter.ContactRequests)
|
|
|
|
// name: Utils.removeStatusEns(model.name)
|
|
|
|
// address: model.address
|
|
|
|
// localNickname: model.localNickname
|
|
|
|
// identicon: model.thumbnailImage || model.identicon
|
|
|
|
// // TODO set to transparent bg if the notif is read
|
|
|
|
// color: Utils.setColorAlpha(Style.current.blue, 0.1)
|
|
|
|
// radius: 0
|
|
|
|
// profileClick: function (showFooter, userName, fromAuthor, identicon, textParam, nickName) {
|
|
|
|
// var popup = profilePopupComponent.createObject(contactList);
|
|
|
|
// popup.openPopup(showFooter, userName, fromAuthor, identicon, textParam, nickName);
|
|
|
|
// }
|
|
|
|
// onBlockContactActionTriggered: {
|
|
|
|
// blockContactConfirmationDialog.contactName = name
|
|
|
|
// blockContactConfirmationDialog.contactAddress = address
|
|
|
|
// blockContactConfirmationDialog.open()
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2021-05-28 17:35:21 +00:00
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
Repeater {
|
|
|
|
model: notifDelegateList
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
DelegateModelGeneralized {
|
|
|
|
id: notifDelegateList
|
2021-06-15 19:34:36 +00:00
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
lessThan: [
|
|
|
|
function(left, right) { return left.timestamp > right.timestamp }
|
|
|
|
]
|
|
|
|
|
|
|
|
model: chatsModel.activityNotificationList
|
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
id: notificationDelegate
|
|
|
|
width: parent.width
|
|
|
|
height: notifLoader.active ? childrenRect.height : 0
|
|
|
|
|
|
|
|
property int idx: DelegateModel.itemsIndex
|
|
|
|
|
2021-06-11 19:50:52 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
switch (model.notificationType) {
|
2021-06-11 20:34:25 +00:00
|
|
|
case Constants.activityCenterNotificationTypeMention:
|
2021-06-11 19:50:52 +00:00
|
|
|
if (!hasMentions) {
|
|
|
|
hasMentions = true
|
|
|
|
}
|
|
|
|
break
|
|
|
|
|
2021-06-11 20:34:25 +00:00
|
|
|
case Constants.activityCenterNotificationTypeReply:
|
2021-06-11 19:50:52 +00:00
|
|
|
if (!hasReplies) {
|
|
|
|
hasReplies = true
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2021-06-11 17:41:59 +00:00
|
|
|
|
|
|
|
Loader {
|
2021-06-15 19:34:36 +00:00
|
|
|
property int previousNotificationIndex: {
|
|
|
|
if (notificationDelegate.idx === 0) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is used in order to have access to the previous message and determine the timestamp
|
|
|
|
// we can't rely on the index because the sequence of messages is not ordered on the nim side
|
|
|
|
if (notificationDelegate.idx < notifDelegateList.items.count - 1) {
|
|
|
|
return notifDelegateList.items.get(notificationDelegate.idx - 1).model.index
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
property string previousNotificationTimestamp: notificationDelegate.idx === 0 ? "" : chatsModel.activityNotificationList.getNotificationData(previousNotificationIndex, "timestamp")
|
|
|
|
|
|
|
|
|
2021-06-11 17:41:59 +00:00
|
|
|
id: notifLoader
|
|
|
|
anchors.top: parent.top
|
|
|
|
active: !!sourceComponent
|
|
|
|
width: parent.width
|
|
|
|
sourceComponent: {
|
|
|
|
switch (model.notificationType) {
|
2021-07-20 14:24:16 +00:00
|
|
|
case Constants.activityCenterNotificationTypeOneToOne:
|
|
|
|
case Constants.activityCenterNotificationTypeMention:
|
2021-06-11 20:34:25 +00:00
|
|
|
case Constants.activityCenterNotificationTypeReply: return messageNotificationComponent
|
2021-06-15 19:34:36 +00:00
|
|
|
case Constants.activityCenterNotificationTypeGroupRequest: return groupRequestNotificationComponent
|
2021-06-11 17:41:59 +00:00
|
|
|
default: return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: messageNotificationComponent
|
|
|
|
|
2021-06-15 19:34:36 +00:00
|
|
|
ActivityCenterMessageComponent {}
|
|
|
|
}
|
2021-06-21 15:03:40 +00:00
|
|
|
|
2021-06-15 19:34:36 +00:00
|
|
|
Component {
|
|
|
|
id: groupRequestNotificationComponent
|
2021-06-21 15:03:40 +00:00
|
|
|
|
2021-06-15 19:34:36 +00:00
|
|
|
ActivityCenterGroupRequest {}
|
2021-06-11 17:41:59 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 18:05:49 +00:00
|
|
|
Item {
|
|
|
|
visible: chatsModel.activityNotificationList.hasMoreToShow
|
|
|
|
width: parent.width
|
|
|
|
height: visible ? showMoreBtn.height + showMoreBtn.anchors.topMargin : 0
|
|
|
|
StatusButton {
|
|
|
|
id: showMoreBtn
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Show more"
|
|
|
|
text: qsTrId("show-more")
|
2021-06-08 18:05:49 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
onClicked: chatsModel.activityNotificationList.loadMoreNotifications()
|
|
|
|
}
|
|
|
|
}
|
2021-06-11 17:41:59 +00:00
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
}
|