added share targets ui and custom icons

This commit is contained in:
Lasan Mahaliyana
2026-06-21 10:03:27 +05:30
parent 86474f15bc
commit d8a64867be
11 changed files with 170 additions and 13 deletions
+15 -6
View File
@@ -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",
@@ -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
@@ -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
@@ -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
+10
View File
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
+3 -2
View File
@@ -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",
],
)
+15 -5
View File
@@ -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;
}