Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw

custom
jacqueline 11 months ago
commit ddc03204e1
  1. 20
      lua/widgets.lua

@ -265,8 +265,6 @@ function widgets.InfiniteList(parent, iterator, opts)
fwd_iterator:prev() fwd_iterator:prev()
end end
local moving_back = false
local function add_item(item, index) local function add_item(item, index)
if not item then if not item then
return return
@ -288,7 +286,7 @@ function widgets.InfiniteList(parent, iterator, opts)
end end
btn:onevent(lvgl.EVENT.FOCUSED, function() btn:onevent(lvgl.EVENT.FOCUSED, function()
if refreshing then return end if refreshing then return end
if this_item > last_selected and this_item - first_index > 5 then if this_item > last_selected and this_item - first_index > 3 then
-- moving forward -- moving forward
local to_add = fwd_iterator:next() local to_add = fwd_iterator:next()
if to_add then if to_add then
@ -298,18 +296,16 @@ function widgets.InfiniteList(parent, iterator, opts)
end end
if this_item < last_selected then if this_item < last_selected then
-- moving backward -- moving backward
if (last_index - first_index > 10) then if (first_index > 0 and last_index - this_item > 3) then
local to_add = bck_iterator:prev();
if to_add then
remove_last() remove_last()
end add_item(to_add, first_index-1)
if (first_index > 0 and this_item - first_index < 5) then refresh_group()
local to_add = bck_iterator:prev(); end
if to_add then end
add_item(to_add, first_index-1)
end
end
end end
last_selected = this_item last_selected = this_item
refresh_group()
end) end)
btn:add_style(styles.list_item) btn:add_style(styles.list_item)
return btn return btn

Loading…
Cancel
Save