change a bunch of stuff, seperate tracking for progress, updated custom srs layout
This commit is contained in:
@@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user