update scripts to reflect latest api changes

This commit is contained in:
Evgeny
2021-08-31 13:24:26 +03:00
parent 54577f95d2
commit 6516a81f1f
2 changed files with 101 additions and 80 deletions

View File

@@ -32,7 +32,6 @@ local rate = 0
function on_alarm() function on_alarm()
date = os.date("%Y-%m-%d") date = os.date("%Y-%m-%d")
get_rates(date) get_rates(date)
ui:prepare_context_menu({{"share-alt","Поделиться"},{"copy","Копировать"},{"redo","Перезагрузить"}})
end end
function get_rates(date) function get_rates(date)
@@ -78,6 +77,16 @@ function on_click(idx)
end end
end end
function on_long_click(idx)
item_idx = idx
ui:show_context_menu({
{"share-alt","Поделиться"},
{"copy","Копировать"},
{"redo","Перезагрузить"}
})
end
function on_dialog_action(data) function on_dialog_action(data)
if data == -1 then if data == -1 then
return return
@@ -131,7 +140,7 @@ function on_dialog_action(data)
get_rates(date) get_rates(date)
end end
function on_context_menu_click(item_idx, menu_idx) function on_context_menu_click(menu_idx)
if menu_idx == 2 then if menu_idx == 2 then
system:copy_to_clipboard(rate) system:copy_to_clipboard(rate)
elseif menu_idx == 1 then elseif menu_idx == 1 then

View File

@@ -17,6 +17,7 @@ local style = {"Icons", "Names"}
--variables-- --variables--
local dialog_id = "" local dialog_id = ""
local item_idx = 0
function on_resume() function on_resume()
if next(aio:get_args()) == nil then if next(aio:get_args()) == nil then
@@ -24,7 +25,6 @@ function on_resume()
end end
ui:set_folding_flag(true) ui:set_folding_flag(true)
ui:prepare_context_menu({{"sliders-v-square","Widgets"},{"pencil-alt","Style"},{"info","Info"}})
local buttons,colors = get_buttons() local buttons,colors = get_buttons()
ui:show_buttons(buttons, colors) ui:show_buttons(buttons, colors)
@@ -46,6 +46,29 @@ function on_click(idx)
ui:show_buttons(buttons, colors) ui:show_buttons(buttons, colors)
end end
function on_long_click(idx)
item_idx = idx
ui:show_context_menu({
{"sliders-v-square", "Widgets"},
{"pencil-alt", "Style"},
{"info", "Info"}
})
end
function on_context_menu_click(menu_idx)
if menu_idx == 1 then
dialog_id = "widgets"
ui:show_checkbox_dialog("Select widgets", names, get_checkbox_idx())
elseif menu_idx == 2 then
dialog_id = "style"
ui:show_radio_dialog("Select style", style, get_radio_idx())
elseif menu_idx == 3 then
dialog_id = "info"
ui:show_dialog("Widget", names[get_checkbox_idx()[item_idx]])
end
end
function on_dialog_action(data) function on_dialog_action(data)
if data == -1 then if data == -1 then
return return
@@ -65,19 +88,6 @@ function on_dialog_action(data)
on_resume() on_resume()
end end
function on_context_menu_click(item_idx, menu_idx)
if menu_idx == 1 then
dialog_id = "widgets"
ui:show_checkbox_dialog("Select widgets", names, get_checkbox_idx())
elseif menu_idx == 2 then
dialog_id = "style"
ui:show_radio_dialog("Select style", style, get_radio_idx())
elseif menu_idx == 3 then
dialog_id = "info"
ui:show_dialog("Widget",names[get_checkbox_idx()[item_idx]])
end
end
--utilities-- --utilities--
function set_default_args() function set_default_args()
@@ -107,6 +117,7 @@ function get_buttons()
local buttons,colors = {},{} local buttons,colors = {},{}
local checkbox_idx = get_checkbox_idx() local checkbox_idx = get_checkbox_idx()
local radio_idx = get_radio_idx() local radio_idx = get_radio_idx()
for i = 1, #checkbox_idx do for i = 1, #checkbox_idx do
if radio_idx == 1 then if radio_idx == 1 then
table.insert(buttons, icons[checkbox_idx[i]]) table.insert(buttons, icons[checkbox_idx[i]])
@@ -119,5 +130,6 @@ function get_buttons()
table.insert(colors, "#909090") table.insert(colors, "#909090")
end end
end end
return buttons,colors return buttons,colors
end end