Skip to content

Commit dbfeddb

Browse files
authored
Merge pull request #25 from dyson-025/issue-13-reset-confirmation
Add confirmation dialog before resetting dashboard progress
2 parents eebc06e + 5f4c1d5 commit dbfeddb

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

src/app.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub struct VisualizerApp {
5959
theme: Theme,
6060
colorblind_mode: ColorblindMode,
6161
show_settings_modal: bool,
62+
show_reset_confirm_modal: bool,
6263
show_unaudited: bool,
6364
view_mode: ViewMode,
6465
completed_problems: std::collections::HashSet<u32>,
@@ -136,6 +137,7 @@ impl Default for VisualizerApp {
136137
theme: Theme::DarkVSCode, // Default to user's favorite VS Code Dark style!
137138
colorblind_mode: ColorblindMode::Off,
138139
show_settings_modal: false,
140+
show_reset_confirm_modal: false,
139141
show_unaudited: false, // Default: Only show 100% Audited problems in Public Release!
140142
view_mode: ViewMode::Visualizer,
141143
completed_problems: std::collections::HashSet::new(),
@@ -321,6 +323,40 @@ impl VisualizerApp {
321323
}
322324
}
323325

326+
fn render_reset_confirm_modal(&mut self, ctx: &egui::Context) {
327+
if !self.show_reset_confirm_modal {
328+
return;
329+
}
330+
331+
egui::Window::new("Confirm Reset")
332+
.collapsible(false)
333+
.resizable(false)
334+
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
335+
.show(ctx, |ui| {
336+
ui.label("Are you sure you want to reset all completed problem checkmarks?");
337+
ui.add_space(8.0);
338+
339+
ui.horizontal(|ui| {
340+
if ui.button("Cancel").clicked() {
341+
self.show_reset_confirm_modal = false;
342+
}
343+
344+
let dark_red = Color32::from_rgb(210, 40, 65);
345+
let confirm_btn = egui::Button::new(
346+
RichText::new("Confirm Reset")
347+
.color(Color32::WHITE)
348+
.strong(),
349+
)
350+
.fill(dark_red);
351+
352+
if ui.add(confirm_btn).clicked() {
353+
self.completed_problems.clear();
354+
self.show_reset_confirm_modal = false;
355+
}
356+
});
357+
});
358+
}
359+
324360
fn recompute_steps(&mut self) {
325361
let app_id = self.selected_approach_id;
326362
self.steps = match self.current_problem {
@@ -1285,7 +1321,7 @@ impl VisualizerApp {
12851321
.button(RichText::new("Reset All Progress").strong().color(p.red))
12861322
.clicked()
12871323
{
1288-
self.completed_problems.clear();
1324+
self.show_reset_confirm_modal = true;
12891325
}
12901326

12911327
ui.add_space(12.0);
@@ -1455,6 +1491,9 @@ impl VisualizerApp {
14551491
self.select_problem(prob);
14561492
self.view_mode = ViewMode::Visualizer;
14571493
}
1494+
1495+
// Render the confirmation dialog on top of the dashboard
1496+
self.render_reset_confirm_modal(ctx);
14581497
}
14591498
}
14601499

0 commit comments

Comments
 (0)