refine(daemon-update): version cards show a text label + the icon badge

Bring back the small status label next to the tag (installed / pre-release /
latest), colored to match, alongside the right-aligned icon badge — both keyed to
the same status. The label is bounded so it never overruns the icon.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-10 17:37:12 -05:00
parent 96a1c54556
commit 54945c94bf

View File

@@ -272,21 +272,30 @@ private:
mdl->AddRectFilled(rmn, rmx, fill, round);
if (sel) mdl->AddRect(rmn, rmx, WithAlpha(Primary(), 150), round, 0, 1.6f * dp);
if (hov || held) ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
// Right-aligned status icon badge — active (installed), pre-release, or newest.
const char* ico = nullptr; ImU32 icoC = 0; const char* tt = nullptr;
if (r.installed) { ico = ICON_MD_CHECK_CIRCLE; icoC = Success(); tt = TR("daemon_update_active_tt"); }
else if (r.prerelease) { ico = ICON_MD_SCIENCE; icoC = Warning(); tt = TR("daemon_update_prerelease_tt"); }
else if (i == 0) { ico = ICON_MD_NEW_RELEASES; icoC = Primary(); tt = TR("daemon_update_latest_tt"); }
// Status — one of active (installed), pre-release, or newest — shown as a small text
// label next to the tag AND a matching right-aligned icon badge.
const char* ico = nullptr; ImU32 statusC = 0; const char* tt = nullptr; const char* lbl = nullptr;
if (r.installed) { ico = ICON_MD_CHECK_CIRCLE; statusC = Success(); tt = TR("daemon_update_active_tt"); lbl = TR("upd_installed_badge"); }
else if (r.prerelease) { ico = ICON_MD_SCIENCE; statusC = Warning(); tt = TR("daemon_update_prerelease_tt"); lbl = TR("upd_prerelease"); }
else if (i == 0) { ico = ICON_MD_NEW_RELEASES; statusC = Primary(); tt = TR("daemon_update_latest_tt"); lbl = TR("daemon_update_latest_badge"); }
float rightLimit = rmx.x - Layout::spacingMd();
if (ico) {
float cs = bodyF->LegacySize * 1.3f;
ImVec2 cp(rmx.x - Layout::spacingMd() - cs, (rmn.y + rmx.y) * 0.5f - cs * 0.5f);
mdl->AddText(icoF, cs, cp, icoC, ico);
mdl->AddText(icoF, cs, cp, statusC, ico);
if ((hov || sel) && tt) Tooltip("%s", tt);
rightLimit = cp.x - Layout::spacingSm();
}
float x = rmn.x + Layout::spacingMd();
float tagY = rmn.y + Layout::spacingMd();
mdl->AddText(bodyF, bodyF->LegacySize, ImVec2(x, tagY),
r.hasAsset ? OnSurface() : OnSurfaceDisabled(), r.tag.c_str());
if (lbl) {
float bx = x + bodyF->CalcTextSizeA(bodyF->LegacySize, FLT_MAX, 0, r.tag.c_str()).x + Layout::spacingSm();
float by = tagY + (bodyF->LegacySize - capF->LegacySize) * 0.5f;
if (bx + capF->CalcTextSizeA(capF->LegacySize, FLT_MAX, 0, lbl).x <= rightLimit)
mdl->AddText(capF, capF->LegacySize, ImVec2(bx, by), statusC, lbl);
}
if (!r.date.empty())
mdl->AddText(capF, capF->LegacySize,
ImVec2(x, rmx.y - Layout::spacingMd() - capF->LegacySize),