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 { class MyHome extends StatelessWidget {
const MyHome({super.key}); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -146,17 +185,20 @@ class MyHome extends StatelessWidget {
bottom: 10, bottom: 10,
child: IconButton.filled( child: IconButton.filled(
padding: const EdgeInsets.all(15), padding: const EdgeInsets.all(15),
onPressed: () {}, onPressed: () {
_showDeleteDialog(context); // Dialog anzeigen
},
icon: const Icon( icon: const Icon(
Icons.delete, Icons.delete,
size: 30, size: 30,
), ),
style: ButtonStyle( style: ButtonStyle(
shape: WidgetStateProperty.all(RoundedRectangleBorder( shape: WidgetStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(17))), borderRadius: BorderRadius.circular(17))),
backgroundColor: WidgetStateProperty.all( backgroundColor: WidgetStateProperty.all(
Theme.of(context).colorScheme.primary, Theme.of(context).colorScheme.primary,
)), ),
),
), ),
) )
], ],
+7
View File
@@ -19,4 +19,11 @@ class AmbienteProvider extends ChangeNotifier {
freiText = text; freiText = text;
notifyListeners(); notifyListeners();
} }
void resetAllFields(){
freiText = "";
ratingFrage1 = 0;
ratingFrage2 = 0;
notifyListeners();
}
} }
+7
View File
@@ -19,4 +19,11 @@ class AnmerkungProvider extends ChangeNotifier {
freiText = text; freiText = text;
notifyListeners(); notifyListeners();
} }
void resetAllFields(){
freiText = "";
ratingFrage1 = 0;
ratingFrage2 = 0;
notifyListeners();
}
} }
+7
View File
@@ -19,4 +19,11 @@ class EssenProvider extends ChangeNotifier {
freiText = text; freiText = text;
notifyListeners(); notifyListeners();
} }
void resetAllFields(){
freiText = "";
ratingGeschmack = 0;
ratingQuali = 0;
notifyListeners();
}
} }
+7
View File
@@ -19,4 +19,11 @@ class ServiceProvider extends ChangeNotifier {
freiText = text; freiText = text;
notifyListeners(); notifyListeners();
} }
void resetAllFields(){
freiText = "";
ratingFrage1 = 0;
ratingFrage2 = 0;
notifyListeners();
}
} }
@@ -20,4 +20,11 @@ class SpezielleErnaehrungProvider extends ChangeNotifier {
freiText = text; freiText = text;
notifyListeners(); notifyListeners();
} }
void resetAllFields(){
freiText = "";
ratingSitzmoeglichkeit = 0;
ratingKeineAhnung = 0;
notifyListeners();
}
} }