update scripts

This commit is contained in:
Evgeny
2021-08-02 19:52:44 +03:00
parent d5d5504631
commit 0e79d5f275
3 changed files with 73 additions and 1 deletions

View File

@@ -8,5 +8,9 @@ function on_click()
end end
function on_dialog_action(idx) function on_dialog_action(idx)
if idx == -1 then
ui:show_toast("Dialog cancelled")
else
ui:show_toast("Checked: "..dialog_items[idx]) ui:show_toast("Checked: "..dialog_items[idx])
end end
end

13
utils.lua Normal file
View File

@@ -0,0 +1,13 @@
function get_args_kv()
local keys = {}
local values = {}
local args = aio:get_args()
for idx = 1, #args, 1 do
local arg = sx.split(args[idx], ":")
keys[idx] = arg[1]
values[idx] = arg[2]
end
return { keys, values }
end

55
widgets-on-off.lua Normal file
View File

@@ -0,0 +1,55 @@
-- name = "Включение виджетов"
-- description = "Включает и отключает виджеты на экране при нажатии на кнопки"
-- type = "widget"
-- author = "Andrey Gavrilov"
-- version = "1.0"
-- arguments_help = "Введите список виджетов и кнопок в формате bitcoin:Биткойн timer:Таймер"
-- arguments_default = "bitcoin:Битк. timer:Тайм. stopwatch:Секунд. recorder:Дикт. calculator:Кальк."
sx = require 'pl.stringx'
function on_resume()
local args = get_args_kv()
widgets = args[1]
buttons = args[2]
colors = {}
for idx,widget in ipairs(widgets) do
if aio:is_widget_added(widget) then
colors[idx] = "#f44336"
else
colors[idx] = "#388e3c"
end
end
ui:show_buttons(buttons, colors)
end
function on_click(idx)
local widget = widgets[idx]
if aio:is_widget_added(widget) then
aio:remove_widget(widget)
colors[idx] = "#388e3c"
else
aio:add_widget(widget)
colors[idx] = "#f44336"
end
ui:show_buttons(buttons, colors)
end
function get_args_kv()
local keys = {}
local values = {}
local args = aio:get_args()
for idx = 1, #args, 1 do
local arg = sx.split(args[idx], ":")
keys[idx] = arg[1]
values[idx] = arg[2]
end
return { keys, values }
end