Update notify module docs

This commit is contained in:
Evgeny
2025-04-23 19:32:49 +08:00
parent cc4813730a
commit 7074a17b83
2 changed files with 27 additions and 33 deletions

View File

@@ -1,34 +1,19 @@
-- This is an example of a widget that,
-- when a notification is added or removed,
-- simply reads the current notifications and refreshes the screen.
local curr_notab = {}
local curr_titletab = {}
local curr_keystab = {}
function on_notify_posted(n)
curr_notab[n.key] = n
redraw()
function on_resume()
refresh()
end
function on_notify_removed(n)
curr_notab[n.key] = nil
redraw()
ui:show_toast("Notify from "..n.package.." removed")
function on_notifications_updated()
refresh()
end
function redraw()
fill_tabs(curr_notab)
ui:show_lines(curr_titletab)
end
function on_click(i)
notify:open(curr_keystab[i])
end
function fill_tabs(tab)
curr_titletab = {}
curr_keystab = {}
for k,v in pairs(tab) do
table.insert(curr_titletab, v.title)
table.insert(curr_keystab, v.key)
end
function refresh()
local titles = map(
function(it) return it.title end,
notify:list()
)
ui:show_lines(titles)
end