feat(wallets): segmented sort control (like the Receive all/z/t toggle)
Replace the sort dropdown with a material::SegmentedControl — Created / Addresses / Txs / Size — matching the Receive tab's address-type toggle, with the asc/desc arrow beside it. Shorten the four sort labels to fit the segments (updated across all eight languages + the back-fill script). The direction arrow is positioned explicitly on the segment's baseline (the control is draw-list based and doesn't advance the layout cursor). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -120,19 +120,29 @@ public:
|
||||
return idx < probeSnap.size() ? probeSnap[idx] : ProbeResult{};
|
||||
};
|
||||
|
||||
// ---- Sort controls: pick the key; the arrow flips ascending/descending -----------------
|
||||
// ---- Sort controls: a segmented key picker + an arrow that flips ascending/descending ----
|
||||
{
|
||||
ImGui::AlignTextToFramePadding();
|
||||
Type().textColored(TypeStyle::Caption, OnSurfaceMedium(), TR("wallets_sort_by"));
|
||||
ImGui::SameLine();
|
||||
const char* items[] = { TR("wallets_sort_created"), TR("wallets_sort_addresses"),
|
||||
TR("wallets_sort_txs"), TR("wallets_sort_size") };
|
||||
ImGui::SetNextItemWidth(190.0f * dp);
|
||||
ImGui::Combo("##walletSort", &s_sortMode, items, IM_ARRAYSIZE(items));
|
||||
ImGui::SameLine();
|
||||
const float dbH = ImGui::GetFrameHeight();
|
||||
ImFont* segFont = Type().caption();
|
||||
const char* segLabels[] = { TR("wallets_sort_created"), TR("wallets_sort_addresses"),
|
||||
TR("wallets_sort_txs"), TR("wallets_sort_size") };
|
||||
float maxLW = 0.0f;
|
||||
for (const char* l : segLabels)
|
||||
maxLW = std::max(maxLW, segFont->CalcTextSizeA(segFont->LegacySize, FLT_MAX, 0, l).x);
|
||||
const float segH = ImGui::GetFrameHeight();
|
||||
const float segTW = (maxLW + 20.0f * dp) * 4.0f;
|
||||
const ImVec2 segOrigin = ImGui::GetCursorScreenPos();
|
||||
const int clk = material::SegmentedControl(ImGui::GetWindowDrawList(), segOrigin, segTW, segH,
|
||||
segLabels, 4, s_sortMode, segFont, "##walletSortSeg", dp);
|
||||
if (clk >= 0) s_sortMode = clk;
|
||||
// SegmentedControl is draw-list based and doesn't move the layout cursor, so place the
|
||||
// direction arrow explicitly just to its right on the same baseline (a real item advances
|
||||
// the cursor past this row for the list below).
|
||||
ImGui::SetCursorScreenPos(ImVec2(segOrigin.x + segTW + Layout::spacingSm(), segOrigin.y));
|
||||
if (StyledButton(s_sortDesc ? ICON_MD_ARROW_DOWNWARD : ICON_MD_ARROW_UPWARD,
|
||||
ImVec2(dbH, dbH), Type().iconSmall()))
|
||||
ImVec2(segH, segH), Type().iconSmall()))
|
||||
s_sortDesc = !s_sortDesc;
|
||||
if (ImGui::IsItemHovered()) Tooltip("%s", TR(s_sortDesc ? "wallets_sort_desc" : "wallets_sort_asc"));
|
||||
}
|
||||
|
||||
@@ -262,10 +262,10 @@ void I18n::loadBuiltinEnglish()
|
||||
strings_["wallets_col_keys"] = "keys";
|
||||
strings_["wallets_created"] = "created";
|
||||
strings_["wallets_sort_by"] = "Sort:";
|
||||
strings_["wallets_sort_created"] = "Date created";
|
||||
strings_["wallets_sort_addresses"] = "Address count";
|
||||
strings_["wallets_sort_txs"] = "Transaction count";
|
||||
strings_["wallets_sort_size"] = "Wallet size";
|
||||
strings_["wallets_sort_created"] = "Created";
|
||||
strings_["wallets_sort_addresses"] = "Addresses";
|
||||
strings_["wallets_sort_txs"] = "Txs";
|
||||
strings_["wallets_sort_size"] = "Size";
|
||||
strings_["wallets_sort_asc"] = "Ascending (oldest / fewest / smallest first)";
|
||||
strings_["wallets_sort_desc"] = "Descending (newest / most / largest first)";
|
||||
strings_["wallets_col_balance"] = "Balance";
|
||||
|
||||
Reference in New Issue
Block a user