Skip to content

Commit

Permalink
chore: Refactor VocDetailsPage to add confirmation dialog for deletin…
Browse files Browse the repository at this point in the history
…g vocabulary
  • Loading branch information
judemont committed Oct 5, 2024
1 parent 178eb9f commit aea9751
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions lib/widgets/voc_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,42 @@ class _VocDetailsPageState extends State<VocDetailsPage> {
IconButton(
icon: const Icon(Icons.delete),
onPressed: () {
DatabaseService.removeVoc(widget.voc.id!).then((value) {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (context) => const PagesLayout(
currentSection: 0,
child: HomePage(),
),
),
(Route<dynamic> route) => false,
);
});
showDialog(
context: context,
builder: (BuildContext ctx) {
return AlertDialog(
title: const Text('Please Confirm'),
content: const Text('Are you sure ?'),
actions: [
// The "Yes" button
TextButton(
onPressed: () {
// Remove the box
DatabaseService.removeVoc(widget.voc.id!)
.then((value) {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (context) => const PagesLayout(
currentSection: 0,
child: HomePage(),
),
),
(Route<dynamic> route) => false,
);
});
// Close the dialog
Navigator.of(context).pop();
},
child: const Text('Yes')),
TextButton(
onPressed: () {
// Close the dialog
Navigator.of(context).pop();
},
child: const Text('No'))
],
);
});
},
),
IconButton(
Expand Down

0 comments on commit aea9751

Please sign in to comment.