import { bind } from "astal"
import { Astal, Gtk, Widget } from "astal/gtk3"
import Notif from "gi://AstalNotifd"
import Pango from "gi://Pango?version=1.0"
const notifs = Notif.get_default()
const { TOP, RIGHT, BOTTOM } = Astal.WindowAnchor
const notifPlaceholder = "/home/spingus/.config/ags/assets/notif.svg"
let notifWindow: Widget.Window
let lastId: number
const wrap = (str: string, chars: number): string => {
if (str.length <= chars)
return str;
return str.substring(0, chars) + "\n" + wrap(str.substring(chars), chars);
}
function NewNotif(notif: Notif.Notification, inPanel: boolean = true) {
return
{notif.actions.map(action => )}
}
function NotifPanel() {
return
{notifs.notifications.map(n => NewNotif(n, false))}
}
function notify(notif: Notif.Notification) {
let thisNotif = NewNotif(notif)
if (notifWindow) {
let os = notifWindow.get_child().overlays
for (let i = os.length-1; i > 0; i--) {
if (os[i].get_preferred_width()[0] >= 352) {
os[i].css = `margin-top: ${(os[i+1]?.get_preferred_height()[0] ?? 20)+thisNotif.get_preferred_height()[0]-20}px;`
}
}
notifWindow.get_child().add_overlay(thisNotif)
notifWindow.get_child().get_child().heightRequest = os[1].get_preferred_height()[0] + thisNotif.get_preferred_height()[0]
} else {
notifWindow =
}
setTimeout(() => {
let os = notifWindow.get_child().overlays
let thisIndex = os.findIndex(nb => nb == thisNotif)
thisNotif.css = `margin-right: -352px; margin-top: ${(thisIndex === os.length-1) ? 20 : os[thisIndex+1].get_preferred_height()[0]+20}px; transition: cubic-bezier(0.64, 0, 0.78, 0) 0.3s;`
setTimeout(() => {
let os = notifWindow.get_child().overlays
notifWindow.get_child().remove(thisNotif)
if (os.length < 3) {
notifWindow.destroy()
notifWindow = null
}
}, 400)
}, 3000)
}
export default function notifWidget() {
return
}