Added pagination to the notifications menu and a configurable limit to the amount of notifications spawned. (#199)

* Added notification pagination and pagination configuration options. fixes #171

* Added skip to end buttons

* Update theme

* Removed unused theme parts

* Update pager colors

* Theme auto-generator

* Update label color in options for pager.

* Updated themes

* Added option to change footer background for notifications menu.

* Changes to the Displayed Total options now update the menu. Bugfix
This commit is contained in:
Jas Singh
2024-08-30 01:32:11 -07:00
committed by GitHub
parent f80b3e4ef6
commit f624153eab
39 changed files with 1586 additions and 1317 deletions

View File

@@ -0,0 +1,74 @@
const notifs = await Service.import("notifications");
import options from "options";
import { Variable } from "types/variable";
const { displayedTotal } = options.notifications;
export const NotificationPager = (curPage: Variable<number>) => {
return Widget.Box({
class_name: "notification-menu-pager",
hexpand: true,
vexpand: false,
children: Utils.merge([curPage.bind("value"), displayedTotal.bind("value"), notifs.bind("notifications")], (currentPage, dispTotal, notifications) => {
return [
Widget.Button({
hexpand: true,
hpack: "start",
class_name: `pager-button left ${currentPage <= 1 ? "disabled" : ""}`,
onPrimaryClick: () => {
curPage.value = 1;
},
child: Widget.Label({
className: "pager-button-label",
label: ""
}),
}),
Widget.Button({
hexpand: true,
hpack: "start",
class_name: `pager-button left ${currentPage <= 1 ? "disabled" : ""}`,
onPrimaryClick: () => {
curPage.value = currentPage <= 1 ? 1 : currentPage - 1;
},
child: Widget.Label({
className: "pager-button-label",
label: ""
}),
}),
Widget.Label({
hexpand: true,
hpack: "center",
class_name: "pager-label",
label: `${currentPage} / ${Math.ceil(notifs.notifications.length / dispTotal) || 1}`
}),
Widget.Button({
hexpand: true,
hpack: "end",
class_name: `pager-button right ${currentPage >= Math.ceil(notifs.notifications.length / dispTotal) ? "disabled" : ""}`,
onPrimaryClick: () => {
const maxPage = Math.ceil(notifs.notifications.length / displayedTotal.value);
curPage.value = currentPage >= maxPage ? currentPage : currentPage + 1;
},
child: Widget.Label({
className: "pager-button-label",
label: ""
}),
}),
Widget.Button({
hexpand: true,
hpack: "end",
class_name: `pager-button right ${currentPage >= Math.ceil(notifs.notifications.length / dispTotal) ? "disabled" : ""}`,
onPrimaryClick: () => {
const maxPage = Math.ceil(notifs.notifications.length / displayedTotal.value);
curPage.value = maxPage;
},
child: Widget.Label({
className: "pager-button-label",
label: "󰄾"
}),
}),
]
})
})
}