diff options
| author | ailurux <ailurux@noreply.codeberg.org> | 2025-02-05 04:56:06 +0000 |
|---|---|---|
| committer | ailurux <ailurux@noreply.codeberg.org> | 2025-02-05 04:56:06 +0000 |
| commit | 407c2f36f5dd6971d588f76ba5e426240f6c4131 (patch) | |
| tree | 811cc15ce41b7a086bf6e82dd4cbbd9b9674f135 /lua/main_menu.lua | |
| parent | ebadc83f785da9a24cdcaba774613a1cebfb084d (diff) | |
| parent | 342726a9fc432650adb2e2de16fed02654f4d30d (diff) | |
| download | tangara-fw-407c2f36f5dd6971d588f76ba5e426240f6c4131.tar.gz | |
Merge pull request 'Playlist Browser' (#228) from slord/tangara-fw:playlist-browser into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/228
Diffstat (limited to 'lua/main_menu.lua')
| -rw-r--r-- | lua/main_menu.lua | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lua/main_menu.lua b/lua/main_menu.lua index 3b512d72..8754df85 100644 --- a/lua/main_menu.lua +++ b/lua/main_menu.lua @@ -11,7 +11,6 @@ local browser = require("browser") local playing = require("playing") local styles = require("styles") local filesystem = require("filesystem") -local screen = require("screen") local font = require("font") local theme = require("theme") local img = require("images") @@ -129,6 +128,15 @@ return widgets.MenuScreen:new { }) end + local playlist_btn = indexes_list:add_btn(nil, "Playlists") + playlist_btn:onClicked(function() + backstack.push(require("playlist_browser"):new { + title = "Playlists", + iterator = filesystem.iterator("/Playlists") + }) + end) + playlist_btn:add_style(styles.list_item) + local function show_no_indexes(msg) indexes_list:add_flag(lvgl.FLAG.HIDDEN) no_indexes_container:clear_flag(lvgl.FLAG.HIDDEN) @@ -144,6 +152,14 @@ return widgets.MenuScreen:new { end end + local function hide_playlist_listing() + playlist_btn:add_flag(lvgl.FLAG.HIDDEN) + end + + local function show_playlist_listing() + playlist_btn:clear_flag(lvgl.FLAG.HIDDEN) + end + local function update_visible_indexes() local has_valid_index = false for _, idx in ipairs(indexes) do @@ -157,6 +173,13 @@ return widgets.MenuScreen:new { end if has_valid_index then hide_no_indexes() + + -- If we have valid indexes, then also check for playlists + if filesystem.iterator("/Playlists/"):next() == nil then + hide_playlist_listing() + else + show_playlist_listing() + end else if require("database").updating:get() then show_no_indexes("The database is updating for the first time. Please wait.") |
