diff --git a/sharing/linux/tui/components/BUILD b/sharing/linux/tui/components/BUILD index b196a307..a12bc7d9 100644 --- a/sharing/linux/tui/components/BUILD +++ b/sharing/linux/tui/components/BUILD @@ -1,12 +1,20 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library") cc_library( - name = "file_icon", + name = "icons", srcs = [ "file_icon.cc", + "brand.cc", + "laptop_icon.cc", + "phone_icon.cc", + "tablet_icon.cc", ], hdrs = [ "file_icon.h", + "brand.h", + "laptop_icon.h", + "phone_icon.h", + "tablet_icon.h", ], deps = [ "@ftxui//:ftxui", @@ -14,18 +22,19 @@ cc_library( ) cc_library( - name = "brand", + name = "share_target", srcs = [ - "brand.cc", + "share_target.cc", ], hdrs = [ - "brand.h", + "share_target.h", ], deps = [ "@ftxui//:ftxui", + "//sharing/linux/tui:palette", + ":icons", ], ) - cc_library( name = "file_picker_card", srcs = [ @@ -35,7 +44,7 @@ cc_library( "file_picker_card.h", ], deps = [ - ":file_icon", + ":icons", "//sharing/linux/tui:file_picker", "//sharing/linux/tui:palette", "@ftxui//:ftxui", diff --git a/sharing/linux/tui/components/laptop_icon.cc b/sharing/linux/tui/components/laptop_icon.cc new file mode 100644 index 00000000..4c9d828d --- /dev/null +++ b/sharing/linux/tui/components/laptop_icon.cc @@ -0,0 +1,15 @@ +#include "sharing/linux/tui/components/laptop_icon.h" + +namespace nearby::sharing::linux_tui { +using namespace ftxui; + +Element Laptop() { + return vbox({ + text(" +========+ ") | center, + text(" | | ") | center, + text(" |________| ") | center, + text(" /--------\\ ") | center, + text("/__________\\") | center, + }); +} +} // namespace nearby::sharing::linux_tui diff --git a/sharing/linux/tui/components/laptop_icon.h b/sharing/linux/tui/components/laptop_icon.h new file mode 100644 index 00000000..93ec1b8d --- /dev/null +++ b/sharing/linux/tui/components/laptop_icon.h @@ -0,0 +1,10 @@ +#pragma once + +#include "ftxui/dom/elements.hpp" + +namespace nearby::sharing::linux_tui { +using namespace ftxui; + +Element Laptop(); + +} // namespace nearby::sharing::linux_tui diff --git a/sharing/linux/tui/components/phone_icon.cc b/sharing/linux/tui/components/phone_icon.cc new file mode 100644 index 00000000..0bcae284 --- /dev/null +++ b/sharing/linux/tui/components/phone_icon.cc @@ -0,0 +1,15 @@ +#include "sharing/linux/tui/components/phone_icon.h" + +namespace nearby::sharing::linux_tui { +using namespace ftxui; + +Element Phone() { + return vbox({ + text("______") | center, + text("| |") | center, + text("| |") | center, + text("| |") | center, + text("|____|") | center, + }); +} +} // namespace nearby::sharing::linux_tui diff --git a/sharing/linux/tui/components/phone_icon.h b/sharing/linux/tui/components/phone_icon.h new file mode 100644 index 00000000..40ef60b7 --- /dev/null +++ b/sharing/linux/tui/components/phone_icon.h @@ -0,0 +1,10 @@ +#pragma once + +#include "ftxui/dom/elements.hpp" + +namespace nearby::sharing::linux_tui { +using namespace ftxui; + +Element Phone(); + +} // namespace nearby::sharing::linux_tui diff --git a/sharing/linux/tui/components/share_target.cc b/sharing/linux/tui/components/share_target.cc new file mode 100644 index 00000000..147c6f23 --- /dev/null +++ b/sharing/linux/tui/components/share_target.cc @@ -0,0 +1,32 @@ +#include "ftxui/dom/elements.hpp" +#include "sharing/linux/tui/components/share_target.h" +#include "sharing/linux/tui/components/laptop_icon.h" +#include "sharing/linux/tui/components/phone_icon.h" +#include "sharing/linux/tui/components/tablet_icon.h" +#include "sharing/linux/tui/palette.h" + +namespace nearby::sharing::linux_tui { +using namespace ftxui; + +Element ShareTarget(std::string device_name, ShareTargetType device_type) { + Element icon; + switch (device_type) { + case ShareTargetType::kPhone: + icon = Phone(); + break; + case ShareTargetType::kTablet: + icon = Tablet(); + break; + default: + icon = Laptop(); + break; + } + return vbox( + {icon, separatorLight() | dim, + paragraph(device_name) | color(Palette::secondary) | bold | center + + }) | + size(WIDTH, EQUAL, 14) | border; +}; + +} // namespace nearby::sharing::linux_tui diff --git a/sharing/linux/tui/components/share_target.h b/sharing/linux/tui/components/share_target.h new file mode 100644 index 00000000..b5f72f42 --- /dev/null +++ b/sharing/linux/tui/components/share_target.h @@ -0,0 +1,30 @@ +#pragma once + +#include "ftxui/dom/elements.hpp" + +namespace nearby::sharing::linux_tui { +using namespace ftxui; + +enum class ShareTargetType { + // Unknown device type. + kUnknown = 0, + // A phone. + kPhone = 1, + // A tablet. + kTablet = 2, + // A laptop. + kLaptop = 3, + // A car. + kCar = 4, + // A foldable. + kFoldable = 5, + // An XR device. + kXR = 6, +}; + +Element ShareTarget( + std::string device_name, + ShareTargetType device_type + ); + +} // namespace nearby::sharing::linux_tui diff --git a/sharing/linux/tui/components/tablet_icon.cc b/sharing/linux/tui/components/tablet_icon.cc new file mode 100644 index 00000000..8f227c58 --- /dev/null +++ b/sharing/linux/tui/components/tablet_icon.cc @@ -0,0 +1,15 @@ +#include "sharing/linux/tui/components/tablet_icon.h" + +namespace nearby::sharing::linux_tui { +using namespace ftxui; + +Element Tablet() { + return vbox({ + text("____________") | center, + text("| |") | center, + text("| |") | center, + text("|__________|") | center, + text(" ") | center, + }); +} +} // namespace nearby::sharing::linux_tui diff --git a/sharing/linux/tui/components/tablet_icon.h b/sharing/linux/tui/components/tablet_icon.h new file mode 100644 index 00000000..752b2efe --- /dev/null +++ b/sharing/linux/tui/components/tablet_icon.h @@ -0,0 +1,10 @@ +#pragma once + +#include "ftxui/dom/elements.hpp" + +namespace nearby::sharing::linux_tui { +using namespace ftxui; + +Element Tablet(); + +} // namespace nearby::sharing::linux_tui diff --git a/sharing/linux/tui/ui/BUILD b/sharing/linux/tui/ui/BUILD index 0f06a9f1..f5301a5a 100644 --- a/sharing/linux/tui/ui/BUILD +++ b/sharing/linux/tui/ui/BUILD @@ -10,7 +10,7 @@ cc_library( ], deps = [ "@ftxui//:ftxui", - "//sharing/linux/tui/components:brand" + "//sharing/linux/tui/components:icons" ], ) @@ -24,7 +24,7 @@ cc_library( ], deps = [ "//sharing/linux/tui:palette", - "//sharing/linux/tui/components:file_icon", + "//sharing/linux/tui/components:icons", "@ftxui//:ftxui", ], ) @@ -39,6 +39,7 @@ cc_library( ], deps = [ "//sharing/linux/tui:palette", + "//sharing/linux/tui/components:share_target", "@ftxui//:ftxui", ], ) diff --git a/sharing/linux/tui/ui/file_selected_screen.cc b/sharing/linux/tui/ui/file_selected_screen.cc index 586c6713..f1a947fa 100644 --- a/sharing/linux/tui/ui/file_selected_screen.cc +++ b/sharing/linux/tui/ui/file_selected_screen.cc @@ -1,4 +1,5 @@ #include "sharing/linux/tui/ui/file_selected_screen.h" +#include "sharing/linux/tui/components/share_target.h" #include "sharing/linux/tui/palette.h" @@ -6,12 +7,21 @@ namespace nearby::sharing::linux_tui { using namespace ftxui; Element FileSelectedScreen(const std::string& selected_file) { + FlexboxConfig config; + config.direction = FlexboxConfig::Direction::Row; + config.wrap = FlexboxConfig::Wrap::Wrap; + config.gap_x = 2; + config.gap_y = 1; return vbox({ - text("File selected") | bold | center | color(Palette::primary), - separator(), - paragraph(selected_file) | center, - separatorEmpty(), - text("Press Backspace to choose another file") | dim | center, + flexbox({ + ShareTarget("Lasan's A55", ShareTargetType::kPhone), + ShareTarget("lasan-laptop", ShareTargetType::kLaptop), + ShareTarget("lasan-laptop", ShareTargetType::kLaptop), + ShareTarget("lasan-laptop", ShareTargetType::kLaptop), + ShareTarget("Lasan's S9+", ShareTargetType::kTablet), + ShareTarget("Lasan's S9+", ShareTargetType::kTablet), + + }, config) | flex }) | borderStyled(Palette::primary) | flex; }