/* * Copyright 2023 jacqueline * * SPDX-License-Identifier: GPL-3.0-only */ #pragma once #include #include #include #include #include "lvgl.h" #include "database.hpp" #include "screen.hpp" namespace ui { namespace screens { class TrackBrowser : public Screen { public: TrackBrowser( std::weak_ptr db, const std::string& title, std::future*>&& initial_page); ~TrackBrowser() {} auto Tick() -> void override; auto OnItemSelected(lv_event_t* ev) -> void; auto OnItemClicked(lv_event_t* ev) -> void; private: enum Position { START = 0, END = 1, }; auto AddLoadingIndictor(Position pos) -> void; auto AddResults(Position pos, database::Result*) -> void; auto DropPage(Position pos) -> void; auto FetchNewPage(Position pos) -> void; auto GetNumRecords() -> std::size_t; auto GetItemIndex(lv_obj_t* obj) -> std::optional; auto GetRecordByIndex(std::size_t index) -> std::optional; std::weak_ptr db_; lv_obj_t* list_; lv_obj_t* loading_indicator_; std::optional loading_pos_; std::optional*>> loading_page_; std::deque>> current_pages_; }; } // namespace screens } // namespace ui