diff options
Diffstat (limited to 'cli/page.hpp')
| -rw-r--r-- | cli/page.hpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/cli/page.hpp b/cli/page.hpp new file mode 100644 index 0000000..66ea8a0 --- /dev/null +++ b/cli/page.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include <ftxui/component/event.hpp> +#include <ftxui/component/component_base.hpp> +#include <ftxui/component/component.hpp> + +#include "katja/repository.hpp" +#include "katja/database.hpp" + +#include "component.hpp" + +namespace katja +{ + class PageBase : public ftxui::ComponentBase + { + public: + virtual void Load() = 0; + }; + + using Page = std::shared_ptr<PageBase>; + using Pages = std::vector<Page>; + + class ScreenContainer final : public ftxui::ComponentBase + { + int menu_selected{ 0 }; + ftxui::Component menu; + ftxui::Component content; + std::vector<std::string> menu_entries; + Pages menu_pages; + std::function<void()> on_enter; + + public: + ScreenContainer(std::vector<std::pair<std::string, Page>> pages, std::function<void()> on_enter); + + ftxui::Element OnRender() override; + bool OnEvent(ftxui::Event event) override; + }; + + ftxui::Component Screen(std::vector<std::pair<std::string, Page>> pages, std::function<void()> on_enter); + + class WelcomePage final : public PageBase + { + public: + void Load() override; + ftxui::Element OnRender() override; + }; + + class UpdatesPage final : public PageBase + { + ftxui::Component updatable = PackageList("Updates"); + std::shared_ptr<struct repository> repository; + package_database database; + + public: + UpdatesPage(std::shared_ptr<struct repository> repository, package_database database); + + void Load() override; + ftxui::Element OnRender() override; + }; + + class SearchPage final : public PageBase + { + std::string needle; + ftxui::Component search_input; + ftxui::Component type_input; + std::shared_ptr<struct repository> repository; + std::string architecture; + ftxui::Component search_results = PackageList("Results"); + int search_type{ 0 }; + + public: + SearchPage(std::shared_ptr<struct repository> repository, const std::string& architecture); + + void Load() override; + ftxui::Element OnRender() override; + bool OnEvent(ftxui::Event event) override; + }; +} |
