refactor(ui): add material::LabeledInput helper + adopt at 8 form fields

UI-standardization audit: the labeled single-line form field (a plain
ImGui::Text label above a fixed-width InputText/InputTextWithHint) was
open-coded across dialogs. Add material::LabeledInput(label, id, buf, size,
width=-1, hint=nullptr, flags=0) mirroring that idiom exactly — pixel-identical,
but a single chokepoint so input styling (label typography, frame, spacing) can
later evolve in one place. Returns the input's edited bool.

Adopt at the clean vertical (label-above) single-line sites: address-book
add/edit (label + address), shield from-address, export-all-keys + export-
transactions filename, validate-address input, request-payment label + URI.
Left as-is: horizontal label-beside-input rows (settings RPC host/port/user/
pass use Text + SameLine), multiline (InputTextMultiline), numeric (InputDouble),
combos, and hint-only inputs — none match the vertical single-line idiom.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-04 21:11:02 -05:00
parent 1c8e97c0a4
commit 840ead3645
7 changed files with 29 additions and 26 deletions

View File

@@ -354,6 +354,22 @@ inline ImVec2 DrawPill(ImDrawList* dl, const ImVec2& pos, const char* text, ImFo
return sz;
}
// ── Labeled form input ───────────────────────────────────────────────────
// The app's common form-field idiom: a plain label above a fixed-width single-line input
// (ImGui::Text label + SetNextItemWidth + InputText / InputTextWithHint). Mirrors the existing
// pattern exactly (no visual change) so input styling can later evolve in ONE place. `width` < 0
// means full width (-1). Pass a non-null `hint` to use InputTextWithHint. Returns the input's
// edited bool. The label is drawn via "%s" so a stray '%' in the text is safe.
inline bool LabeledInput(const char* label, const char* id, char* buf, size_t bufSize,
float width = -1.0f, const char* hint = nullptr,
ImGuiInputTextFlags flags = 0)
{
ImGui::Text("%s", label);
ImGui::SetNextItemWidth(width);
if (hint && hint[0]) return ImGui::InputTextWithHint(id, hint, buf, bufSize, flags);
return ImGui::InputText(id, buf, bufSize, flags);
}
// ── Frameless icon button ────────────────────────────────────────────────
// Style for IconButton. All colors default to 0 (= unset): color falls back to OnSurfaceMedium();
// hoverColor==0 means "no hover recolor"; hoverBg/restBg==0 mean "no background".