delete all kinda stuff

delete function implemented
on pressed -> pop up => are you sure about that?
yes: all rating from all pages will be cleared
no: nothing happens, pop closes
This commit is contained in:
Ali
2024-11-23 17:52:12 +01:00
parent b0b0a5c36d
commit 3cdc1dc169
6 changed files with 83 additions and 6 deletions
+48 -6
View File
@@ -63,6 +63,45 @@ class MyApp extends StatelessWidget {
class MyHome extends StatelessWidget {
const MyHome({super.key});
void _showDeleteDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
title: const Text("Bewertungen löschen"),
content: const Text("Möchtest du alle Eingaben entfernen?",
style: TextStyle(fontSize: 18),),
actions: [
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text("Behalten"),
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.secondary
),
),
ElevatedButton(
onPressed: () {
Provider.of<AnmerkungProvider>(context, listen: false).resetAllFields();
Provider.of<EssenProvider>(context, listen: false).resetAllFields();
Provider.of<AmbienteProvider>(context, listen: false).resetAllFields();
Provider.of<ServiceProvider>(context, listen: false).resetAllFields();
Provider.of<SpezielleErnaehrungProvider>(context, listen: false).resetAllFields();
// Hier Aktion für Löschen ausführen
Navigator.of(context).pop(); // Dialog schließen
},
child: Text("Löschen"),
)
],
);
},
);
}
@override
Widget build(BuildContext context) {
@@ -146,17 +185,20 @@ class MyHome extends StatelessWidget {
bottom: 10,
child: IconButton.filled(
padding: const EdgeInsets.all(15),
onPressed: () {},
onPressed: () {
_showDeleteDialog(context); // Dialog anzeigen
},
icon: const Icon(
Icons.delete,
size: 30,
),
style: ButtonStyle(
shape: WidgetStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(17))),
backgroundColor: WidgetStateProperty.all(
Theme.of(context).colorScheme.primary,
)),
shape: WidgetStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(17))),
backgroundColor: WidgetStateProperty.all(
Theme.of(context).colorScheme.primary,
),
),
),
)
],