feat(ags): add anims to notifs when pressing on clear
This commit is contained in:
parent
8f992718cb
commit
23ed97ea7b
1 changed files with 36 additions and 17 deletions
|
@ -1,27 +1,46 @@
|
||||||
const { Notifications } = ags.Service;
|
const { Notifications } = ags.Service;
|
||||||
const { Button, Label, Box, Icon, Scrollable, Window, Revealer } = ags.Widget;
|
const { Button, Label, Box, Icon, Scrollable, Window, Revealer } = ags.Widget;
|
||||||
const { timeout } = ags.Utils;
|
const { timeout } = ags.Utils;
|
||||||
|
const { getWindow } = ags.App;
|
||||||
|
|
||||||
import Notification from './base.js';
|
import Notification from './base.js';
|
||||||
import { EventBox } from '../misc/cursorbox.js'
|
import { EventBox } from '../misc/cursorbox.js'
|
||||||
|
|
||||||
const ClearButton = () => EventBox({child: Button({
|
const ClearButton = () => EventBox({
|
||||||
onClicked: Notifications.clear,
|
child: Button({
|
||||||
connections: [[Notifications, button => {
|
onPrimaryClickRelease: button => {
|
||||||
button.sensitive = Notifications.notifications.length > 0;
|
button._popups.children.forEach(ch => ch.child.setStyle(ch.child._leftAnim));
|
||||||
}]],
|
button._notifList.children.forEach(ch => {
|
||||||
child: Box({
|
ch.child.setStyle(ch.child._rightAnim);
|
||||||
children: [
|
timeout(500, () => {
|
||||||
Label('Clear '),
|
button._notifList.remove(ch);
|
||||||
Icon({
|
Notifications.close(ch._id);
|
||||||
connections: [[Notifications, icon => {
|
});
|
||||||
icon.icon = Notifications.notifications.length > 0
|
});
|
||||||
|
},
|
||||||
|
properties: [['notifList'], ['popups']],
|
||||||
|
connections: [[Notifications, button => {
|
||||||
|
if (!button._notifList)
|
||||||
|
button._notifList = getWindow('notification-center').child.children[1].children[0].child.child.children[0];
|
||||||
|
|
||||||
|
if (!button._popups)
|
||||||
|
button._popups = getWindow('notifications').child.children[0].child;
|
||||||
|
|
||||||
|
button.sensitive = Notifications.notifications.length > 0;
|
||||||
|
}]],
|
||||||
|
child: Box({
|
||||||
|
children: [
|
||||||
|
Label('Clear '),
|
||||||
|
Icon({
|
||||||
|
connections: [[Notifications, icon => {
|
||||||
|
icon.icon = Notifications.notifications.length > 0
|
||||||
? 'user-trash-full-symbolic' : 'user-trash-symbolic';
|
? 'user-trash-full-symbolic' : 'user-trash-symbolic';
|
||||||
}]],
|
}]],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
})});
|
});
|
||||||
|
|
||||||
const Header = () => Box({
|
const Header = () => Box({
|
||||||
className: 'header',
|
className: 'header',
|
||||||
|
@ -49,11 +68,9 @@ const NotificationList = () => Box({
|
||||||
box.show_all();
|
box.show_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
box.visible = Notifications.notifications.length > 0;
|
|
||||||
}, 'notified'],
|
}, 'notified'],
|
||||||
|
|
||||||
[Notifications, (box, id) => {
|
[Notifications, (box, id) => {
|
||||||
box.visible = Notifications.notifications.length > 0;
|
|
||||||
for (const ch of box.children) {
|
for (const ch of box.children) {
|
||||||
if (ch._id == id) {
|
if (ch._id == id) {
|
||||||
ch.child.setStyle(ch.child._rightAnim);
|
ch.child.setStyle(ch.child._rightAnim);
|
||||||
|
@ -62,6 +79,8 @@ const NotificationList = () => Box({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 'closed'],
|
}, 'closed'],
|
||||||
|
|
||||||
|
[Notifications, box => box.visible = Notifications.notifications.length > 0],
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue