crosspoint-reader/src/activities/home/ListViewActivity.h

53 lines
1.5 KiB
C
Raw Normal View History

#pragma once
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <freertos/task.h>
#include <functional>
#include <string>
#include <vector>
#include "../Activity.h"
#include "BookListStore.h"
/**
* ListViewActivity - Displays the contents of a single book list
*
* Shows books in custom order with title, author, and thumbnail.
* Allows selecting a book to open in the reader.
*/
class ListViewActivity final : public Activity {
private:
TaskHandle_t displayTaskHandle = nullptr;
SemaphoreHandle_t renderingMutex = nullptr;
std::string listName;
BookList bookList;
int selectorIndex = 0;
bool updateRequired = false;
// Callbacks
const std::function<void()> onBack;
const std::function<void(const std::string& path)> onSelectBook;
// Pagination helpers
int getPageItems() const;
int getTotalPages() const;
int getCurrentPage() const;
// Rendering
static void taskTrampoline(void* param);
[[noreturn]] void displayTaskLoop();
void render() const;
public:
explicit ListViewActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& listName,
const std::function<void()>& onBack,
const std::function<void(const std::string& path)>& onSelectBook)
: Activity("ListView", renderer, mappedInput), listName(listName), onBack(onBack), onSelectBook(onSelectBook) {}
void onEnter() override;
void onExit() override;
void loop() override;
};