finish refactor, add docs and CI
This commit is contained in:
@@ -1,86 +1,83 @@
|
||||
#pragma once
|
||||
#include <pu/Plutonium>
|
||||
|
||||
#include <nxst/domain/account.hpp>
|
||||
#include <nxst/ui/theme.hpp>
|
||||
#include <nxst/ui/ui_context.hpp>
|
||||
#include <nxst/domain/account.hpp>
|
||||
|
||||
namespace ui {
|
||||
|
||||
class HeaderBar {
|
||||
private:
|
||||
pu::ui::elm::Rectangle::Ref bg;
|
||||
pu::ui::elm::Rectangle::Ref divider;
|
||||
pu::ui::elm::TextBlock::Ref appName;
|
||||
pu::ui::elm::TextBlock::Ref subtitle;
|
||||
pu::ui::elm::Rectangle::Ref chipBg;
|
||||
pu::ui::elm::Image::Ref avatar;
|
||||
pu::ui::elm::TextBlock::Ref userName;
|
||||
class HeaderBar {
|
||||
private:
|
||||
pu::ui::elm::Rectangle::Ref bg;
|
||||
pu::ui::elm::Rectangle::Ref divider;
|
||||
pu::ui::elm::TextBlock::Ref appName;
|
||||
pu::ui::elm::TextBlock::Ref subtitle;
|
||||
pu::ui::elm::Rectangle::Ref chipBg;
|
||||
pu::ui::elm::Image::Ref avatar;
|
||||
pu::ui::elm::TextBlock::Ref userName;
|
||||
|
||||
public:
|
||||
HeaderBar(pu::ui::Layout* parent, const std::string& sub = "Save Transfer") {
|
||||
using namespace theme;
|
||||
public:
|
||||
HeaderBar(pu::ui::Layout* parent, const std::string& sub = "Save Transfer") {
|
||||
using namespace theme;
|
||||
|
||||
bg = pu::ui::elm::Rectangle::New(
|
||||
0, 0, layout::ScreenW, layout::HeaderH, color::BgSurface);
|
||||
divider = pu::ui::elm::Rectangle::New(
|
||||
0, layout::HeaderH - 1, layout::ScreenW, 1, color::Divider);
|
||||
bg = pu::ui::elm::Rectangle::New(0, 0, layout::ScreenW, layout::HeaderH, color::BgSurface);
|
||||
divider = pu::ui::elm::Rectangle::New(0, layout::HeaderH - 1, layout::ScreenW, 1, color::Divider);
|
||||
|
||||
appName = pu::ui::elm::TextBlock::New(space::lg, 8, "NXST");
|
||||
appName->SetFont(type::font(type::Title));
|
||||
appName->SetColor(color::TextPrimary);
|
||||
appName = pu::ui::elm::TextBlock::New(space::lg, 8, "NXST");
|
||||
appName->SetFont(type::font(type::Title));
|
||||
appName->SetColor(color::TextPrimary);
|
||||
|
||||
subtitle = pu::ui::elm::TextBlock::New(space::lg, 46, sub);
|
||||
subtitle->SetFont(type::font(type::Caption));
|
||||
subtitle->SetColor(color::TextMuted);
|
||||
subtitle = pu::ui::elm::TextBlock::New(space::lg, 46, sub);
|
||||
subtitle->SetFont(type::font(type::Caption));
|
||||
subtitle->SetColor(color::TextMuted);
|
||||
|
||||
const int chipW = 280;
|
||||
const int chipX = layout::ScreenW - chipW - space::lg;
|
||||
chipBg = pu::ui::elm::Rectangle::New(
|
||||
chipX, 16, chipW, 40,
|
||||
color::BgSurface2, radius::pill);
|
||||
chipBg->SetVisible(false);
|
||||
const int chipW = 280;
|
||||
const int chipX = layout::ScreenW - chipW - space::lg;
|
||||
chipBg = pu::ui::elm::Rectangle::New(chipX, 16, chipW, 40, color::BgSurface2, radius::pill);
|
||||
chipBg->SetVisible(false);
|
||||
|
||||
avatar = pu::ui::elm::Image::New(chipX + 4, 20, "");
|
||||
avatar->SetWidth(32);
|
||||
avatar->SetHeight(32);
|
||||
avatar->SetVisible(false);
|
||||
avatar = pu::ui::elm::Image::New(chipX + 4, 20, "");
|
||||
avatar->SetWidth(32);
|
||||
avatar->SetHeight(32);
|
||||
avatar->SetVisible(false);
|
||||
|
||||
userName = pu::ui::elm::TextBlock::New(chipX + 44, 24, "");
|
||||
userName->SetFont(type::font(type::Body));
|
||||
userName->SetColor(color::TextPrimary);
|
||||
userName->SetVisible(false);
|
||||
userName = pu::ui::elm::TextBlock::New(chipX + 44, 24, "");
|
||||
userName->SetFont(type::font(type::Body));
|
||||
userName->SetColor(color::TextPrimary);
|
||||
userName->SetVisible(false);
|
||||
|
||||
parent->Add(bg);
|
||||
parent->Add(divider);
|
||||
parent->Add(appName);
|
||||
parent->Add(subtitle);
|
||||
parent->Add(chipBg);
|
||||
parent->Add(avatar);
|
||||
parent->Add(userName);
|
||||
}
|
||||
parent->Add(bg);
|
||||
parent->Add(divider);
|
||||
parent->Add(appName);
|
||||
parent->Add(subtitle);
|
||||
parent->Add(chipBg);
|
||||
parent->Add(avatar);
|
||||
parent->Add(userName);
|
||||
}
|
||||
|
||||
void SetUser(const std::optional<AccountUid>& uid, const std::string& name) {
|
||||
const bool show = uid.has_value();
|
||||
chipBg->SetVisible(show);
|
||||
userName->SetVisible(show);
|
||||
if (show) {
|
||||
userName->SetText(name);
|
||||
std::string path = Account::iconPath(*uid);
|
||||
if (!path.empty()) {
|
||||
avatar->SetImage(path);
|
||||
avatar->SetWidth(32);
|
||||
avatar->SetHeight(32);
|
||||
avatar->SetVisible(avatar->IsImageValid());
|
||||
} else {
|
||||
avatar->SetVisible(false);
|
||||
}
|
||||
void SetUser(const std::optional<AccountUid>& uid, const std::string& name) {
|
||||
const bool show = uid.has_value();
|
||||
chipBg->SetVisible(show);
|
||||
userName->SetVisible(show);
|
||||
if (show) {
|
||||
userName->SetText(name);
|
||||
std::string path = Account::iconPath(*uid);
|
||||
if (!path.empty()) {
|
||||
avatar->SetImage(path);
|
||||
avatar->SetWidth(32);
|
||||
avatar->SetHeight(32);
|
||||
avatar->SetVisible(avatar->IsImageValid());
|
||||
} else {
|
||||
avatar->SetVisible(false);
|
||||
}
|
||||
} else {
|
||||
avatar->SetVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SetSubtitle(const std::string& text) {
|
||||
subtitle->SetText(text);
|
||||
}
|
||||
};
|
||||
}
|
||||
void SetSubtitle(const std::string& text) {
|
||||
subtitle->SetText(text);
|
||||
}
|
||||
};
|
||||
} // namespace ui
|
||||
|
||||
Reference in New Issue
Block a user