Rename widget to InfiniteList

custom
ailurux 12 months ago
parent ee5657cb44
commit 0062eb9a9e
  1. 2
      lua/browser.lua
  2. 2
      lua/file_browser.lua
  3. 20
      lua/widgets.lua

@ -81,7 +81,7 @@ return screen:new{
backstack.push(playing:new()) backstack.push(playing:new())
end) end)
local recycle_list = widgets.RecyclerList(self.root, self.iterator, { local infinite_list = widgets.InfiniteList(self.root, self.iterator, {
callback = function(item) callback = function(item)
return function() return function()
local contents = item:contents() local contents = item:contents()

@ -55,7 +55,7 @@ return screen:new{
} }
end end
local recycle_list = widgets.RecyclerList(self.root, self.iterator, { local infinite_list = widgets.InfiniteList(self.root, self.iterator, {
callback = function(item) callback = function(item)
return function() return function()
local is_dir = item:is_directory() local is_dir = item:is_directory()

@ -215,10 +215,10 @@ function widgets.IconBtn(parent, icon, text)
return btn return btn
end end
function widgets.RecyclerList(parent, iterator, opts) function widgets.InfiniteList(parent, iterator, opts)
local recycler_list = {} local infinite_list = {}
recycler_list.root = lvgl.List(parent, { infinite_list.root = lvgl.List(parent, {
w = lvgl.PCT(100), w = lvgl.PCT(100),
h = lvgl.PCT(100), h = lvgl.PCT(100),
flex_grow = 1, flex_grow = 1,
@ -230,13 +230,13 @@ function widgets.RecyclerList(parent, iterator, opts)
refreshing = true refreshing = true
local group = lvgl.group.get_default() local group = lvgl.group.get_default()
local focused_obj = group:get_focused() local focused_obj = group:get_focused()
local num_children = recycler_list.root:get_child_cnt() local num_children = infinite_list.root:get_child_cnt()
-- remove all children from the group and re-add them -- remove all children from the group and re-add them
for i = 0, num_children-1 do for i = 0, num_children-1 do
lvgl.group.remove_obj(recycler_list.root:get_child(i)) lvgl.group.remove_obj(infinite_list.root:get_child(i))
end end
for i = 0, num_children-1 do for i = 0, num_children-1 do
group:add_obj(recycler_list.root:get_child(i)) group:add_obj(infinite_list.root:get_child(i))
end end
if (focused_obj) then if (focused_obj) then
lvgl.group.focus_obj(focused_obj) lvgl.group.focus_obj(focused_obj)
@ -252,14 +252,14 @@ function widgets.RecyclerList(parent, iterator, opts)
local first_index = 0 local first_index = 0
local function remove_top() local function remove_top()
local obj = recycler_list.root:get_child(0) local obj = infinite_list.root:get_child(0)
obj:delete() obj:delete()
first_index = first_index + 1 first_index = first_index + 1
bck_iterator:next() bck_iterator:next()
end end
local function remove_last() local function remove_last()
local obj = recycler_list.root:get_child(-1) local obj = infinite_list.root:get_child(-1)
obj:delete() obj:delete()
last_index = last_index - 1 last_index = last_index - 1
fwd_iterator:prev() fwd_iterator:prev()
@ -278,7 +278,7 @@ function widgets.RecyclerList(parent, iterator, opts)
add_to_top = true add_to_top = true
end end
if this_item > last_index then last_index = index end if this_item > last_index then last_index = index end
local btn = recycler_list.root:add_btn(nil, tostring(item)) local btn = infinite_list.root:add_btn(nil, tostring(item))
if add_to_top then if add_to_top then
btn:move_to_index(0) btn:move_to_index(0)
end end
@ -323,7 +323,7 @@ function widgets.RecyclerList(parent, iterator, opts)
add_item(val, idx) add_item(val, idx)
end end
return recycler_list return infinite_list
end end
return widgets return widgets

Loading…
Cancel
Save