Delete column confirmation
Changelog-Changed: Add confirmation when deleting columns Closes: https://github.com/damus-io/notedeck/pull/608 Fixes: https://github.com/damus-io/notedeck/issues/549 Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
committed by
William Casarin
parent
588bb8c5b2
commit
55cc8e4f1d
@@ -77,10 +77,9 @@ impl<'a> NavTitle<'a> {
|
|||||||
ui.add_space(chev_x + item_spacing);
|
ui.add_space(chev_x + item_spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
let delete_button_resp =
|
let remove_column = self.title(ui, self.routes.last().unwrap(), back_button_resp.is_some());
|
||||||
self.title(ui, self.routes.last().unwrap(), back_button_resp.is_some());
|
|
||||||
|
|
||||||
if delete_button_resp.map_or(false, |r| r.clicked()) {
|
if remove_column {
|
||||||
Some(RenderNavAction::RemoveColumn)
|
Some(RenderNavAction::RemoveColumn)
|
||||||
} else if back_button_resp.map_or(false, |r| r.clicked()) {
|
} else if back_button_resp.map_or(false, |r| r.clicked()) {
|
||||||
Some(RenderNavAction::Back)
|
Some(RenderNavAction::Back)
|
||||||
@@ -158,6 +157,35 @@ impl<'a> NavTitle<'a> {
|
|||||||
animation_resp
|
animation_resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn delete_button_section(&self, ui: &mut egui::Ui) -> bool {
|
||||||
|
let id = ui.id().with("title");
|
||||||
|
|
||||||
|
let delete_button_resp = self.delete_column_button(ui, 32.0);
|
||||||
|
if delete_button_resp.clicked() {
|
||||||
|
ui.data_mut(|d| d.insert_temp(id, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ui.data_mut(|d| *d.get_temp_mut_or_default(id)) {
|
||||||
|
let mut confirm_pressed = false;
|
||||||
|
delete_button_resp.show_tooltip_ui(|ui| {
|
||||||
|
let confirm_resp = ui.button("Confirm");
|
||||||
|
if confirm_resp.clicked() {
|
||||||
|
confirm_pressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if confirm_resp.clicked() || ui.button("Cancel").clicked() {
|
||||||
|
ui.data_mut(|d| d.insert_temp(id, false));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if !confirm_pressed && delete_button_resp.clicked_elsewhere() {
|
||||||
|
ui.data_mut(|d| d.insert_temp(id, false));
|
||||||
|
}
|
||||||
|
confirm_pressed
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn pubkey_pfp<'txn, 'me>(
|
fn pubkey_pfp<'txn, 'me>(
|
||||||
&'me mut self,
|
&'me mut self,
|
||||||
txn: &'txn Transaction,
|
txn: &'txn Transaction,
|
||||||
@@ -260,12 +288,7 @@ impl<'a> NavTitle<'a> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn title(
|
fn title(&mut self, ui: &mut egui::Ui, top: &Route, navigating: bool) -> bool {
|
||||||
&mut self,
|
|
||||||
ui: &mut egui::Ui,
|
|
||||||
top: &Route,
|
|
||||||
navigating: bool,
|
|
||||||
) -> Option<egui::Response> {
|
|
||||||
if !navigating {
|
if !navigating {
|
||||||
self.title_pfp(ui, top, 32.0);
|
self.title_pfp(ui, top, 32.0);
|
||||||
self.title_label(ui, top);
|
self.title_label(ui, top);
|
||||||
@@ -275,9 +298,9 @@ impl<'a> NavTitle<'a> {
|
|||||||
if navigating {
|
if navigating {
|
||||||
self.title_label(ui, top);
|
self.title_label(ui, top);
|
||||||
self.title_pfp(ui, top, 32.0);
|
self.title_pfp(ui, top, 32.0);
|
||||||
None
|
false
|
||||||
} else {
|
} else {
|
||||||
Some(self.delete_column_button(ui, 32.0))
|
self.delete_button_section(ui)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.inner
|
.inner
|
||||||
|
|||||||
Reference in New Issue
Block a user