summaryrefslogtreecommitdiff
path: root/cli/component.hpp
blob: a3960369b80fc7a79002530ba5066893c375503b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */
#pragma once

#include <optional>

#include <ftxui/component/event.hpp>
#include <ftxui/component/component.hpp>
#include <ftxui/dom/elements.hpp>

#include "katja/repository.hpp"

namespace katja
{
    class PackageListBase : public ftxui::ComponentBase
    {
        std::string title;
        const std::vector<package_identifier> packages;
        std::optional<std::size_t> selected;

    public:
        PackageListBase(const std::string& title, const std::vector<package_identifier>& packages = {});

        ftxui::Element OnRender() override;
        bool OnEvent(ftxui::Event event) override;
    };

    ftxui::Component PackageList(const std::string& title, const std::vector<package_identifier>& packages = {});
        
}