add settings API

This commit is contained in:
Evgeny
2021-08-31 19:43:38 +03:00
parent 7d03496bfc
commit 74d101c673
11 changed files with 92 additions and 72 deletions

View File

@@ -1,34 +1,34 @@
-- name = "Period progress"
-- description = "Shows period progress"
-- type = "widget"
-- author = "Nikolai Galashev"
-- version = "1.0"
-- name = "Period progress"
-- description = "Shows period progress"
-- type = "widget"
-- author = "Nikolai Galashev"
-- version = "1.0"
-- arguments_help = "Enter the title and the start and end date in this format: Title 2021 01 31 2021 09 25"
function on_resume()
if (next(aio:get_args()) == nil) then
function on_resume()
if (next(settings:get()) == nil) then
ui:show_text("Tap to enter date")
return
end
local params = aio:get_args()
start_period = get_time(params[2], params[3], params[4]);
local params = settings:get()
start_period = get_time(params[2], params[3], params[4]);
end_period = get_time(params[5], params[6], params[7]);
name_period = params[1]
current_time = os.time()
init_progressbar()
end
function on_click()
name_period = params[1]
current_time = os.time()
init_progressbar()
end
function on_click()
aio:show_args_dialog()
end
function get_time(y,m,d)
return os.time{day=d,month=m,year=y}
end
function get_time(y,m,d)
return os.time{day=d,month=m,year=y}
end
function init_progressbar()
percent = math.floor((current_time - start_period) / ((end_period - start_period) / 100))
ui:show_progress_bar(name_period..": "..percent.."%", current_time - start_period, end_period - start_period, "#7069f0ae")
percent = math.floor((current_time - start_period) / ((end_period - start_period) / 100))
ui:show_progress_bar(name_period..": "..percent.."%", current_time - start_period, end_period - start_period, "#7069f0ae")
end