Adds bookmark add/remove functionality to EpubReaderActivity and base ReaderActivity, with visual indicator for bookmarked pages.
42 lines
1.8 KiB
C++
42 lines
1.8 KiB
C++
#pragma once
|
|
#include <memory>
|
|
|
|
#include "../ActivityWithSubactivity.h"
|
|
#include "activities/home/MyLibraryActivity.h"
|
|
|
|
class Epub;
|
|
class Txt;
|
|
|
|
class ReaderActivity final : public ActivityWithSubactivity {
|
|
std::string initialBookPath;
|
|
std::string currentBookPath; // Track current book path for navigation
|
|
MyLibraryActivity::Tab libraryTab; // Track which tab to return to
|
|
const std::function<void()> onGoBack;
|
|
const std::function<void(const std::string&, MyLibraryActivity::Tab)> onGoToLibrary;
|
|
const std::function<void()> onGoToClearCache;
|
|
const std::function<void()> onGoToSettings;
|
|
static std::unique_ptr<Epub> loadEpub(const std::string& path);
|
|
static std::unique_ptr<Txt> loadTxt(const std::string& path);
|
|
static bool isTxtFile(const std::string& path);
|
|
|
|
static std::string extractFolderPath(const std::string& filePath);
|
|
void goToLibrary(const std::string& fromBookPath = "");
|
|
void onGoToEpubReader(std::unique_ptr<Epub> epub);
|
|
void onGoToTxtReader(std::unique_ptr<Txt> txt);
|
|
|
|
public:
|
|
explicit ReaderActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::string initialBookPath,
|
|
MyLibraryActivity::Tab libraryTab, const std::function<void()>& onGoBack,
|
|
const std::function<void(const std::string&, MyLibraryActivity::Tab)>& onGoToLibrary,
|
|
const std::function<void()>& onGoToClearCache = nullptr,
|
|
const std::function<void()>& onGoToSettings = nullptr)
|
|
: ActivityWithSubactivity("Reader", renderer, mappedInput),
|
|
initialBookPath(std::move(initialBookPath)),
|
|
libraryTab(libraryTab),
|
|
onGoBack(onGoBack),
|
|
onGoToLibrary(onGoToLibrary),
|
|
onGoToClearCache(onGoToClearCache),
|
|
onGoToSettings(onGoToSettings) {}
|
|
void onEnter() override;
|
|
};
|