summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-10-01 17:10:50 +1000
committerjacqueline <me@jacqueline.id.au>2024-10-01 17:10:50 +1000
commit90b82e4ad6d923028db32bfd40e7a56289f2573e (patch)
tree157934b5d85a28de05341b1bf484e50580a8cfb4 /lua
parenta879e7b603e32b51d2883cb41c0c7027e9c6723c (diff)
downloadtangara-fw-90b82e4ad6d923028db32bfd40e7a56289f2573e.tar.gz
autoformat
Diffstat (limited to 'lua')
-rw-r--r--lua/browser.lua242
1 files changed, 121 insertions, 121 deletions
diff --git a/lua/browser.lua b/lua/browser.lua
index 013dcacf..d4fe759f 100644
--- a/lua/browser.lua
+++ b/lua/browser.lua
@@ -11,133 +11,133 @@ local screen = require("screen")
local database = require("database")
local img = require("images")
-return screen:new{
- create_ui = 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()
+return screen:new {
+ create_ui = 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
- })
+ 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,
- scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF
- }
- theme.set_subject(header, "header")
+ 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,
+ scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF
+ }
+ theme.set_subject(header, "header")
- if self.breadcrumb then
- header:Label{
- text = self.breadcrumb,
- text_font = font.fusion_10
- }
- end
-
- if (self.mediatype == database.MediaTypes.Music) then
- local buttons = header:Object({
- flex = {
- flex_direction = "row",
- flex_wrap = "wrap",
- justify_content = "space-between",
- align_items = "center",
- align_content = "center"
- },
- w = lvgl.PCT(100),
- h = lvgl.SIZE_CONTENT,
- pad_column = 4
- })
- local original_iterator = self.iterator:clone()
- local enqueue = widgets.IconBtn(buttons, img.enqueue, "Enqueue")
- enqueue:onClicked(function()
- queue.add(original_iterator)
- playback.playing:set(true)
- end)
- local shuffle_play = widgets.IconBtn(buttons, img.shuffleplay, "Shuffle")
- shuffle_play:onClicked(function()
- queue.clear()
- queue.random:set(true)
- queue.add(original_iterator)
- playback.playing:set(true)
- backstack.push(playing:new())
- end)
- -- enqueue:add_flag(lvgl.FLAG.HIDDEN)
- local play = widgets.IconBtn(buttons, img.play_small, "Play")
- play:onClicked(function()
- queue.clear()
- queue.random:set(false)
- queue.add(original_iterator)
- playback.playing:set(true)
- backstack.push(playing:new())
- end)
- end
+ if self.breadcrumb then
+ header:Label {
+ text = self.breadcrumb,
+ text_font = font.fusion_10
+ }
+ end
- local get_icon_func = nil
- local show_listened = self.mediatype == database.MediaTypes.Audiobook or self.mediatype == database.MediaTypes.Podcast
- if show_listened then
- get_icon_func = function (item)
- local contents = item:contents()
- if type(contents) == "userdata" then
- return
- else
- local track = database.track_by_id(contents)
- if not track then return end
- if (track.play_count > 0) then
- return img.listened
- else
- return img.unlistened
- end
- end
+ if (self.mediatype == database.MediaTypes.Music) then
+ local buttons = header:Object({
+ flex = {
+ flex_direction = "row",
+ flex_wrap = "wrap",
+ justify_content = "space-between",
+ align_items = "center",
+ align_content = "center"
+ },
+ w = lvgl.PCT(100),
+ h = lvgl.SIZE_CONTENT,
+ pad_column = 4
+ })
+ local original_iterator = self.iterator:clone()
+ local enqueue = widgets.IconBtn(buttons, img.enqueue, "Enqueue")
+ enqueue:onClicked(function()
+ queue.add(original_iterator)
+ playback.playing:set(true)
+ end)
+ local shuffle_play = widgets.IconBtn(buttons, img.shuffleplay, "Shuffle")
+ shuffle_play:onClicked(function()
+ queue.clear()
+ queue.random:set(true)
+ queue.add(original_iterator)
+ playback.playing:set(true)
+ backstack.push(playing:new())
+ end)
+ -- enqueue:add_flag(lvgl.FLAG.HIDDEN)
+ local play = widgets.IconBtn(buttons, img.play_small, "Play")
+ play:onClicked(function()
+ queue.clear()
+ queue.random:set(false)
+ queue.add(original_iterator)
+ playback.playing:set(true)
+ backstack.push(playing:new())
+ end)
+ end
- end
+ local get_icon_func = nil
+ local show_listened = self.mediatype == database.MediaTypes.Audiobook or
+ self.mediatype == database.MediaTypes.Podcast
+ if show_listened then
+ get_icon_func = function(item)
+ local contents = item:contents()
+ if type(contents) == "userdata" then
+ return
+ else
+ local track = database.track_by_id(contents)
+ if not track then return end
+ if (track.play_count > 0) then
+ return img.listened
+ else
+ return img.unlistened
+ end
end
+ end
+ end
- widgets.InfiniteList(self.root, self.iterator, {
- get_icon = get_icon_func,
- callback = function(item)
- return function()
- local contents = item:contents()
- if type(contents) == "userdata" then
- backstack.push(require("browser"):new{
- title = self.title,
- iterator = contents,
- mediatype = self.mediatype,
- breadcrumb = tostring(item)
- })
- else
- queue.clear()
- local track = database.track_by_id(contents)
- if (track) then
- queue.play_from(track.filepath, track.saved_position)
- else
- queue.add(contents)
- end
- playback.playing:set(true)
- backstack.push(playing:new())
- end
- end
+ widgets.InfiniteList(self.root, self.iterator, {
+ get_icon = get_icon_func,
+ callback = function(item)
+ return function()
+ local contents = item:contents()
+ if type(contents) == "userdata" then
+ backstack.push(require("browser"):new {
+ title = self.title,
+ iterator = contents,
+ mediatype = self.mediatype,
+ breadcrumb = tostring(item)
+ })
+ else
+ queue.clear()
+ local track = database.track_by_id(contents)
+ if (track) then
+ queue.play_from(track.filepath, track.saved_position)
+ else
+ queue.add(contents)
end
- })
- end
+ playback.playing:set(true)
+ backstack.push(playing:new())
+ end
+ end
+ end
+ })
+ end
}