diff options
| author | Eugen Wissner <belka@caraus.de> | 2025-04-05 14:23:44 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2025-04-05 14:23:44 +0200 |
| commit | 24ecc7becd7a59d151f7ae14645b7b762452b168 (patch) | |
| tree | afa91f3fae38ac87c1fbe5edb040eca462a3caf7 /cli/component.cpp | |
| parent | ff3c508ceb185d631aea7fed93329525d77a1704 (diff) | |
| download | kazbek-24ecc7becd7a59d151f7ae14645b7b762452b168.tar.gz | |
katja: Use the tab container for pages
Diffstat (limited to 'cli/component.cpp')
| -rw-r--r-- | cli/component.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cli/component.cpp b/cli/component.cpp index 9e0593e..4def946 100644 --- a/cli/component.cpp +++ b/cli/component.cpp @@ -2,16 +2,57 @@ namespace katja { + PageContainer::PageContainer(std::vector<std::pair<std::string, Page>> pages) + { + ftxui::Components menu_pages; + + std::transform(std::cbegin(pages), std::cend(pages), std::back_inserter(menu_entries), + [](const std::pair<std::string, Page>& pair) { return pair.first; }); + std::transform(std::cbegin(pages), std::cend(pages), std::back_inserter(menu_pages), + [](const std::pair<std::string, Page>& pair) { return pair.second; }); + + ftxui::MenuOption menu_option = ftxui::MenuOption::Horizontal(); + this->menu = ftxui::Menu(&this->menu_entries, &this->menu_selected, menu_option); + + this->content = ftxui::Container::Tab(menu_pages, &this->menu_selected); + } + + ftxui::Element PageContainer::Render() + { + return ftxui::vbox({ + this->menu->Render(), + this->content->Render() + }); + } + + bool PageContainer::OnEvent(ftxui::Event event) + { + if (event.character() == "q" && this->on_enter) + { + on_enter(); + return true; + } + return menu->OnEvent(event); + } + ftxui::Element WelcomePage::Render() { return ftxui::text("Select an action in the menu."); } + void WelcomePage::Load() + { + } + UpdatesPage::UpdatesPage(std::vector<package_identifier>&& updatable) : updatable(std::move(updatable)) { } + void UpdatesPage::Load() + { + } + ftxui::Element UpdatesPage::Render() { std::vector<std::shared_ptr<ftxui::Node>> lines; @@ -25,4 +66,8 @@ namespace katja return ftxui::window(summary, ftxui::vbox(lines)); } + + void SearchPage::Load() + { + } } |
