WIP: File browser, needs bug fixes
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
local lvgl = require("lvgl")
|
||||
local widgets = require("widgets")
|
||||
local backstack = require("backstack")
|
||||
local font = require("font")
|
||||
local queue = require("queue")
|
||||
local playing = require("playing")
|
||||
local styles = require("styles")
|
||||
local playback = require("playback")
|
||||
local theme = require("theme")
|
||||
local screen = require("screen")
|
||||
local filesystem = require("filesystem")
|
||||
|
||||
return screen:new{
|
||||
createUi = function(self)
|
||||
self.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()
|
||||
})
|
||||
self.root:center()
|
||||
|
||||
self.status_bar = widgets.StatusBar(self, {
|
||||
back_cb = backstack.pop,
|
||||
title = self.title
|
||||
})
|
||||
|
||||
local header = self.root:Object{
|
||||
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.SIZE_CONTENT,
|
||||
pad_left = 4,
|
||||
pad_right = 4,
|
||||
pad_bottom = 2,
|
||||
bg_opa = lvgl.OPA(100),
|
||||
scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF
|
||||
}
|
||||
theme.set_style(header, "header")
|
||||
|
||||
if self.breadcrumb then
|
||||
header:Label{
|
||||
text = self.breadcrumb,
|
||||
text_font = font.fusion_10
|
||||
}
|
||||
end
|
||||
|
||||
local recycle_list = widgets.RecyclerList(self.root, self.iterator, {
|
||||
callback = function(item)
|
||||
return function()
|
||||
local is_dir = item:is_directory()
|
||||
if is_dir then
|
||||
backstack.push(require("file_browser"):new{
|
||||
title = self.title,
|
||||
iterator = filesystem.iterator(tostring(item)),
|
||||
breadcrumb = tostring(item)
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
}
|
||||
@@ -5,6 +5,7 @@ local backstack = require("backstack")
|
||||
local browser = require("browser")
|
||||
local playing = require("playing")
|
||||
local styles = require("styles")
|
||||
local filesystem = require("filesystem")
|
||||
local screen = require("screen")
|
||||
|
||||
return widgets.MenuScreen:new {
|
||||
@@ -35,6 +36,15 @@ return widgets.MenuScreen:new {
|
||||
btn:add_style(styles.list_item)
|
||||
end
|
||||
|
||||
local files = list:add_btn(nil, "Files")
|
||||
files:onClicked(function()
|
||||
backstack.push(require("file_browser"):new {
|
||||
title = "Files",
|
||||
iterator = filesystem.iterator(""),
|
||||
})
|
||||
end)
|
||||
files:add_style(styles.list_item)
|
||||
|
||||
local settings = list:add_btn(nil, "Settings")
|
||||
settings:onClicked(function()
|
||||
backstack.push(require("settings"):new())
|
||||
|
||||
Reference in New Issue
Block a user