feat(contacts): validate address on save, armed-delete hints, bigger avatar badge, Z/T tooltips (F005/F006/F044/F078)
UX audit, Contacts surface (batch 2):
- F005: Save is disabled (with an inline red hint) when the address fails the same
recipient validator the Send tab uses — a contact can no longer be saved with an
address that would only fail later at send time.
- F006: an armed per-row delete names the consequence ("Click again to delete <label>
— cannot be undone") instead of leaving the tooltip on "Delete".
- F044: the avatar-library delete badge gets a larger hit target and an explicit
armed-state tooltip.
- F078: the bare Z/T letter in Table view gets a hover tooltip (shielded / mining).
New strings (English). Build + tests green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "../../data/address_book.h"
|
||||
#include "../../util/i18n.h"
|
||||
#include "../../util/text_format.h"
|
||||
#include "../../util/address_validation.h"
|
||||
#include "../notifications.h"
|
||||
#include "../schema/ui_schema.h"
|
||||
#include "../material/draw_helpers.h"
|
||||
@@ -687,6 +688,17 @@ void RenderContactsTab(App* app)
|
||||
}
|
||||
}
|
||||
|
||||
// Inline validity hint — never let an invalid address be saved as a contact (it would only fail
|
||||
// later at send time); uses the same recipient validator as the Send tab. (F005)
|
||||
{
|
||||
const std::string addrTok = dragonx::util::stripAllWhitespaceForKey(s_edit_address);
|
||||
if (!addrTok.empty() && !dragonx::util::isValidRecipientAddress(addrTok)) {
|
||||
ImGui::PushTextWrapPos(0.0f);
|
||||
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(material::Error()), "%s", TR("invalid_address"));
|
||||
ImGui::PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
// Notes grows to fill the column above the Global checkbox, which is pinned to the bottom.
|
||||
@@ -916,7 +928,7 @@ void RenderContactsTab(App* app)
|
||||
// The delete badge is hit-tested MANUALLY (not an ImGui item) so it never moves the
|
||||
// layout cursor — an InvisibleButton here would leave CursorPosPrevLine at the badge
|
||||
// corner and jitter the rest of the row's cells via the next SameLine.
|
||||
float dr = std::max(7.0f * dp, cell * 0.15f);
|
||||
float dr = std::max(10.5f * dp, cell * 0.17f); // larger hit target (F044)
|
||||
ImVec2 dcc(mx.x - dr - 3.0f * dp, mn.y + dr + 3.0f * dp);
|
||||
bool dhov = ImGui::IsMouseHoveringRect(ImVec2(dcc.x-dr, dcc.y-dr), ImVec2(dcc.x+dr, dcc.y+dr));
|
||||
const int libIdx = n - 1;
|
||||
@@ -938,7 +950,7 @@ void RenderContactsTab(App* app)
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
|
||||
// Two-stage confirm: the first click arms this badge; a second click on the SAME
|
||||
// badge deletes the image file (fs::remove is irreversible — no undo).
|
||||
material::Tooltip("%s", delArmed ? TR("address_book_confirm_delete") : TR("delete"));
|
||||
material::Tooltip("%s", delArmed ? TR("contacts_avatar_del_armed") : TR("contacts_avatar_del"));
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||
if (delArmed) { pendingDelete = libIdx; s_confirm_avatar_del_idx = -1; }
|
||||
else s_confirm_avatar_del_idx = libIdx; // arm; requires a 2nd deliberate click
|
||||
@@ -971,6 +983,7 @@ void RenderContactsTab(App* app)
|
||||
const std::string cleanLabel = dragonx::util::trimUnicodeWhitespace(s_edit_label);
|
||||
const std::string cleanAddr = dragonx::util::stripAllWhitespaceForKey(s_edit_address);
|
||||
bool canSubmit = !cleanLabel.empty() && !cleanAddr.empty()
|
||||
&& dragonx::util::isValidRecipientAddress(cleanAddr) // reject invalid addresses (F005)
|
||||
&& !avatarImportPending();
|
||||
float actionW = std::max(110.0f * dp,
|
||||
btnFont->CalcTextSizeA(btnFont->LegacySize, FLT_MAX, 0, TR("save")).x
|
||||
@@ -1282,6 +1295,8 @@ void RenderContactsTab(App* app)
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushFont(material::Type().subtitle2());
|
||||
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(typeColor(shielded)), "%s", shielded ? "Z" : "T");
|
||||
if (ImGui::IsItemHovered()) // explain the bare Z/T letter (F078)
|
||||
material::Tooltip("%s", shielded ? TR("contact_avatar_shielded") : TR("contact_chip_mining"));
|
||||
ImGui::PopFont();
|
||||
ImGui::SameLine(0.0f, 6.0f * dp);
|
||||
std::string addr_display = util::truncateMiddle(entry.address, addrFrontLbl.truncate, addrBackLbl.truncate);
|
||||
@@ -1452,7 +1467,15 @@ void RenderContactsTab(App* app)
|
||||
ImGui::PushID(a + 100);
|
||||
const bool aClk = ImGui::InvisibleButton("##act", ImVec2(actHit, actHit));
|
||||
const bool aHov = ImGui::IsItemHovered();
|
||||
if (aHov) { ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); material::Tooltip("%s", actTip[a]); }
|
||||
if (aHov) {
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
|
||||
// While the delete action is armed, name the consequence at the point of action
|
||||
// instead of leaving the tooltip on "Delete". (F006)
|
||||
if (a == 3 && s_confirm_delete_idx == static_cast<int>(i))
|
||||
material::Tooltip(TR("contacts_delete_armed_tip"), entry.label.c_str());
|
||||
else
|
||||
material::Tooltip("%s", actTip[a]);
|
||||
}
|
||||
if (aClk) {
|
||||
s_selected_index = static_cast<int>(i);
|
||||
if (a == 0) doCopy();
|
||||
|
||||
@@ -2045,6 +2045,9 @@ void I18n::loadBuiltinEnglish()
|
||||
strings_["contacts_count_filtered"] = "%zu of %zu contacts";
|
||||
strings_["contacts_scope_empty"] = "No contacts for this wallet yet";
|
||||
strings_["contacts_select_first"] = "Select a contact first";
|
||||
strings_["contacts_delete_armed_tip"] = "Click again to delete \"%s\" \xE2\x80\x94 cannot be undone";
|
||||
strings_["contacts_avatar_del"] = "Delete this image";
|
||||
strings_["contacts_avatar_del_armed"] = "Click again to permanently delete this image. Contacts using it show the default badge.";
|
||||
strings_["address_book_count_one"] = "%zu address saved";
|
||||
strings_["address_book_deleted"] = "Entry deleted";
|
||||
strings_["address_book_edit"] = "Edit Address";
|
||||
|
||||
Reference in New Issue
Block a user