From fa290acf85a7e89d42fe95cbbd304aefb068cc21 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sun, 28 Nov 2021 22:44:02 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20update=20ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tui.cpp | 44 +++++++++++++++++++++----------------------- src/utils.cpp | 1 + src/utils.hpp | 5 ++--- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/tui.cpp b/src/tui.cpp index 3bc9dbb..7d583a1 100644 --- a/src/tui.cpp +++ b/src/tui.cpp @@ -1,4 +1,6 @@ #include "tui.hpp" +#include "definitions.hpp" + #include #include #include @@ -12,38 +14,34 @@ namespace tui { void init() noexcept { auto screen = ScreenInteractive::Fullscreen(); - auto button_ok = Button("Ok", screen.ExitLoopClosure()); - auto button_quit = Button("Quit", screen.ExitLoopClosure()); + /* clang-format off */ + auto button_option = ButtonOption(); + button_option.border = false; + auto button_ok = Button("OK", [=] { info("ok\n"); }, &button_option); + auto button_quit = Button("Quit", screen.ExitLoopClosure(), &button_option); + /* clang-format on */ - auto component = Container::Horizontal({ + auto container = Container::Horizontal({ button_ok, + Renderer([] { return filler() | size(WIDTH, GREATER_THAN, 3); }), button_quit, }); - auto dialog = vbox({ - text("TODO!!"), - separator(), - hbox({ - button_ok->Render(), - button_quit->Render(), - }), - }); - - // -------- Center Menu -------------- - /* clang-format off */ - auto center_dialog = hbox({ - filler(), - border(dialog), - filler(), - }) | vcenter; - /* clang-format on */ - - auto renderer = Renderer(component, [&] { + auto renderer = Renderer(container, [&] { return vbox({ + // -------- Title -------------- text("New CLI Installer") | bold, filler(), // -------- Center Menu -------------- - center_dialog | hcenter, + hbox({ + filler(), + border(vbox({ + text("TODO!!") | size(HEIGHT, GREATER_THAN, 5), + separator(), + container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25), + })), + filler(), + }) | center, filler(), }); }); diff --git a/src/utils.cpp b/src/utils.cpp index f6c656e..5e636a4 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include diff --git a/src/utils.hpp b/src/utils.hpp index 4e6e50c..43ac1b0 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -4,18 +4,17 @@ #include "definitions.hpp" #include -#include namespace utils { void print_banner() noexcept; -bool is_connected() noexcept; +[[nodiscard]] bool is_connected() noexcept; bool prompt_char(const char* prompt, const char* color = RESET, char* read = nullptr) noexcept; void clear_screen() noexcept; auto exec(const std::string_view& command) noexcept -> std::string; [[nodiscard]] bool check_root() noexcept; void id_system() noexcept; -bool handle_connection() noexcept; +[[nodiscard]] bool handle_connection() noexcept; void show_iwctl() noexcept; } // namespace utils