can now hide correct month values when practicing
This commit is contained in:
parent
3e632627fe
commit
88eb570f63
3 changed files with 27 additions and 4 deletions
|
@ -18,6 +18,7 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
int _count = 0;
|
||||
int _correct = 0;
|
||||
int _incorrect = 0;
|
||||
bool _showCorrect = true;
|
||||
static final _random = new Random();
|
||||
Month _month = Months.getFromInt(_random.nextInt(Months.length));
|
||||
List<MonthPracticeAnswer> answers = new List<MonthPracticeAnswer>();
|
||||
|
@ -55,11 +56,15 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
List<Widget> questions = List<Widget>();
|
||||
if(answers.length >= 2){
|
||||
MonthPracticeAnswer answer = answers[answers.length - 2];
|
||||
StringBuffer tmp = StringBuffer("${answer.month.string.capitalize()}");
|
||||
if (_showCorrect){
|
||||
tmp.write(": ${answer.month.value}");
|
||||
}
|
||||
questions.add(
|
||||
new Opacity(
|
||||
opacity: 0.3,
|
||||
child: new Text(
|
||||
"${answer.month.string.capitalize()}: ${answer.month.value}",
|
||||
tmp.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: answer.answer == answer.month.value ? Colors.green : Colors.red
|
||||
|
@ -80,11 +85,15 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
}
|
||||
if(answers.length >= 1){
|
||||
MonthPracticeAnswer answer = answers[answers.length - 1];
|
||||
StringBuffer tmp = StringBuffer("${answer.month.string.capitalize()}");
|
||||
if (_showCorrect){
|
||||
tmp.write(": ${answer.month.value}");
|
||||
}
|
||||
questions.add(
|
||||
new Opacity(
|
||||
opacity: 0.6,
|
||||
child: new Text(
|
||||
"${answer.month.string.capitalize()}: ${answer.month.value}",
|
||||
tmp.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: answer.answer == answer.month.value ? Colors.green : Colors.red
|
||||
|
@ -152,6 +161,7 @@ class _MonthPracticeState extends State<MonthPracticePage> {
|
|||
Widget build(BuildContext context) {
|
||||
MonthPracticeSetup setup = ModalRoute.of(context).settings.arguments;
|
||||
_startCount = setup.count;
|
||||
_showCorrect = setup.showCorrect;
|
||||
return Scaffold(
|
||||
drawer: AppDrawer(),
|
||||
appBar: AppBar(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class MonthPracticeSetup {
|
||||
final int count;
|
||||
final bool showCorrect;
|
||||
|
||||
MonthPracticeSetup(this.count);
|
||||
MonthPracticeSetup(this.count, this.showCorrect);
|
||||
}
|
|
@ -10,6 +10,7 @@ class MonthPracticeSetupPage extends StatefulWidget {
|
|||
|
||||
class _MonthPracticeSetupState extends State<MonthPracticeSetupPage> {
|
||||
int _count = 12;
|
||||
bool _showCorrect = true;
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
return Scaffold(
|
||||
|
@ -33,12 +34,23 @@ class _MonthPracticeSetupState extends State<MonthPracticeSetupPage> {
|
|||
onChanged: (newNumber) =>
|
||||
setState(() => _count = newNumber),
|
||||
),
|
||||
new SizedBox(height: 30),
|
||||
new CheckboxListTile(
|
||||
title: new Text("Show correct Answer"),
|
||||
value: _showCorrect,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_showCorrect = !_showCorrect;
|
||||
});
|
||||
}
|
||||
),
|
||||
new SizedBox(height: 30),
|
||||
new FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'/practice/month/practice',
|
||||
arguments: MonthPracticeSetup(_count)
|
||||
arguments: MonthPracticeSetup(_count, _showCorrect)
|
||||
);
|
||||
},
|
||||
child: new Text("Start!"),
|
||||
|
|
Loading…
Add table
Reference in a new issue