2023-09-11 13:59:51 -04:00
|
|
|
const { Notifications } = ags.Service;
|
|
|
|
const { Button, Label, Box, Icon, Scrollable, Window } = ags.Widget;
|
|
|
|
|
2023-09-11 19:57:21 -04:00
|
|
|
import Notification from './base.js';
|
|
|
|
import { EventBox } from '../misc/cursorbox.js'
|
|
|
|
|
2023-09-11 16:25:57 -04:00
|
|
|
const ClearButton = () => EventBox({child: Button({
|
2023-09-11 14:18:22 -04:00
|
|
|
onClicked: Notifications.clear,
|
|
|
|
connections: [[Notifications, button => {
|
|
|
|
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';
|
|
|
|
}]],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
2023-09-11 16:25:57 -04:00
|
|
|
})});
|
2023-09-11 13:59:51 -04:00
|
|
|
|
|
|
|
const Header = () => Box({
|
2023-09-11 14:18:22 -04:00
|
|
|
className: 'header',
|
|
|
|
children: [
|
|
|
|
Label({ label: 'Notifications', hexpand: true, xalign: 0 }),
|
|
|
|
ClearButton(),
|
|
|
|
],
|
2023-09-11 13:59:51 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
const NotificationList = () => Box({
|
2023-09-11 14:18:22 -04:00
|
|
|
vertical: true,
|
|
|
|
vexpand: true,
|
|
|
|
connections: [[Notifications, box => {
|
|
|
|
box.children = Notifications.notifications
|
|
|
|
.reverse()
|
|
|
|
.map(n => Notification(n));
|
2023-09-11 13:59:51 -04:00
|
|
|
|
2023-09-11 14:18:22 -04:00
|
|
|
box.visible = Notifications.notifications.length > 0;
|
|
|
|
}]],
|
2023-09-11 13:59:51 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
const Placeholder = () => Box({
|
2023-09-11 14:18:22 -04:00
|
|
|
className: 'placeholder',
|
|
|
|
vertical: true,
|
|
|
|
valign: 'center',
|
|
|
|
halign: 'center',
|
|
|
|
vexpand: true,
|
|
|
|
hexpand: true,
|
|
|
|
children: [
|
|
|
|
Icon('notification-disabled-symbolic'),
|
|
|
|
Label('Your inbox is empty'),
|
|
|
|
],
|
|
|
|
connections: [[Notifications, box => {
|
|
|
|
box.visible = Notifications.notifications.length === 0;
|
|
|
|
}]],
|
2023-09-11 13:59:51 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
export const NotificationCenter = Window({
|
|
|
|
name: 'notification-center',
|
2023-09-11 14:18:22 -04:00
|
|
|
popup: true,
|
2023-09-11 13:59:51 -04:00
|
|
|
layer: 'overlay',
|
|
|
|
anchor: 'top right',
|
|
|
|
child: Box({
|
2023-09-11 16:25:57 -04:00
|
|
|
className: 'notification-center',
|
2023-09-11 13:59:51 -04:00
|
|
|
vertical: true,
|
|
|
|
children: [
|
2023-09-11 14:18:22 -04:00
|
|
|
Header(),
|
|
|
|
Box({
|
|
|
|
className: 'notification-wallpaper-box',
|
|
|
|
children: [Scrollable({
|
|
|
|
className: 'notification-list-box',
|
|
|
|
hscroll: 'never',
|
|
|
|
vscroll: 'automatic',
|
|
|
|
child: Box({
|
|
|
|
className: 'notification-list',
|
|
|
|
vertical: true,
|
|
|
|
children: [
|
|
|
|
NotificationList(),
|
|
|
|
Placeholder(),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
})],
|
|
|
|
}),
|
2023-09-11 13:59:51 -04:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
});
|