Redesign grade average calculator

This commit is contained in:
Elias Müller 2023-05-30 19:42:24 +02:00
parent 6a3ca7803c
commit ba90556e69

@ -35,7 +35,8 @@ class _GradeAverageState extends State<GradeAverage> {
IconButton(onPressed: () {
showDialog(context: context, builder: (context) {
return AlertDialog(
title: const Text("Noten Zurücksetzen?"),
title: const Text("Zurücksetzen?"),
content: const Text("Alle Einträge werden entfernt."),
actions: [
TextButton(onPressed: () {
Navigator.of(context).pop();
@ -103,6 +104,8 @@ class _GradeAverageState extends State<GradeAverage> {
const SizedBox(height: 10),
const Divider(),
const SizedBox(height: 10),
Text(gradeSystem ? "Wähle unten die Anzahl deiner jewiligen Noten aus" : "Wähle unten die Anzahl deiner jeweiligen Punkte aus"),
const SizedBox(height: 10),
Expanded(
child: ListView.builder(
itemBuilder: (context, index) {
@ -113,7 +116,10 @@ class _GradeAverageState extends State<GradeAverage> {
tileColor: grade.isEven ? Colors.transparent : Colors.transparent.withAlpha(50),
title: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(getGradeDisplay(grade)),
const SizedBox(width: 30),
IconButton(
onPressed: () {
setState(() {
@ -124,7 +130,7 @@ class _GradeAverageState extends State<GradeAverage> {
icon: const Icon(Icons.remove),
color: Theme.of(context).colorScheme.onSurface,
),
Text(getGradeDisplay(grade)),
Text("${grades.where(isThis).length}", style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),
IconButton(
onPressed: () {
setState(() {
@ -137,7 +143,20 @@ class _GradeAverageState extends State<GradeAverage> {
],
),
),
trailing: Text("Anzahl: ${grades.where(isThis).length}"),
trailing: Visibility(
maintainState: true,
maintainAnimation: true,
maintainSize: true,
visible: grades.any(isThis),
child: IconButton(
icon: const Icon(Icons.delete),
onPressed: () {
setState(() {
grades.removeWhere(isThis);
});
},
),
),
),
);
},