From 1fefd5791bea5ed6ca8b12bef52e284eca58c33f Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 22 Jul 2025 12:01:46 +0800 Subject: [PATCH] Add Time & Date widget --- community/time-date-widget.lua | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 community/time-date-widget.lua diff --git a/community/time-date-widget.lua b/community/time-date-widget.lua new file mode 100644 index 0000000..c0be1a4 --- /dev/null +++ b/community/time-date-widget.lua @@ -0,0 +1,41 @@ +-- name = "Time & Date" +-- description = "Simple widget showing current time and date" +-- author = "Evgeny Zobnin (zobnin@gmail.com) +-- type = "widget" +-- aio_version = "5.2.1" + +local function draw() + local now = os.date("*t") + local time = string.format("%02d:%02d", now.hour, now.min) + local date = os.date("%a, %d %b") + + gui{ + {"spacer", 2}, + {"text", time, { size = 40 }}, + {"text", date, { size = 20, gravity = "right|center_v" }}, + {"spacer", 2}, + }.render() +end + +function on_tick() + draw() +end + +function on_click(idx) + -- time + if idx == 2 then + intent:start_activity{ + action = "android.intent.action.SHOW_ALARMS" + } + return + end + + -- date + if idx == 3 then + intent:start_activity{ + action = "android.intent.action.MAIN", + category = "android.intent.category.APP_CALENDAR" + } + end +end +