From 655663d19988e40253496589d330743bd2d3138b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Tue, 6 Aug 2024 16:38:15 +0200 Subject: [PATCH 1/4] Add two-step dialog when attempting to delete DB from button click event --- lib/tabs/home.dart | 50 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/tabs/home.dart b/lib/tabs/home.dart index f8763de..6880447 100644 --- a/lib/tabs/home.dart +++ b/lib/tabs/home.dart @@ -84,6 +84,54 @@ class _ExerciseStoreHomePageState extends State with Sing }); } + Future _showConfirmationDialogs() async { + final bool? firstDialogConfirmed = await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Confirm Deletion'), + content: const Text('Clicking this button deletes all the recorded exercise data. Are you sure you want to do this?'), + actions: [ + TextButton( + child: const Text('No'), + onPressed: () => Navigator.of(context).pop(false), + ), + TextButton( + child: const Text('Yes'), + onPressed: () => Navigator.of(context).pop(true), + ), + ], + ); + }, + ); + + if (firstDialogConfirmed == true) { + final bool? secondDialogConfirmed = await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Are you really sure?'), + content: const Text('Are you really sure you want to lose all your data? There is no going back!'), + actions: [ + TextButton( + child: const Text('No'), + onPressed: () => Navigator.of(context).pop(false), + ), + TextButton( + child: const Text('Yes'), + onPressed: () => Navigator.of(context).pop(true), + ), + ], + ); + }, + ); + + if (secondDialogConfirmed == true) { + await _clearDatabase(); + } + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -93,7 +141,7 @@ class _ExerciseStoreHomePageState extends State with Sing IconButton( icon: const Icon(Icons.delete_sweep), onPressed: () async { - await _clearDatabase(); + await _showConfirmationDialogs(); }, ), ], From f3a4f32843e113cb6052d1a8feda4883ad9d818f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Tue, 6 Aug 2024 16:40:39 +0200 Subject: [PATCH 2/4] Added emojis to DB delete dialog --- lib/tabs/home.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tabs/home.dart b/lib/tabs/home.dart index 6880447..ec25d3b 100644 --- a/lib/tabs/home.dart +++ b/lib/tabs/home.dart @@ -89,8 +89,8 @@ class _ExerciseStoreHomePageState extends State with Sing context: context, builder: (BuildContext context) { return AlertDialog( - title: const Text('Confirm Deletion'), - content: const Text('Clicking this button deletes all the recorded exercise data. Are you sure you want to do this?'), + title: const Text('⚠️ Confirm Deletion'), + content: const Text('🚨 Clicking this button deletes all the recorded exercise data. Are you sure you want to do this?'), actions: [ TextButton( child: const Text('No'), @@ -110,8 +110,8 @@ class _ExerciseStoreHomePageState extends State with Sing context: context, builder: (BuildContext context) { return AlertDialog( - title: const Text('Are you really sure?'), - content: const Text('Are you really sure you want to lose all your data? There is no going back!'), + title: const Text('❗️ Are you really sure?'), + content: const Text('💥 Are you really sure you want to lose all your data? There is no going back!'), actions: [ TextButton( child: const Text('No'), From 747029f7386a9ceecb5ec70231e6fb54352dc220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Tue, 6 Aug 2024 16:43:22 +0200 Subject: [PATCH 3/4] Add notification snackbar when DB is successfully deleted --- lib/tabs/home.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/tabs/home.dart b/lib/tabs/home.dart index ec25d3b..7f03167 100644 --- a/lib/tabs/home.dart +++ b/lib/tabs/home.dart @@ -128,6 +128,15 @@ class _ExerciseStoreHomePageState extends State with Sing if (secondDialogConfirmed == true) { await _clearDatabase(); + + // Show success SnackBar + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: const Text('✅ Database cleared successfully!'), + backgroundColor: Colors.green, + duration: const Duration(seconds: 2), + ), + ); } } } From c91de33a3794842fe95394ffc7f4a72f7c8bd765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Tue, 6 Aug 2024 16:45:10 +0200 Subject: [PATCH 4/4] Added emojis to the two other SnackBars in the inputs tab --- lib/tabs/inputs.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tabs/inputs.dart b/lib/tabs/inputs.dart index 8279469..800257e 100644 --- a/lib/tabs/inputs.dart +++ b/lib/tabs/inputs.dart @@ -82,13 +82,13 @@ class _ExerciseSetterState extends State { if (isNewHighScore) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text('New high score for $exerciseName!'), + content: Text('🚀🎉 New high score for $exerciseName!'), duration: Duration(seconds: 2), backgroundColor: Colors.green, )); } else { ScaffoldMessenger.of(context).showSnackBar(const SnackBar( - content: Text('Exercise added successfully'), + content: Text('🎯 Exercise added successfully'), duration: Duration(seconds: 2), )); }