format files

This commit is contained in:
Eliz Kilic 2026-01-23 12:25:39 +00:00
parent c505729558
commit 87873c5d05
3 changed files with 11 additions and 28 deletions

View File

@ -14,15 +14,10 @@ constexpr int MAX_RECENT_BOOKS = 10;
RecentBooksStore RecentBooksStore::instance;
void RecentBooksStore::addBook(
const std::string& path,
const std::string& title,
const std::string& author) {
void RecentBooksStore::addBook(const std::string& path, const std::string& title, const std::string& author) {
// Remove existing entry if present
auto it = std::find_if(
recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) {
return book.path == path;
});
auto it =
std::find_if(recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) { return book.path == path; });
if (it != recentBooks.end()) {
recentBooks.erase(it);
}
@ -58,10 +53,7 @@ bool RecentBooksStore::saveToFile() const {
}
outputFile.close();
Serial.printf(
"[%lu] [RBS] Recent books saved to file (%d entries)\n",
millis(),
count);
Serial.printf("[%lu] [RBS] Recent books saved to file (%d entries)\n", millis(), count);
return true;
}
@ -88,10 +80,7 @@ bool RecentBooksStore::loadFromFile() {
recentBooks.push_back({path, "", ""});
}
} else {
Serial.printf(
"[%lu] [RBS] Deserialization failed: Unknown version %u\n",
millis(),
version);
Serial.printf("[%lu] [RBS] Deserialization failed: Unknown version %u\n", millis(), version);
inputFile.close();
return false;
}
@ -112,9 +101,6 @@ bool RecentBooksStore::loadFromFile() {
}
inputFile.close();
Serial.printf(
"[%lu] [RBS] Recent books loaded from file (%d entries)\n",
millis(),
recentBooks.size());
Serial.printf("[%lu] [RBS] Recent books loaded from file (%d entries)\n", millis(), recentBooks.size());
return true;
}

View File

@ -23,10 +23,7 @@ class RecentBooksStore {
static RecentBooksStore& getInstance() { return instance; }
// Add a book to the recent list (moves to front if already exists)
void addBook(
const std::string& path,
const std::string& title,
const std::string& author);
void addBook(const std::string& path, const std::string& title, const std::string& author);
// Get the list of recent books (most recent first)
const std::vector<RecentBook>& getBooks() const { return recentBooks; }

View File

@ -16,7 +16,7 @@ namespace {
constexpr int TAB_BAR_Y = 15;
constexpr int CONTENT_START_Y = 60;
constexpr int LINE_HEIGHT = 30;
constexpr int RECENTS_LINE_HEIGHT = 65; // Increased for two-line items
constexpr int RECENTS_LINE_HEIGHT = 65; // Increased for two-line items
constexpr int LEFT_MARGIN = 20;
constexpr int RIGHT_MARGIN = 40; // Extra space for scroll indicator
@ -323,8 +323,8 @@ void MyLibraryActivity::renderRecentTab() const {
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
// Draw selection highlight
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * RECENTS_LINE_HEIGHT - 2, pageWidth - RIGHT_MARGIN,
RECENTS_LINE_HEIGHT);
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * RECENTS_LINE_HEIGHT - 2,
pageWidth - RIGHT_MARGIN, RECENTS_LINE_HEIGHT);
// Draw items
for (int i = pageStartIndex; i < bookCount && i < pageStartIndex + pageItems; i++) {
@ -346,7 +346,7 @@ void MyLibraryActivity::renderRecentTab() const {
}
}
auto truncatedTitle = renderer.truncatedText(UI_12_FONT_ID, title.c_str(), pageWidth - LEFT_MARGIN - RIGHT_MARGIN);
renderer.drawText(UI_12_FONT_ID, LEFT_MARGIN, y + 3, truncatedTitle.c_str(), i != selectorIndex);
renderer.drawText(UI_12_FONT_ID, LEFT_MARGIN, y + 2, truncatedTitle.c_str(), i != selectorIndex);
// Line 2: Author
if (!book.author.empty()) {