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:
+44
-2
@@ -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,7 +185,9 @@ 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,
|
||||
@@ -156,7 +197,8 @@ class MyHome extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(17))),
|
||||
backgroundColor: WidgetStateProperty.all(
|
||||
Theme.of(context).colorScheme.primary,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
@@ -19,4 +19,11 @@ class AmbienteProvider extends ChangeNotifier {
|
||||
freiText = text;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void resetAllFields(){
|
||||
freiText = "";
|
||||
ratingFrage1 = 0;
|
||||
ratingFrage2 = 0;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,11 @@ class AnmerkungProvider extends ChangeNotifier {
|
||||
freiText = text;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void resetAllFields(){
|
||||
freiText = "";
|
||||
ratingFrage1 = 0;
|
||||
ratingFrage2 = 0;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,11 @@ class EssenProvider extends ChangeNotifier {
|
||||
freiText = text;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void resetAllFields(){
|
||||
freiText = "";
|
||||
ratingGeschmack = 0;
|
||||
ratingQuali = 0;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,11 @@ class ServiceProvider extends ChangeNotifier {
|
||||
freiText = text;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void resetAllFields(){
|
||||
freiText = "";
|
||||
ratingFrage1 = 0;
|
||||
ratingFrage2 = 0;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,11 @@ class SpezielleErnaehrungProvider extends ChangeNotifier {
|
||||
freiText = text;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void resetAllFields(){
|
||||
freiText = "";
|
||||
ratingSitzmoeglichkeit = 0;
|
||||
ratingKeineAhnung = 0;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user