feat(settings): migrate Backup Wallet modal to the reference design

Phase 1. Struct-form BlurFloat overlay (was the legacy positional overload);
DialogWarningHeader care header; centered DialogActionFooter (Create Backup +
Close) replacing the StyledButtons + separator; full i18n — title/destination/
button reuse existing backup_* keys, plus two new keys (backup_warn one-line care
line, backup_overwrite_confirm) added in en + 8 langs. No change to backupWallet.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-13 21:37:58 -05:00
parent bf81ec1702
commit 22638b094c
11 changed files with 49 additions and 35 deletions

View File

@@ -3271,42 +3271,44 @@ void App::renderExportKeyDialog()
void App::renderBackupDialog()
{
auto dlg = ui::schema::UI().drawElement("inline-dialogs", "backup");
auto dlgF = [&](const char* key, float fb) -> float {
auto it = dlg.extraFloats.find(key);
return it != dlg.extraFloats.end() ? it->second : fb;
};
int btnFont = (int)dlgF("button-font", 1);
float btnW = dlgF("button-width", 120.0f);
if (!ui::material::BeginOverlayDialog("Backup Wallet", &show_backup_, dlgF("width", 500.0f), 0.94f)) {
return;
}
ImGui::TextWrapped("Export all private keys to a file. Keep this file secure!");
namespace m = ui::material;
m::OverlayDialogSpec ov;
ov.title = TR("backup_title");
ov.p_open = &show_backup_;
ov.style = m::OverlayStyle::BlurFloat;
ov.cardWidth = 560.0f;
ov.idSuffix = "backup";
if (!m::BeginOverlayDialog(ov)) return;
m::DialogWarningHeader(TR("backup_warn"));
ImGui::Spacing();
ImGui::Text("Backup File Path:");
static char backup_path[512] = "dragonx-backup.txt";
static bool s_backup_confirm_overwrite = false;
ImGui::TextUnformatted(TR("backup_destination"));
ImGui::SetNextItemWidth(-1);
if (ImGui::InputText("##backuppath", backup_path, sizeof(backup_path)))
s_backup_confirm_overwrite = false; // path edited — re-check overwrite on next Save
ImGui::Spacing();
if (!backup_status_.empty()) {
if (backup_success_) {
ImGui::TextColored(ui::material::SuccessVec4(), "%s", backup_status_.c_str());
} else {
ImGui::TextColored(ImVec4(0.8f, 0.3f, 0.3f, 1.0f), "%s", backup_status_.c_str());
}
ImGui::Spacing();
ImGui::PushTextWrapPos(0.0f);
ImGui::TextColored(backup_success_ ? m::SuccessVec4() : ImVec4(0.8f, 0.3f, 0.3f, 1.0f),
"%s", backup_status_.c_str());
ImGui::PopTextWrapPos();
}
ImGui::Spacing();
ImGui::Separator();
if (ui::material::StyledButton("Save Backup", ImVec2(btnW, 0), ui::material::resolveButtonFont(btnFont))) {
bool doSave = false, doClose = false;
m::DialogActionFooter(TR("backup_create"), true, TR("close"), doSave, doClose);
if (doClose) {
show_backup_ = false;
backup_status_.clear();
s_backup_confirm_overwrite = false;
}
if (doSave) {
std::string path(backup_path);
// Trim surrounding whitespace (a pasted path can carry a trailing newline).
while (!path.empty() && (path.front()==' '||path.front()=='\t'||path.front()=='\n'||path.front()=='\r')) path.erase(path.begin());
@@ -3317,7 +3319,7 @@ void App::renderBackupDialog()
// Don't clobber an existing file (possibly a good earlier backup) without confirmation.
s_backup_confirm_overwrite = true;
backup_success_ = false;
backup_status_ = "A file already exists there — click Save Backup again to overwrite it.";
backup_status_ = TR("backup_overwrite_confirm");
} else {
s_backup_confirm_overwrite = false;
backupWallet(path, [this](bool success, const std::string& msg) {
@@ -3327,14 +3329,8 @@ void App::renderBackupDialog()
}
}
}
ImGui::SameLine();
if (ui::material::StyledButton("Close", ImVec2(btnW, 0), ui::material::resolveButtonFont(btnFont))) {
show_backup_ = false;
backup_status_.clear();
s_backup_confirm_overwrite = false;
}
ui::material::EndOverlayDialog();
m::EndOverlayDialog();
}
void App::maybeOfferDaemonUpdate()