From f9861e505a4565b2aa3a66c20c7288a01f2ca098 Mon Sep 17 00:00:00 2001 From: DanS Date: Wed, 18 Nov 2026 21:45:59 -0600 Subject: [PATCH] feat(balance): clearer fiat line instead of "$-.-- USD" placeholder (F087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/ui/windows/balance_tab.cpp | 19 +++++++++++++------ src/util/i18n.cpp | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ui/windows/balance_tab.cpp b/src/ui/windows/balance_tab.cpp index 6a426e8..585aabb 100644 --- a/src/ui/windows/balance_tab.cpp +++ b/src/ui/windows/balance_tab.cpp @@ -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 diff --git a/src/util/i18n.cpp b/src/util/i18n.cpp index 9371ee1..25c3857 100644 --- a/src/util/i18n.cpp +++ b/src/util/i18n.cpp @@ -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";