Status bar consistency improvements

custom
ailurux 1 year ago
parent 0d0c4b2307
commit 01ae3fee30
  1. 228
      lua/browser.lua

@ -9,125 +9,131 @@ local playback = require("playback")
local theme = require("theme") local theme = require("theme")
local screen = require("screen") local screen = require("screen")
return screen:new { return screen:new{
createUi = function(self) createUi = function(self)
self.root = lvgl.Object(nil, { self.root = lvgl.Object(nil, {
flex = { flex = {
flex_direction = "column", flex_direction = "column",
flex_wrap = "wrap", flex_wrap = "wrap",
justify_content = "flex-start", justify_content = "flex-start",
align_items = "flex-start", align_items = "flex-start",
align_content = "flex-start", align_content = "flex-start"
}, },
w = lvgl.HOR_RES(), w = lvgl.HOR_RES(),
h = lvgl.VER_RES(), h = lvgl.VER_RES()
}) })
self.root:center() self.root:center()
self.status_bar = widgets.StatusBar(self.root, { self.status_bar = widgets.StatusBar(self.root, {
title = self.title, back_cb = backstack.pop,
}) title = self.title
})
if self.breadcrumb then local header = self.root:Object{
local header = self.root:Object { flex = {
flex = { flex_direction = "column",
flex_direction = "column", flex_wrap = "wrap",
flex_wrap = "wrap", justify_content = "flex-start",
justify_content = "flex-start", align_items = "flex-start",
align_items = "flex-start", align_content = "flex-start"
align_content = "flex-start", },
}, w = lvgl.HOR_RES(),
w = lvgl.HOR_RES(), h = lvgl.SIZE_CONTENT,
h = lvgl.SIZE_CONTENT, pad_left = 4,
pad_left = 4, pad_right = 4,
pad_right = 4, pad_bottom = 2,
pad_bottom = 2, bg_opa = lvgl.OPA(100),
bg_opa = lvgl.OPA(100), scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF
scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF, }
} theme.set_style(header, "header")
theme.set_style(header, "header")
if self.breadcrumb then
header:Label{
text = self.breadcrumb,
text_font = font.fusion_10
}
end
header:Label { local buttons = header:Object({
text = self.breadcrumb, flex = {
text_font = font.fusion_10, flex_direction = "row",
} flex_wrap = "wrap",
justify_content = "flex-end",
local buttons = header:Object({ align_items = "center",
flex = { align_content = "center"
flex_direction = "row", },
flex_wrap = "wrap", w = lvgl.PCT(100),
justify_content = "flex-end", h = lvgl.SIZE_CONTENT,
align_items = "center", pad_column = 4
align_content = "center", })
}, local original_iterator = self.iterator:clone()
w = lvgl.PCT(100), local enqueue = widgets.IconBtn(buttons, "//lua/img/enqueue.png", "Enqueue")
h = lvgl.SIZE_CONTENT, enqueue:onClicked(function()
pad_column = 4, queue.add(original_iterator)
}) playback.playing:set(true)
local original_iterator = self.iterator:clone() end)
local enqueue = widgets.IconBtn(buttons, "//lua/img/enqueue.png", "Enqueue") -- enqueue:add_flag(lvgl.FLAG.HIDDEN)
enqueue:onClicked(function() local play = widgets.IconBtn(buttons, "//lua/img/play_small.png", "Play")
queue.add(original_iterator) play:onClicked(function()
playback.playing:set(true) queue.clear()
end) queue.add(original_iterator)
-- enqueue:add_flag(lvgl.FLAG.HIDDEN) playback.playing:set(true)
local play = widgets.IconBtn(buttons, "//lua/img/play_small.png", "Play") backstack.push(playing)
play:onClicked(function() end)
queue.clear()
queue.add(original_iterator)
playback.playing:set(true)
backstack.push(playing)
end
)
end
self.list = lvgl.List(self.root, { self.list = lvgl.List(self.root, {
w = lvgl.PCT(100), w = lvgl.PCT(100),
h = lvgl.PCT(100), h = lvgl.PCT(100),
flex_grow = 1, flex_grow = 1,
scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF, scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF
}) })
local back = self.list:add_btn(nil, "< Back") -- local back = self.list:add_btn(nil, "< Back")
back:onClicked(backstack.pop) -- back:onClicked(backstack.pop)
back:add_style(styles.list_item) -- back:add_style(styles.list_item)
self.focused_item = 0 self.focused_item = 0
self.last_item = 0 self.last_item = 0
self.add_item = function(item) self.add_item = function(item)
if not item then return end if not item then
self.last_item = self.last_item + 1 return
local this_item = self.last_item end
local btn = self.list:add_btn(nil, tostring(item)) self.last_item = self.last_item + 1
btn:onClicked(function() local this_item = self.last_item
local contents = item:contents() local btn = self.list:add_btn(nil, tostring(item))
if type(contents) == "userdata" then btn:onClicked(function()
backstack.push(require("browser"):new { local contents = item:contents()
title = self.title, if type(contents) == "userdata" then
iterator = contents, backstack.push(require("browser"):new{
breadcrumb = tostring(item), title = self.title,
}) iterator = contents,
else breadcrumb = tostring(item)
queue.clear() })
queue.add(contents) else
playback.playing:set(true) queue.clear()
backstack.push(playing:new()) queue.add(contents)
playback.playing:set(true)
backstack.push(playing:new())
end
end)
btn:onevent(lvgl.EVENT.FOCUSED, function()
self.focused_item = this_item
if self.last_item - 5 < this_item then
self.add_item(self.iterator())
end
end)
btn:add_style(styles.list_item)
if this_item == 1 then
btn:focus()
end
end end
end)
btn:onevent(lvgl.EVENT.FOCUSED, function()
self.focused_item = this_item
if self.last_item - 5 < this_item then
self.add_item(self.iterator())
end
end)
btn:add_style(styles.list_item)
end
for _ = 1, 8 do for _ = 1, 8 do
local val = self.iterator() local val = self.iterator()
if not val then break end if not val then
self.add_item(val) break
end
self.add_item(val)
end
end end
end
} }

Loading…
Cancel
Save