summaryrefslogtreecommitdiff
path: root/lua/main.lua
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-04-02 11:13:50 +1100
committerailurux <ailuruxx@gmail.com>2024-04-02 11:13:50 +1100
commite20ebe7574db5aedc73f07b7bb3a0a01eae93c84 (patch)
tree34c93ec8a80e282f3ce3e47dd60c41e46de0f8b3 /lua/main.lua
parenta750af35aa6afda40aadca8f7cf8db75f41a43b2 (diff)
parent0d0c4b2307cac8436fea7276956f293262b265ed (diff)
downloadtangara-fw-e20ebe7574db5aedc73f07b7bb3a0a01eae93c84.tar.gz
Merge branch 'main' into lua-volume
Diffstat (limited to 'lua/main.lua')
-rw-r--r--lua/main.lua24
1 files changed, 22 insertions, 2 deletions
diff --git a/lua/main.lua b/lua/main.lua
index 5cbbf0a6..dc73c964 100644
--- a/lua/main.lua
+++ b/lua/main.lua
@@ -1,8 +1,17 @@
local font = require("font")
local vol = require("volume")
+local theme = require("theme")
+local controls = require("controls")
+local time = require("time")
+
+local lock_time = time.ticks()
+
+local theme_dark = require("theme_dark")
+theme.set(theme_dark)
-- Set up property bindings that are used across every screen.
GLOBAL_BINDINGS = {
+ -- Show an alert with the current volume whenever the volume changes
vol.current_pct:bind(function(pct)
require("alerts").show(function()
local container = lvgl.Object(nil, {
@@ -14,11 +23,10 @@ GLOBAL_BINDINGS = {
align_items = "center",
align_content = "center",
},
- bg_opa = lvgl.OPA(100),
- bg_color = "#fafafa",
radius = 8,
pad_all = 2,
})
+ theme.set_style(container, "pop_up")
container:Label {
text = string.format("Volume %i%%", pct),
text_font = font.fusion_10
@@ -32,6 +40,18 @@ GLOBAL_BINDINGS = {
container:center()
end)
end),
+ -- When the device has been locked for a while, default to showing the now
+ -- playing screen after unlocking.
+ controls.lock_switch:bind(function(locked)
+ if locked then
+ lock_time = time.ticks()
+ elseif time.ticks() - lock_time > 8000 then
+ local queue = require("queue")
+ if queue.size:get() > 0 then
+ require("playing"):pushIfNotShown()
+ end
+ end
+ end),
}
local backstack = require("backstack")