feat: Search tab with character picker and unified tab bar navigation

Adds Search tab to MyLibraryActivity with character picker for building
search queries, result navigation with long press jump-to-end support,
and Bookmarks tab integration. Implements consistent tab bar navigation
across all tabs - pressing Up from top of any list enters tab bar mode
with visible cursor indicators, Left/Right switches tabs, Down enters
list at top, and Up jumps to bottom of list.
This commit is contained in:
cottongin 2026-01-28 02:20:48 -05:00
parent 69a26ccb0e
commit e1fcec7d69
No known key found for this signature in database
GPG Key ID: 0ECC91FE4655C262
2 changed files with 1085 additions and 41 deletions

File diff suppressed because it is too large Load Diff

View File

@ -19,9 +19,25 @@ struct ThumbExistsCache {
bool exists = false; // Whether thumbnail exists
};
// Search result for the Search tab
struct SearchResult {
std::string path;
std::string title;
std::string author;
int matchScore = 0; // Higher = better match
};
// Book with bookmarks info for the Bookmarks tab
struct BookmarkedBook {
std::string path;
std::string title;
std::string author;
int bookmarkCount = 0;
};
class MyLibraryActivity final : public Activity {
public:
enum class Tab { Recent, Lists, Files };
enum class Tab { Recent, Lists, Bookmarks, Search, Files };
enum class UIState { Normal, ActionMenu, Confirming, ListActionMenu, ListConfirmingDelete, ClearAllRecentsConfirming };
enum class ActionType { Archive, Delete, RemoveFromRecents, ClearAllRecents };
@ -32,6 +48,7 @@ class MyLibraryActivity final : public Activity {
Tab currentTab = Tab::Recent;
int selectorIndex = 0;
bool updateRequired = false;
bool inTabBar = false; // true = focus on tab bar for switching tabs (all tabs)
// Action menu state
UIState uiState = UIState::Normal;
@ -61,6 +78,17 @@ class MyLibraryActivity final : public Activity {
int listMenuSelection = 0; // 0 = Pin/Unpin, 1 = Delete
std::string listActionTargetName;
// Bookmarks tab state
std::vector<BookmarkedBook> bookmarkedBooks;
// Search tab state
std::string searchQuery;
std::vector<SearchResult> searchResults;
std::vector<SearchResult> allBooks; // Cached index of all books
std::vector<char> searchCharacters; // Dynamic character set from library
int searchCharIndex = 0; // Current position in character picker
bool searchInResults = false; // true = navigating results, false = in character picker
// Files tab state (from FileSelectionActivity)
std::string basepath = "/";
std::vector<std::string> files;
@ -69,6 +97,7 @@ class MyLibraryActivity final : public Activity {
const std::function<void()> onGoHome;
const std::function<void(const std::string& path, Tab fromTab)> onSelectBook;
const std::function<void(const std::string& listName)> onSelectList;
const std::function<void(const std::string& path, const std::string& title)> onSelectBookmarkedBook;
// Number of items that fit on a page
int getPageItems() const;
@ -79,6 +108,9 @@ class MyLibraryActivity final : public Activity {
// Data loading
void loadRecentBooks();
void loadLists();
void loadBookmarkedBooks();
void loadAllBooks();
void updateSearchResults();
void loadFiles();
size_t findEntry(const std::string& name) const;
@ -88,10 +120,16 @@ class MyLibraryActivity final : public Activity {
void render() const;
void renderRecentTab() const;
void renderListsTab() const;
void renderBookmarksTab() const;
void renderSearchTab() const;
void renderFilesTab() const;
void renderActionMenu() const;
void renderConfirmation() const;
// Search character picker helpers
void buildSearchCharacters();
void renderCharacterPicker(int y) const;
// Action handling
void openActionMenu();
void executeAction();
@ -114,13 +152,15 @@ class MyLibraryActivity final : public Activity {
const std::function<void()>& onGoHome,
const std::function<void(const std::string& path, Tab fromTab)>& onSelectBook,
const std::function<void(const std::string& listName)>& onSelectList,
const std::function<void(const std::string& path, const std::string& title)>& onSelectBookmarkedBook = nullptr,
Tab initialTab = Tab::Recent, std::string initialPath = "/")
: Activity("MyLibrary", renderer, mappedInput),
currentTab(initialTab),
basepath(initialPath.empty() ? "/" : std::move(initialPath)),
onGoHome(onGoHome),
onSelectBook(onSelectBook),
onSelectList(onSelectList) {}
onSelectList(onSelectList),
onSelectBookmarkedBook(onSelectBookmarkedBook) {}
void onEnter() override;
void onExit() override;
void loop() override;