Add update partial method for listview

This commit is contained in:
Ben 2024-06-02 04:22:07 +02:00
parent 3269df63d6
commit 0cb62033ef
Signed by: ben
GPG key ID: 0F54A7ED232D3319
2 changed files with 24 additions and 0 deletions

View file

@ -18,6 +18,10 @@ local function redrawLine(idx)
frame.setCursorPos(1, idx-paginationOffset+1)
if drawLine then
drawLine(frame, backingList[idx])
else
frame.setBackgroundColor(colors.red)
frame.clearLine()
frame.setBackgroundColor(colors.black)
end
end
end
@ -59,6 +63,10 @@ local function redraw()
end
backingIdx = backingIdx + 1
end
else
frame.setBackgroundColor(colors.red)
frame.clear()
frame.setBackgroundColor(colors.black)
end
end
@ -69,6 +77,20 @@ local function updatePage(newOffset)
end
end
local function updatePartial(filter)
if drawLine then
local tw, th = frame.getSize()
local backingIdx = paginationOffset
for idx = 1, th, 1 do
frame.setCursorPos(1, idx)
if backingList[backingIdx] ~= nil and filter(backingList[backingIdx]) then
drawLine(frame, backingList[backingIdx])
end
backingIdx = backingIdx + 1
end
end
end
return {
setTerm=setTerm,
@ -78,4 +100,5 @@ return {
clearFrom=clearFrom,
redraw=redraw,
updatePage=updatePage,
updatePartial=updatePartial,
}

View file

@ -101,6 +101,7 @@ local function onTouch(self, touch_x, touch_y)
else
permset.add(allowed_items, obj.answer.name)
end
listview.updatePartial(function (item) return item.answer ~= nil and item.answer.name == obj.answer.name end)
return true
end
end