feat: fall back to index navigation when items fit on one page

This commit is contained in:
Istiak Tridip 2026-01-29 20:41:59 +06:00
parent 45bba9a822
commit 66e69e750e
No known key found for this signature in database

View File

@ -90,6 +90,11 @@ int ButtonNavigator::previousIndex(const int currentIndex, const int totalItems)
int ButtonNavigator::nextPageIndex(const int currentIndex, const int totalItems, const int itemsPerPage) { int ButtonNavigator::nextPageIndex(const int currentIndex, const int totalItems, const int itemsPerPage) {
if (totalItems <= 0 || itemsPerPage <= 0) return 0; if (totalItems <= 0 || itemsPerPage <= 0) return 0;
// When items fit on one page, use index navigation instead
if (totalItems <= itemsPerPage) {
return nextIndex(currentIndex, totalItems);
}
const int lastPageIndex = (totalItems - 1) / itemsPerPage; const int lastPageIndex = (totalItems - 1) / itemsPerPage;
const int currentPageIndex = currentIndex / itemsPerPage; const int currentPageIndex = currentIndex / itemsPerPage;
@ -103,6 +108,11 @@ int ButtonNavigator::nextPageIndex(const int currentIndex, const int totalItems,
int ButtonNavigator::previousPageIndex(const int currentIndex, const int totalItems, const int itemsPerPage) { int ButtonNavigator::previousPageIndex(const int currentIndex, const int totalItems, const int itemsPerPage) {
if (totalItems <= 0 || itemsPerPage <= 0) return 0; if (totalItems <= 0 || itemsPerPage <= 0) return 0;
// When items fit on one page, use index navigation instead
if (totalItems <= itemsPerPage) {
return previousIndex(currentIndex, totalItems);
}
const int lastPageIndex = (totalItems - 1) / itemsPerPage; const int lastPageIndex = (totalItems - 1) / itemsPerPage;
const int currentPageIndex = currentIndex / itemsPerPage; const int currentPageIndex = currentIndex / itemsPerPage;