feat(balance): clearer fiat line instead of "$-.-- USD" placeholder (F087)

UX audit, Balance: the fiat line showed the cryptic "$-.-- USD" whenever the USD
value was 0 — both for a genuine zero balance and for an unavailable price. A
shared FormatFiatFallback now shows "$0.00 USD" when a price is known (balance is
zero) and "Price unavailable" when there's no price, across all six spots. New
string. Build + tests green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 21:45:59 -06:00
co-authored by Claude Opus 4.8
parent 7656c7f92c
commit f9861e505a
2 changed files with 14 additions and 6 deletions
+13 -6
View File
@@ -49,6 +49,13 @@ double s_dispTransparent = 0.0;
double s_dispUnconfirmed = 0.0;
// Forward declarations for all layout functions
// Fiat line fallback when the USD value is <= 0: distinguish "price known, balance is zero" ($0.00) from
// "no price available" (a clear message), instead of the cryptic "$-.-- USD" placeholder for both. (F087)
static void FormatFiatFallback(char* buf, size_t n, double price_usd) {
if (price_usd > 0.0) snprintf(buf, n, "$0.00 USD");
else snprintf(buf, n, "%s", TR("price_unavailable"));
}
static void RenderBalanceClassic(App* app);
static void RenderBalanceDonut(App* app);
static void RenderBalanceConsolidated(App* app);
@@ -403,7 +410,7 @@ static void RenderBalanceClassic(App* app)
if (usd_value > 0.0)
snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else
snprintf(buf, sizeof(buf), "$-.-- USD");
FormatFiatFallback(buf, sizeof(buf), state.market.price_usd);
dl->AddText(capFont, capFont->LegacySize, ImVec2(cx, cy),
OnSurfaceDisabled(), buf);
std::string earnText; ImU32 earnCol;
@@ -760,7 +767,7 @@ static void RenderBalanceDonut(App* app) {
// USD value
double usd_value = state.getBalanceUSD();
if (usd_value > 0.0) snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else snprintf(buf, sizeof(buf), "$-.-- USD");
else FormatFiatFallback(buf, sizeof(buf), state.market.price_usd);
Type().textColored(TypeStyle::Caption, OnSurfaceDisabled(), buf);
{ // total period-earnings beside the USD when the earnings toggle is on
std::string earnText; ImU32 earnCol;
@@ -968,7 +975,7 @@ static void RenderBalanceConsolidated(App* app) {
// USD value
double usd_value = state.getBalanceUSD();
if (usd_value > 0.0) snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else snprintf(buf, sizeof(buf), "$-.-- USD");
else FormatFiatFallback(buf, sizeof(buf), state.market.price_usd);
dl->AddText(capFont, capFont->LegacySize, ImVec2(cx, cy), OnSurfaceDisabled(), buf);
{ // total period-earnings to the right of the USD when the earnings toggle is on
std::string earnText; ImU32 earnCol;
@@ -1679,7 +1686,7 @@ static void RenderBalanceShield(App* app) {
double usd_value = state.getBalanceUSD();
if (usd_value > 0.0) snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else snprintf(buf, sizeof(buf), "$-.-- USD");
else FormatFiatFallback(buf, sizeof(buf), state.market.price_usd);
Type().textColored(TypeStyle::Caption, OnSurfaceDisabled(), buf);
{ // total period-earnings beside the USD when the earnings toggle is on
std::string earnText; ImU32 earnCol;
@@ -1873,7 +1880,7 @@ static void RenderBalanceTimeline(App* app) {
double usd_value = state.getBalanceUSD();
if (usd_value > 0.0) snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else snprintf(buf, sizeof(buf), "$-.-- USD");
else FormatFiatFallback(buf, sizeof(buf), state.market.price_usd);
Type().textColored(TypeStyle::Caption, OnSurfaceDisabled(), buf);
{ // total period-earnings beside the USD when the earnings toggle is on
std::string earnText; ImU32 earnCol;
@@ -2245,7 +2252,7 @@ static void RenderBalanceMinimal(App* app) {
// USD value
double usd_value = state.getBalanceUSD();
if (usd_value > 0.0) snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else snprintf(buf, sizeof(buf), "$-.-- USD");
else FormatFiatFallback(buf, sizeof(buf), state.market.price_usd);
ImGui::SameLine(0, Layout::spacingLg());
Type().textColored(TypeStyle::Caption, OnSurfaceDisabled(), buf);
{ // total period-earnings beside the USD when the earnings toggle is on
+1
View File
@@ -1330,6 +1330,7 @@ void I18n::loadBuiltinEnglish()
strings_["bal_address_created"] = "New address created.";
strings_["bal_address_create_failed"] = "Couldn't create the address — check the connection and try again.";
strings_["bal_addr_wait_sync"] = "Available once sync finishes.";
strings_["price_unavailable"] = "Price unavailable";
strings_["copy_uri"] = "Copy URI";
strings_["qr_unavailable"] = "QR unavailable";
strings_["received_label"] = "Received";