change a bunch of stuff, seperate tracking for progress, updated custom srs layout

This commit is contained in:
Rene Kievits
2025-10-31 07:16:44 +01:00
parent cafec12888
commit d8edfa1686
12 changed files with 1378 additions and 661 deletions

View File

@@ -5,6 +5,10 @@ class OptionsGrid extends StatelessWidget {
final void Function(String) onSelected;
final Color? buttonColor;
final Color? textColor;
final bool isDisabled;
final String? selectedOption;
final List<String>? correctAnswers;
final bool showResult;
const OptionsGrid({
super.key,
@@ -12,6 +16,10 @@ class OptionsGrid extends StatelessWidget {
required this.onSelected,
this.buttonColor,
this.textColor,
this.isDisabled = false,
this.selectedOption,
this.correctAnswers,
this.showResult = false,
});
@override
@@ -27,13 +35,24 @@ class OptionsGrid extends StatelessWidget {
runSpacing: 10,
alignment: WrapAlignment.center,
children: options.map((o) {
Color currentButtonColor = bg;
Color currentTextColor = fg;
if (showResult) {
if (correctAnswers != null && correctAnswers!.contains(o)) {
currentButtonColor = Colors.green;
} else if (o == selectedOption) {
currentButtonColor = Colors.red;
}
}
return SizedBox(
width: 160,
child: ElevatedButton(
onPressed: () => onSelected(o),
onPressed: isDisabled ? null : () => onSelected(o),
style: ElevatedButton.styleFrom(
backgroundColor: bg,
foregroundColor: fg,
backgroundColor: currentButtonColor,
foregroundColor: currentTextColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
@@ -41,7 +60,7 @@ class OptionsGrid extends StatelessWidget {
),
child: Text(
o,
style: TextStyle(fontSize: 20, color: fg),
style: TextStyle(fontSize: 20, color: currentTextColor),
textAlign: TextAlign.center,
),
),
@@ -49,4 +68,4 @@ class OptionsGrid extends StatelessWidget {
}).toList(),
);
}
}
}