add new apis and samples
This commit is contained in:
28
samples/widgets-sample.lua
Normal file
28
samples/widgets-sample.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
local fmt = require "fmt"
|
||||
|
||||
function on_resume()
|
||||
local widgets = aio:get_active_widgets()
|
||||
local tab = {}
|
||||
|
||||
for k,v in pairs(widgets) do
|
||||
table.insert(tab, { fmt.bold(v.name), "(un)fold", "remove" })
|
||||
end
|
||||
|
||||
ui:show_table(tab)
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
local widget_num = math.ceil(idx / 3)
|
||||
local action = idx % 3
|
||||
|
||||
if action == 0 then
|
||||
aio:remove_widget(widget_num)
|
||||
elseif action == 2 then
|
||||
aio:fold_widget(widget_num)
|
||||
end
|
||||
end
|
||||
|
||||
function on_widget_action(action, name)
|
||||
ui:show_toast(name.." "..action)
|
||||
on_resume()
|
||||
end
|
||||
Reference in New Issue
Block a user