another stage of refactoring
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
#include <pu/Plutonium>
|
||||
|
||||
#include <nxst/ui/theme.hpp>
|
||||
|
||||
namespace ui {
|
||||
|
||||
class Card {
|
||||
public:
|
||||
pu::ui::elm::Rectangle::Ref bg;
|
||||
|
||||
Card(pu::ui::Layout* parent, int x, int y, int w, int h, pu::ui::Color color = theme::color::BgSurface,
|
||||
int rad = theme::radius::lg) {
|
||||
bg = pu::ui::elm::Rectangle::New(x, y, w, h, color, rad);
|
||||
parent->Add(bg);
|
||||
}
|
||||
};
|
||||
} // namespace ui
|
||||
@@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <nxst/ui/theme.hpp>
|
||||
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
#define BACKGROUND_COLOR theme::color::BgBase
|
||||
@@ -3,81 +3,80 @@
|
||||
|
||||
#include <nxst/domain/account.hpp>
|
||||
#include <nxst/ui/theme.hpp>
|
||||
#include <nxst/ui/ui_context.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());
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
avatar->SetVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SetSubtitle(const std::string& text) {
|
||||
subtitle->SetText(text);
|
||||
}
|
||||
};
|
||||
void SetSubtitle(const std::string& text) {
|
||||
subtitle->SetText(text);
|
||||
}
|
||||
};
|
||||
} // namespace ui
|
||||
|
||||
@@ -8,49 +8,49 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
struct Hint {
|
||||
std::string glyph;
|
||||
std::string label;
|
||||
};
|
||||
struct Hint {
|
||||
std::string glyph;
|
||||
std::string label;
|
||||
};
|
||||
|
||||
class HintBar {
|
||||
private:
|
||||
pu::ui::Layout* parent;
|
||||
pu::ui::elm::Rectangle::Ref bg;
|
||||
pu::ui::elm::Rectangle::Ref divider;
|
||||
std::vector<pu::ui::elm::TextBlock::Ref> labels;
|
||||
class HintBar {
|
||||
private:
|
||||
pu::ui::Layout* parent;
|
||||
pu::ui::elm::Rectangle::Ref bg;
|
||||
pu::ui::elm::Rectangle::Ref divider;
|
||||
std::vector<pu::ui::elm::TextBlock::Ref> labels;
|
||||
|
||||
public:
|
||||
HintBar(pu::ui::Layout* p) : parent(p) {
|
||||
using namespace theme;
|
||||
bg = pu::ui::elm::Rectangle::New(0, layout::ScreenH - layout::HintH, layout::ScreenW, layout::HintH,
|
||||
color::BgSurface);
|
||||
divider = pu::ui::elm::Rectangle::New(0, layout::ScreenH - layout::HintH, layout::ScreenW, 1,
|
||||
color::Divider);
|
||||
parent->Add(bg);
|
||||
parent->Add(divider);
|
||||
}
|
||||
|
||||
void SetHints(const std::vector<Hint>& hints) {
|
||||
using namespace theme;
|
||||
for (auto& l : labels)
|
||||
l->SetVisible(false);
|
||||
labels.clear();
|
||||
|
||||
int x = layout::ScreenW - space::lg;
|
||||
int y = layout::ScreenH - layout::HintH + 18;
|
||||
for (auto it = hints.rbegin(); it != hints.rend(); ++it) {
|
||||
std::string text = it->glyph + " " + it->label;
|
||||
auto tb = pu::ui::elm::TextBlock::New(0, y, text);
|
||||
tb->SetFont(type::font(type::Label));
|
||||
tb->SetColor(color::TextSecondary);
|
||||
int w = tb->GetWidth();
|
||||
x -= w;
|
||||
tb->SetX(x);
|
||||
x -= space::xl;
|
||||
parent->Add(tb);
|
||||
labels.push_back(tb);
|
||||
public:
|
||||
HintBar(pu::ui::Layout* p) : parent(p) {
|
||||
using namespace theme;
|
||||
bg = pu::ui::elm::Rectangle::New(0, layout::ScreenH - layout::HintH, layout::ScreenW,
|
||||
layout::HintH, color::BgSurface);
|
||||
divider = pu::ui::elm::Rectangle::New(0, layout::ScreenH - layout::HintH, layout::ScreenW, 1,
|
||||
color::Divider);
|
||||
parent->Add(bg);
|
||||
parent->Add(divider);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void SetHints(const std::vector<Hint>& hints) {
|
||||
using namespace theme;
|
||||
for (auto& l : labels)
|
||||
l->SetVisible(false);
|
||||
labels.clear();
|
||||
|
||||
int x = layout::ScreenW - space::lg;
|
||||
int y = layout::ScreenH - layout::HintH + 18;
|
||||
for (auto it = hints.rbegin(); it != hints.rend(); ++it) {
|
||||
std::string text = it->glyph + " " + it->label;
|
||||
auto tb = pu::ui::elm::TextBlock::New(0, y, text);
|
||||
tb->SetFont(type::font(type::Label));
|
||||
tb->SetColor(color::TextSecondary);
|
||||
int w = tb->GetWidth();
|
||||
x -= w;
|
||||
tb->SetX(x);
|
||||
x -= space::xl;
|
||||
parent->Add(tb);
|
||||
labels.push_back(tb);
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace ui
|
||||
|
||||
+59
-59
@@ -5,75 +5,75 @@
|
||||
#include <pu/Plutonium>
|
||||
|
||||
namespace theme {
|
||||
using pu::ui::Color;
|
||||
using pu::ui::Color;
|
||||
|
||||
namespace color {
|
||||
constexpr Color BgBase{0x10, 0x14, 0x1C, 0xFF};
|
||||
constexpr Color BgSurface{0x18, 0x1F, 0x2A, 0xFF};
|
||||
constexpr Color BgSurface2{0x22, 0x2B, 0x39, 0xFF};
|
||||
constexpr Color Scrim{0x00, 0x00, 0x00, 0xB8};
|
||||
namespace color {
|
||||
constexpr Color BgBase{0x10, 0x14, 0x1C, 0xFF};
|
||||
constexpr Color BgSurface{0x18, 0x1F, 0x2A, 0xFF};
|
||||
constexpr Color BgSurface2{0x22, 0x2B, 0x39, 0xFF};
|
||||
constexpr Color Scrim{0x00, 0x00, 0x00, 0xB8};
|
||||
|
||||
constexpr Color Primary{0xE2, 0x4B, 0x55, 0xFF};
|
||||
constexpr Color PrimaryDim{0x9C, 0x33, 0x3A, 0xFF};
|
||||
constexpr Color Accent{0x4A, 0xC2, 0xE0, 0xFF};
|
||||
constexpr Color Primary{0xE2, 0x4B, 0x55, 0xFF};
|
||||
constexpr Color PrimaryDim{0x9C, 0x33, 0x3A, 0xFF};
|
||||
constexpr Color Accent{0x4A, 0xC2, 0xE0, 0xFF};
|
||||
|
||||
constexpr Color TextPrimary{0xF2, 0xF4, 0xF8, 0xFF};
|
||||
constexpr Color TextSecondary{0xB6, 0xBE, 0xCB, 0xFF};
|
||||
constexpr Color TextMuted{0x70, 0x7A, 0x8C, 0xFF};
|
||||
constexpr Color TextPrimary{0xF2, 0xF4, 0xF8, 0xFF};
|
||||
constexpr Color TextSecondary{0xB6, 0xBE, 0xCB, 0xFF};
|
||||
constexpr Color TextMuted{0x70, 0x7A, 0x8C, 0xFF};
|
||||
|
||||
constexpr Color Success{0x55, 0xC8, 0x8A, 0xFF};
|
||||
constexpr Color Error{0xE0, 0x6C, 0x6C, 0xFF};
|
||||
constexpr Color Warning{0xE6, 0xB4, 0x55, 0xFF};
|
||||
constexpr Color Success{0x55, 0xC8, 0x8A, 0xFF};
|
||||
constexpr Color Error{0xE0, 0x6C, 0x6C, 0xFF};
|
||||
constexpr Color Warning{0xE6, 0xB4, 0x55, 0xFF};
|
||||
|
||||
constexpr Color Divider{0x2A, 0x33, 0x42, 0xFF};
|
||||
constexpr Color FocusRing{0xE2, 0x4B, 0x55, 0xFF};
|
||||
} // namespace color
|
||||
constexpr Color Divider{0x2A, 0x33, 0x42, 0xFF};
|
||||
constexpr Color FocusRing{0xE2, 0x4B, 0x55, 0xFF};
|
||||
} // namespace color
|
||||
|
||||
namespace space {
|
||||
constexpr int xs = 4;
|
||||
constexpr int sm = 8;
|
||||
constexpr int md = 16;
|
||||
constexpr int lg = 24;
|
||||
constexpr int xl = 32;
|
||||
constexpr int xxl = 48;
|
||||
} // namespace space
|
||||
namespace space {
|
||||
constexpr int xs = 4;
|
||||
constexpr int sm = 8;
|
||||
constexpr int md = 16;
|
||||
constexpr int lg = 24;
|
||||
constexpr int xl = 32;
|
||||
constexpr int xxl = 48;
|
||||
} // namespace space
|
||||
|
||||
namespace radius {
|
||||
constexpr int sm = 6;
|
||||
constexpr int md = 12;
|
||||
constexpr int lg = 20;
|
||||
constexpr int pill = 9999;
|
||||
} // namespace radius
|
||||
namespace radius {
|
||||
constexpr int sm = 6;
|
||||
constexpr int md = 12;
|
||||
constexpr int lg = 20;
|
||||
constexpr int pill = 9999;
|
||||
} // namespace radius
|
||||
|
||||
namespace type {
|
||||
constexpr int Display = 38;
|
||||
constexpr int Title = 30;
|
||||
constexpr int Body = 25;
|
||||
constexpr int Label = 20;
|
||||
constexpr int Caption = 18;
|
||||
namespace type {
|
||||
constexpr int Display = 38;
|
||||
constexpr int Title = 30;
|
||||
constexpr int Body = 25;
|
||||
constexpr int Label = 20;
|
||||
constexpr int Caption = 18;
|
||||
|
||||
inline std::string font(int size) {
|
||||
return "DefaultFont@" + std::to_string(size);
|
||||
}
|
||||
} // namespace type
|
||||
inline std::string font(int size) {
|
||||
return "DefaultFont@" + std::to_string(size);
|
||||
}
|
||||
} // namespace type
|
||||
|
||||
namespace layout {
|
||||
constexpr int ScreenW = 1280;
|
||||
constexpr int ScreenH = 720;
|
||||
constexpr int HeaderH = 72;
|
||||
constexpr int HintH = 56;
|
||||
constexpr int ContentTop = HeaderH;
|
||||
constexpr int ContentH = ScreenH - HeaderH - HintH;
|
||||
} // namespace layout
|
||||
namespace layout {
|
||||
constexpr int ScreenW = 1280;
|
||||
constexpr int ScreenH = 720;
|
||||
constexpr int HeaderH = 72;
|
||||
constexpr int HintH = 56;
|
||||
constexpr int ContentTop = HeaderH;
|
||||
constexpr int ContentH = ScreenH - HeaderH - HintH;
|
||||
} // namespace layout
|
||||
|
||||
namespace motion {
|
||||
constexpr int FadeFrames = 20;
|
||||
constexpr int SlideFrames = 14;
|
||||
constexpr int SpinnerFrames = 72;
|
||||
} // namespace motion
|
||||
namespace motion {
|
||||
constexpr int FadeFrames = 20;
|
||||
constexpr int SlideFrames = 14;
|
||||
constexpr int SpinnerFrames = 72;
|
||||
} // namespace motion
|
||||
|
||||
namespace font {
|
||||
constexpr const char* Default = "Inter";
|
||||
constexpr const char* Medium = "InterMedium";
|
||||
} // namespace font
|
||||
namespace font {
|
||||
constexpr const char* Default = "Inter";
|
||||
constexpr const char* Medium = "InterMedium";
|
||||
} // namespace font
|
||||
} // namespace theme
|
||||
|
||||
@@ -7,57 +7,56 @@
|
||||
|
||||
#include <nxst/domain/account.hpp>
|
||||
#include <nxst/domain/title.hpp>
|
||||
#include <nxst/ui/const.h>
|
||||
#include <nxst/ui/header_bar.hpp>
|
||||
#include <nxst/ui/hint_bar.hpp>
|
||||
|
||||
namespace ui {
|
||||
|
||||
enum class TitlesFocus { List, Actions };
|
||||
enum class TitlesAction { Transfer, Receive };
|
||||
enum class TitlesFocus { List, Actions };
|
||||
enum class TitlesAction { Transfer, Receive };
|
||||
|
||||
class TitlesLayout : public pu::ui::Layout {
|
||||
private:
|
||||
pu::ui::elm::Menu::Ref titlesMenu;
|
||||
std::unordered_map<AccountUid, std::vector<pu::ui::elm::MenuItem::Ref>> menuCache;
|
||||
bool m_inputLocked = false;
|
||||
std::unique_ptr<HeaderBar> header;
|
||||
std::unique_ptr<HintBar> hints;
|
||||
class TitlesLayout : public pu::ui::Layout {
|
||||
private:
|
||||
pu::ui::elm::Menu::Ref titlesMenu;
|
||||
std::unordered_map<AccountUid, std::vector<pu::ui::elm::MenuItem::Ref>> menuCache;
|
||||
bool m_inputLocked = false;
|
||||
std::unique_ptr<HeaderBar> header;
|
||||
std::unique_ptr<HintBar> hints;
|
||||
|
||||
pu::ui::elm::Rectangle::Ref panelBg;
|
||||
pu::ui::elm::TextBlock::Ref panelTitle;
|
||||
pu::ui::elm::TextBlock::Ref panelHint;
|
||||
pu::ui::elm::Rectangle::Ref btnTransferBg;
|
||||
pu::ui::elm::TextBlock::Ref btnTransferText;
|
||||
pu::ui::elm::Rectangle::Ref btnReceiveBg;
|
||||
pu::ui::elm::TextBlock::Ref btnReceiveText;
|
||||
pu::ui::elm::TextBlock::Ref panelFooter;
|
||||
pu::ui::elm::TextBlock::Ref emptyText;
|
||||
pu::ui::elm::TextBlock::Ref emptySub;
|
||||
pu::ui::elm::Rectangle::Ref panelBg;
|
||||
pu::ui::elm::TextBlock::Ref panelTitle;
|
||||
pu::ui::elm::TextBlock::Ref panelHint;
|
||||
pu::ui::elm::Rectangle::Ref btnTransferBg;
|
||||
pu::ui::elm::TextBlock::Ref btnTransferText;
|
||||
pu::ui::elm::Rectangle::Ref btnReceiveBg;
|
||||
pu::ui::elm::TextBlock::Ref btnReceiveText;
|
||||
pu::ui::elm::TextBlock::Ref panelFooter;
|
||||
pu::ui::elm::TextBlock::Ref emptyText;
|
||||
pu::ui::elm::TextBlock::Ref emptySub;
|
||||
|
||||
AccountUid current_uid{};
|
||||
TitlesFocus focus = TitlesFocus::List;
|
||||
TitlesAction action = TitlesAction::Transfer;
|
||||
int lockedListIndex = 0;
|
||||
AccountUid current_uid{};
|
||||
TitlesFocus focus = TitlesFocus::List;
|
||||
TitlesAction action = TitlesAction::Transfer;
|
||||
int lockedListIndex = 0;
|
||||
|
||||
void refreshPanel();
|
||||
void refreshButtons();
|
||||
void updateHints();
|
||||
void runTransfer(int index, Title& title);
|
||||
void runReceive(int index, Title& title);
|
||||
void refreshPanel();
|
||||
void refreshButtons();
|
||||
void updateHints();
|
||||
void runTransfer(int index, Title& title);
|
||||
void runReceive(int index, Title& title);
|
||||
|
||||
public:
|
||||
TitlesLayout();
|
||||
void InitTitles(AccountUid uid);
|
||||
void LockInput() {
|
||||
m_inputLocked = true;
|
||||
}
|
||||
void UnlockInput() {
|
||||
m_inputLocked = false;
|
||||
}
|
||||
public:
|
||||
TitlesLayout();
|
||||
void InitTitles(AccountUid uid);
|
||||
void LockInput() {
|
||||
m_inputLocked = true;
|
||||
}
|
||||
void UnlockInput() {
|
||||
m_inputLocked = false;
|
||||
}
|
||||
|
||||
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos);
|
||||
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos);
|
||||
|
||||
PU_SMART_CTOR(TitlesLayout)
|
||||
};
|
||||
PU_SMART_CTOR(TitlesLayout)
|
||||
};
|
||||
} // namespace ui
|
||||
|
||||
@@ -6,79 +6,79 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
class TransferOverlay : public pu::ui::Overlay {
|
||||
private:
|
||||
pu::ui::elm::Rectangle::Ref card;
|
||||
pu::ui::elm::TextBlock::Ref titleText;
|
||||
pu::ui::elm::TextBlock::Ref statusText;
|
||||
pu::ui::elm::Rectangle::Ref progressTrack;
|
||||
pu::ui::elm::ProgressBar::Ref progressBar;
|
||||
pu::ui::elm::TextBlock::Ref indeterminateText;
|
||||
pu::ui::elm::TextBlock::Ref hintText;
|
||||
class TransferOverlay : public pu::ui::Overlay {
|
||||
private:
|
||||
pu::ui::elm::Rectangle::Ref card;
|
||||
pu::ui::elm::TextBlock::Ref titleText;
|
||||
pu::ui::elm::TextBlock::Ref statusText;
|
||||
pu::ui::elm::Rectangle::Ref progressTrack;
|
||||
pu::ui::elm::ProgressBar::Ref progressBar;
|
||||
pu::ui::elm::TextBlock::Ref indeterminateText;
|
||||
pu::ui::elm::TextBlock::Ref hintText;
|
||||
|
||||
static constexpr int CardW = 720;
|
||||
static constexpr int CardH = 360;
|
||||
static constexpr int CardX = (theme::layout::ScreenW - CardW) / 2;
|
||||
static constexpr int CardY = (theme::layout::ScreenH - CardH) / 2;
|
||||
static constexpr int CardW = 720;
|
||||
static constexpr int CardH = 360;
|
||||
static constexpr int CardX = (theme::layout::ScreenW - CardW) / 2;
|
||||
static constexpr int CardY = (theme::layout::ScreenH - CardH) / 2;
|
||||
|
||||
public:
|
||||
TransferOverlay(const std::string& title)
|
||||
: Overlay(0, 0, theme::layout::ScreenW, theme::layout::ScreenH, theme::color::Scrim) {
|
||||
using namespace theme;
|
||||
public:
|
||||
TransferOverlay(const std::string& title)
|
||||
: Overlay(0, 0, theme::layout::ScreenW, theme::layout::ScreenH, theme::color::Scrim) {
|
||||
using namespace theme;
|
||||
|
||||
card = pu::ui::elm::Rectangle::New(CardX, CardY, CardW, CardH, color::BgSurface, radius::lg);
|
||||
card = pu::ui::elm::Rectangle::New(CardX, CardY, CardW, CardH, color::BgSurface, radius::lg);
|
||||
|
||||
titleText = pu::ui::elm::TextBlock::New(CardX + space::lg, CardY + space::lg, title);
|
||||
titleText->SetFont(type::font(type::Title));
|
||||
titleText->SetColor(color::TextPrimary);
|
||||
titleText = pu::ui::elm::TextBlock::New(CardX + space::lg, CardY + space::lg, title);
|
||||
titleText->SetFont(type::font(type::Title));
|
||||
titleText->SetColor(color::TextPrimary);
|
||||
|
||||
statusText = pu::ui::elm::TextBlock::New(CardX + space::lg, CardY + space::lg + 56, "");
|
||||
statusText->SetFont(type::font(type::Body));
|
||||
statusText->SetColor(color::TextSecondary);
|
||||
statusText = pu::ui::elm::TextBlock::New(CardX + space::lg, CardY + space::lg + 56, "");
|
||||
statusText->SetFont(type::font(type::Body));
|
||||
statusText->SetColor(color::TextSecondary);
|
||||
|
||||
int barX = CardX + space::lg;
|
||||
int barY = CardY + space::lg + 56 + 56;
|
||||
int barW = CardW - 2 * space::lg;
|
||||
int barX = CardX + space::lg;
|
||||
int barY = CardY + space::lg + 56 + 56;
|
||||
int barW = CardW - 2 * space::lg;
|
||||
|
||||
progressTrack = pu::ui::elm::Rectangle::New(barX, barY, barW, 8, color::Divider, radius::sm);
|
||||
progressTrack = pu::ui::elm::Rectangle::New(barX, barY, barW, 8, color::Divider, radius::sm);
|
||||
|
||||
progressBar = pu::ui::elm::ProgressBar::New(barX, barY, barW, 8, 100.0);
|
||||
progressBar->SetProgressColor(color::Primary);
|
||||
progressBar->SetBackgroundColor(color::Divider);
|
||||
progressBar = pu::ui::elm::ProgressBar::New(barX, barY, barW, 8, 100.0);
|
||||
progressBar->SetProgressColor(color::Primary);
|
||||
progressBar->SetBackgroundColor(color::Divider);
|
||||
|
||||
indeterminateText = pu::ui::elm::TextBlock::New(barX, barY - 4, "Preparing transfer...");
|
||||
indeterminateText->SetFont(type::font(type::Body));
|
||||
indeterminateText->SetColor(color::TextMuted);
|
||||
indeterminateText->SetVisible(false);
|
||||
indeterminateText = pu::ui::elm::TextBlock::New(barX, barY - 4, "Preparing transfer...");
|
||||
indeterminateText->SetFont(type::font(type::Body));
|
||||
indeterminateText->SetColor(color::TextMuted);
|
||||
indeterminateText->SetVisible(false);
|
||||
|
||||
hintText =
|
||||
pu::ui::elm::TextBlock::New(CardX + space::lg, CardY + CardH - space::lg - 18, "B to cancel");
|
||||
hintText->SetFont(type::font(type::Caption));
|
||||
hintText->SetColor(color::TextMuted);
|
||||
hintText =
|
||||
pu::ui::elm::TextBlock::New(CardX + space::lg, CardY + CardH - space::lg - 18, "B to cancel");
|
||||
hintText->SetFont(type::font(type::Caption));
|
||||
hintText->SetColor(color::TextMuted);
|
||||
|
||||
this->Add(card);
|
||||
this->Add(titleText);
|
||||
this->Add(statusText);
|
||||
this->Add(progressTrack);
|
||||
this->Add(progressBar);
|
||||
this->Add(indeterminateText);
|
||||
this->Add(hintText);
|
||||
}
|
||||
PU_SMART_CTOR(TransferOverlay)
|
||||
this->Add(card);
|
||||
this->Add(titleText);
|
||||
this->Add(statusText);
|
||||
this->Add(progressTrack);
|
||||
this->Add(progressBar);
|
||||
this->Add(indeterminateText);
|
||||
this->Add(hintText);
|
||||
}
|
||||
PU_SMART_CTOR(TransferOverlay)
|
||||
|
||||
void SetStatus(const std::string& status) {
|
||||
statusText->SetText(StringUtils::elide(status, 56));
|
||||
}
|
||||
void SetStatus(const std::string& status) {
|
||||
statusText->SetText(string_utils::elide(status, 56));
|
||||
}
|
||||
|
||||
void SetProgress(double val) {
|
||||
progressBar->SetProgress(val);
|
||||
}
|
||||
void SetProgress(double val) {
|
||||
progressBar->SetProgress(val);
|
||||
}
|
||||
|
||||
void SetProgressVisible(bool visible) {
|
||||
progressTrack->SetVisible(visible);
|
||||
progressBar->SetVisible(visible);
|
||||
indeterminateText->SetVisible(!visible);
|
||||
}
|
||||
};
|
||||
void SetProgressVisible(bool visible) {
|
||||
progressTrack->SetVisible(visible);
|
||||
progressBar->SetVisible(visible);
|
||||
indeterminateText->SetVisible(!visible);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#include <nxst/domain/account.hpp>
|
||||
|
||||
namespace ui {
|
||||
struct UiContext {
|
||||
std::optional<AccountUid> selectedUser;
|
||||
std::string selectedUserName;
|
||||
};
|
||||
} // namespace ui
|
||||
@@ -2,27 +2,26 @@
|
||||
|
||||
#include <pu/Plutonium>
|
||||
|
||||
#include <nxst/ui/const.h>
|
||||
#include <nxst/ui/header_bar.hpp>
|
||||
#include <nxst/ui/hint_bar.hpp>
|
||||
|
||||
namespace ui {
|
||||
|
||||
class UsersLayout : public pu::ui::Layout {
|
||||
private:
|
||||
pu::ui::elm::Menu::Ref usersMenu;
|
||||
pu::ui::elm::Rectangle::Ref loadingBg;
|
||||
pu::ui::elm::TextBlock::Ref loadingText;
|
||||
std::unique_ptr<HeaderBar> header;
|
||||
std::unique_ptr<HintBar> hints;
|
||||
class UsersLayout : public pu::ui::Layout {
|
||||
private:
|
||||
pu::ui::elm::Menu::Ref usersMenu;
|
||||
pu::ui::elm::Rectangle::Ref loadingBg;
|
||||
pu::ui::elm::TextBlock::Ref loadingText;
|
||||
std::unique_ptr<HeaderBar> header;
|
||||
std::unique_ptr<HintBar> hints;
|
||||
|
||||
public:
|
||||
UsersLayout();
|
||||
public:
|
||||
UsersLayout();
|
||||
|
||||
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos);
|
||||
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::TouchPoint Pos);
|
||||
|
||||
int32_t GetCurrentIndex();
|
||||
int32_t GetCurrentIndex();
|
||||
|
||||
PU_SMART_CTOR(UsersLayout)
|
||||
};
|
||||
PU_SMART_CTOR(UsersLayout)
|
||||
};
|
||||
} // namespace ui
|
||||
|
||||
Reference in New Issue
Block a user