add settings API
This commit is contained in:
@@ -47,26 +47,7 @@ function on_click(idx)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function on_long_click(idx)
|
function on_long_click(idx)
|
||||||
item_idx = idx
|
ui:show_toast(names[get_checkbox_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
|
end
|
||||||
|
|
||||||
function on_dialog_action(data)
|
function on_dialog_action(data)
|
||||||
@@ -74,20 +55,18 @@ function on_dialog_action(data)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if dialog_id == "widgets" then
|
|
||||||
local radio_idx = get_radio_idx()
|
local radio_idx = get_radio_idx()
|
||||||
local args = data
|
local args = data
|
||||||
table.insert(args, radio_idx)
|
table.insert(args, radio_idx)
|
||||||
settings:set(args)
|
settings:set(args)
|
||||||
elseif dialog_id == "style" then
|
|
||||||
local args = get_checkbox_idx()
|
|
||||||
table.insert(args, data)
|
|
||||||
settings:set(args)
|
|
||||||
end
|
|
||||||
|
|
||||||
on_resume()
|
on_resume()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function on_settings()
|
||||||
|
ui:show_checkbox_dialog("Select widgets", names, get_checkbox_idx())
|
||||||
|
end
|
||||||
|
|
||||||
--utilities--
|
--utilities--
|
||||||
|
|
||||||
function set_default_args()
|
function set_default_args()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
function on_resume()
|
function on_resume()
|
||||||
local s1 = {
|
local s1 = {
|
||||||
key1 = "value1",
|
key1 = "123",
|
||||||
key2 = "val ue 2",
|
key2 = "val ue 2",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8,11 +8,6 @@ function on_resume()
|
|||||||
|
|
||||||
local s2 = settings:get_kv()
|
local s2 = settings:get_kv()
|
||||||
|
|
||||||
ui:show_text("key1="..s2.key1.." ".."key2="..s2.key2)
|
ui:show_text("key1=\""..s2.key1.."\" ".."key2=\""..s2.key2.."\"")
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_settings()
|
|
||||||
local s = settings:get_kv()
|
|
||||||
|
|
||||||
ui:show_dialog("Settings", "key1="..s.key1.." ".."key2="..s.key2)
|
|
||||||
end
|
|
||||||
|
|||||||
Reference in New Issue
Block a user