diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-06-28 13:50:40 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-06-28 13:50:40 +1000 |
| commit | 9204b585aedd35f85d3c9118299459d3586cf499 (patch) | |
| tree | f01db6eaac4d40e799ad5677aae0e3a3d95d2b6c /lua | |
| parent | 624e4555ad8efb93ad018ac2b3866cff4f81f06a (diff) | |
| download | tangara-fw-9204b585aedd35f85d3c9118299459d3586cf499.tar.gz | |
show a message if the sd card is unmounted
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/main_menu.lua | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/lua/main_menu.lua b/lua/main_menu.lua index 5426ee0d..f3b7a042 100644 --- a/lua/main_menu.lua +++ b/lua/main_menu.lua @@ -90,26 +90,41 @@ return widgets.MenuScreen:new { -- a list of all available database indexes, but could also be the contents -- of the SD card root. - local list = lvgl.List(self.root, { - w = lvgl.PCT(100), - h = lvgl.PCT(100), - flex_grow = 1, - }) + if require("sd_card").mounted:get() then + local list = lvgl.List(self.root, { + w = lvgl.PCT(100), + h = lvgl.PCT(100), + flex_grow = 1, + }) - local indexes = database.indexes() - for _, idx in ipairs(indexes) do - local btn = list:add_btn(nil, tostring(idx)) - btn:onClicked(function() - backstack.push(browser:new { - title = tostring(idx), - iterator = idx:iter(), - }) - end) - btn:add_style(styles.list_item) - if not has_focus then - has_focus = true - btn:focus() + local indexes = database.indexes() + for _, idx in ipairs(indexes) do + local btn = list:add_btn(nil, tostring(idx)) + btn:onClicked(function() + backstack.push(browser:new { + title = tostring(idx), + iterator = idx:iter(), + }) + end) + btn:add_style(styles.list_item) + if not has_focus then + has_focus = true + btn:focus() + end end + else + local container = self.root:Object { + w = lvgl.PCT(100), + flex_grow = 1, + } + container:Label { + w = lvgl.PCT(100), + h = lvgl.SIZE_CONTENT, + text_align = 2, + long_mode = 0, + margin_all = 4, + text = "SD Card is not inserted or could not be opened.", + }:center(); end -- Finally, the bottom bar with icon buttons for other device features. |
