Convert the main menu screen to lua lol

This commit is contained in:
jacqueline
2023-11-12 19:14:09 +11:00
parent 8471046a95
commit 8a0a167adb
206 changed files with 42303 additions and 183 deletions
+1
View File
@@ -0,0 +1 @@
require("main_menu"):Create()
+47
View File
@@ -0,0 +1,47 @@
local lvgl = require("lvgl")
local widgets = require("widgets")
local legacy_ui = require("legacy_ui")
local database = require("database")
local main_menu = {}
function main_menu:Create()
local root = lvgl.Object(nil, {
flex = {
flex_direction = "column",
flex_wrap = "wrap",
justify_content = "flex-start",
align_items = "flex-start",
align_content = "flex-start",
},
w = lvgl.HOR_RES(),
h = lvgl.VER_RES(),
})
root:center()
widgets.StatusBar(root, {})
local list = lvgl.List(root, {
w = lvgl.PCT(100),
h = lvgl.PCT(100),
flex_grow = 1,
})
list:add_btn(nil, "Now Playing"):onClicked(function()
legacy_ui.open_now_playing();
end)
local indexes = database.get_indexes()
for id, name in ipairs(indexes) do
local btn = list:add_btn(nil, name)
btn:onClicked(function()
legacy_ui.open_browse(id);
end)
end
list:add_btn(nil, "Settings"):onClicked(function()
legacy_ui.open_settings();
end)
end
return main_menu
+37
View File
@@ -0,0 +1,37 @@
local lvgl = require("lvgl")
local widgets = {}
function widgets.StatusBar(parent)
local container = parent:Object {
flex = {
flex_direction = "row",
justify_content = "flex-start",
align_items = "center",
align_content = "center",
},
w = lvgl.HOR_RES(),
h = 16,
}
container:Label {
w = lvgl.SIZE_CONTENT,
h = 12,
text = "<",
}
container:Label {
w = lvgl.PCT(100),
h = 16,
text = "cool title",
flex_grow = 1,
}
container:Label {
w = lvgl.SIZE_CONTENT,
h = 16,
text = "69%",
}
end
return widgets