From 34cae4e6e4bb00b3453bcdab084368a949c908a4 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 5 Jan 2024 10:38:35 +1100 Subject: add an alerts module for lua, and implement a volume indicator with it --- lua/main.lua | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/main.lua b/lua/main.lua index f2cbda3a..cd4bea3c 100644 --- a/lua/main.lua +++ b/lua/main.lua @@ -1,4 +1,36 @@ -require("font") +local font = require("font") +local vol = require("volume") + +-- Set up property bindings that are used across every screen. +GLOBAL_BINDINGS = { + vol.current_pct:bind(function(pct) + require("alerts").show(function() + local container = lvgl.Object(nil, { + w = lvgl.PCT(80), + h = lvgl.SIZE_CONTENT, + flex = { + flex_direction = "column", + justify_content = "center", + align_items = "center", + align_content = "center", + }, + bg_opa = lvgl.OPA(100), + bg_color = "#fafafa", + }) + container:Label { + text = string.format("Volume %i%%", pct), + text_font = font.fusion_10 + } + container:Bar { + w = lvgl.PCT(100), + h = 8, + range = { min = 0, max = 100 }, + value = pct, + } + container:center() + end) + end), +} local backstack = require("backstack") local main_menu = require("main_menu") -- cgit v1.2.3