fix notif popup anims

This commit is contained in:
end-4
2025-05-22 14:24:52 +02:00
parent 382a75e4c6
commit b66f1b7e93
2 changed files with 69 additions and 59 deletions
@@ -33,76 +33,80 @@ Scope {
}
mask: Region {
item: columnLayout
item: listview.contentItem
}
color: "transparent"
implicitWidth: Appearance.sizes.notificationPopupWidth
// Signal handlers to add/remove notifications
Connections {
target: Notifications
function onNotify(notification) {
if (GlobalStates.sidebarRightOpen) {
return
}
// notificationRepeater.model = [notification, ...notificationRepeater.model]
const notif = root.notifComponent.createObject(columnLayout, {
notificationObject: notification,
popup: true
});
notificationWidgetList.unshift(notif)
ListView { // Scrollable window
id: listview
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCente
implicitWidth: parent.width - Appearance.sizes.elevationMargin * 2
// Remove stuff from t he column, add back
for (let i = 0; i < notificationWidgetList.length; i++) {
if (notificationWidgetList[i].parent === columnLayout) {
notificationWidgetList[i].parent = null;
}
}
add: Transition {
animations: [
Appearance.animation.elementMove.numberAnimation.createObject(this, {
properties: "opacity,scale",
from: 0,
to: 1,
}),
]
}
// Add notification widgets to the column
for (let i = 0; i < notificationWidgetList.length; i++) {
if (notificationWidgetList[i].parent === null) {
notificationWidgetList[i].parent = columnLayout;
}
}
addDisplaced: Transition {
animations: [
Appearance.animation.elementMove.numberAnimation.createObject(this, {
property: "y",
}),
Appearance.animation.elementMove.numberAnimation.createObject(this, {
properties: "opacity,scale",
to: 1,
}),
]
}
function onDiscard(id) {
for (let i = notificationWidgetList.length - 1; i >= 0; i--) {
const widget = notificationWidgetList[i];
if (widget && widget.notificationObject && widget.notificationObject.id === id) {
widget.destroyWithAnimation();
notificationWidgetList.splice(i, 1);
}
}
displaced: Transition {
animations: [
Appearance.animation.elementMove.numberAnimation.createObject(this, {
property: "y",
}),
]
}
function onTimeout(id) {
for (let i = notificationWidgetList.length - 1; i >= 0; i--) {
const widget = notificationWidgetList[i];
if (widget && widget.notificationObject && widget.notificationObject.id === id) {
widget.destroyWithAnimation();
notificationWidgetList.splice(i, 1);
}
}
move: Transition {
animations: [
Appearance.animation.elementMove.numberAnimation.createObject(this, {
property: "y",
}),
]
}
function onDiscardAll() {
for (let i = notificationWidgetList.length - 1; i >= 0; i--) {
const widget = notificationWidgetList[i];
if (widget && widget.notificationObject) {
widget.destroyWithAnimation();
}
}
notificationWidgetList = [];
}
}
ColumnLayout { // Scrollable window content
id: columnLayout
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - Appearance.sizes.elevationMargin * 2
spacing: 0 // The widgets themselves have margins for spacing
remove: Transition {
animations: [
Appearance.animation.elementMove.numberAnimation.createObject(this, {
property: "x",
to: listview.width,
}),
Appearance.animation.elementMove.numberAnimation.createObject(this, {
property: "opacity",
to: 0,
})
]
}
// Notifications are added by the above signal handlers
model: ScriptModel {
values: Notifications.popupList.slice().reverse()
}
delegate: NotificationWidget {
required property var modelData
id: notificationWidget
popup: true
anchors.left: parent?.left
anchors.right: parent?.right
notificationObject: modelData
}
}
}