KeyValuePages: Handle not having anything to show slightly better (#7353)

By disabling the pagination buttons, and showing a specific label, like Menu (https://github.com/koreader/koreader/pull/7347#issuecomment-786768640)
pull/7355/head
NiLuJe 3 years ago committed by GitHub
parent 2e507a42a4
commit c2db948ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -625,21 +625,26 @@ function KeyValuePage:_populateItems()
end
-- update page information
self.page_info_text:setText(T(_("Page %1 of %2"), self.show_page, self.pages))
if self.pages > 1 then
self.page_info_text:enable()
if self.pages >= 1 then
self.page_info_text:setText(T(_("Page %1 of %2"), self.show_page, self.pages))
if self.pages > 1 then
self.page_info_text:enable()
else
self.page_info_text:disableWithoutDimming()
end
self.page_info_left_chev:show()
self.page_info_right_chev:show()
self.page_info_first_chev:show()
self.page_info_last_chev:show()
self.page_info_left_chev:enableDisable(self.show_page > 1)
self.page_info_right_chev:enableDisable(self.show_page < self.pages)
self.page_info_first_chev:enableDisable(self.show_page > 1)
self.page_info_last_chev:enableDisable(self.show_page < self.pages)
else
self.page_info_text:setText(_("No items"))
self.page_info_text:disableWithoutDimming()
end
self.page_info_left_chev:show()
self.page_info_right_chev:show()
self.page_info_first_chev:show()
self.page_info_last_chev:show()
self.page_info_left_chev:enableDisable(self.show_page > 1)
self.page_info_right_chev:enableDisable(self.show_page < self.pages)
self.page_info_first_chev:enableDisable(self.show_page > 1)
self.page_info_last_chev:enableDisable(self.show_page < self.pages)
UIManager:setDirty(self, function()
return "ui", self.dimen

@ -991,7 +991,7 @@ function Menu:updatePageInfo(select_number)
self.page_info_last_chev:enableDisable(self.page < self.page_num)
self.page_return_arrow:enableDisable(#self.paths > 0)
else
self.page_info_text:setText(_("No choices available"))
self.page_info_text:setText(_("No items"))
self.page_info_text:disableWithoutDimming()
end
end

@ -1,28 +0,0 @@
local tableutil = {}
--http://stackoverflow.com/questions/15706270/sort-a-table-in-lua
function tableutil.spairs(t, order)
-- collect the keys
local keys = {}
for k in pairs(t) do keys[#keys + 1] = k end
-- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys
if order then
table.sort(keys, function(a, b) return order(t, a, b) end)
else
table.sort(keys)
end
-- return the iterator function
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], t[keys[i]]
end
end
end
return tableutil
Loading…
Cancel
Save