redesign, broadcast server crash fix

This commit is contained in:
2026-04-26 12:41:58 +03:00
parent 4ffa6ed970
commit 64b30e9835
20 changed files with 771 additions and 167 deletions
+55 -31
View File
@@ -1,51 +1,83 @@
#pragma once
#include <pu/Plutonium>
#include <Theme.hpp>
#include <util.hpp>
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;
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:
static constexpr int OvlX = 200;
static constexpr int OvlY = 240;
static constexpr int OvlW = 880;
static constexpr int OvlH = 240;
TransferOverlay(const std::string &title)
: Overlay(OvlX, OvlY, OvlW, OvlH, pu::ui::Color(30, 30, 30, 220))
: Overlay(0, 0, theme::layout::ScreenW, theme::layout::ScreenH, theme::color::Scrim)
{
titleText = pu::ui::elm::TextBlock::New(40, 30, title);
titleText->SetColor(pu::ui::Color(255, 255, 255, 255));
using namespace theme;
statusText = pu::ui::elm::TextBlock::New(40, 90, "");
statusText->SetColor(pu::ui::Color(180, 180, 180, 255));
card = pu::ui::elm::Rectangle::New(
CardX, CardY, CardW, CardH, color::BgSurface, radius::lg);
progressBar = pu::ui::elm::ProgressBar::New(40, 140, OvlW - 80, 20, 100.0);
progressBar->SetProgressColor(pu::ui::Color(100, 180, 255, 255));
progressBar->SetBackgroundColor(pu::ui::Color(70, 70, 70, 255));
titleText = pu::ui::elm::TextBlock::New(
CardX + space::lg, CardY + space::lg, title);
titleText->SetFont(type::font(type::Title));
titleText->SetColor(color::TextPrimary);
hintText = pu::ui::elm::TextBlock::New(40, 195, "Press B to cancel");
hintText->SetColor(pu::ui::Color(130, 130, 130, 255));
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;
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);
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);
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) {
static constexpr size_t MaxChars = 48;
if (status.size() > MaxChars) {
statusText->SetText(status.substr(0, MaxChars - 3) + "...");
} else {
statusText->SetText(status);
}
statusText->SetText(StringUtils::elide(status, 56));
}
void SetProgress(double val) {
@@ -53,17 +85,9 @@ namespace ui {
}
void SetProgressVisible(bool visible) {
progressTrack->SetVisible(visible);
progressBar->SetVisible(visible);
if (visible) {
this->SetHeight(OvlH);
this->SetY(OvlY);
hintText->SetY(195);
} else {
static constexpr int SmallH = 160;
this->SetHeight(SmallH);
this->SetY((720 - SmallH) / 2);
hintText->SetY(120);
}
indeterminateText->SetVisible(!visible);
}
};