diff --git a/lib/pages/practice/month/MonthPracticePage.dart b/lib/pages/practice/month/MonthPracticePage.dart index 85d6b75..ae7a0bf 100644 --- a/lib/pages/practice/month/MonthPracticePage.dart +++ b/lib/pages/practice/month/MonthPracticePage.dart @@ -18,6 +18,7 @@ class _MonthPracticeState extends State { 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 answers = new List(); @@ -55,11 +56,15 @@ class _MonthPracticeState extends State { List questions = List(); 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 { } 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 { Widget build(BuildContext context) { MonthPracticeSetup setup = ModalRoute.of(context).settings.arguments; _startCount = setup.count; + _showCorrect = setup.showCorrect; return Scaffold( drawer: AppDrawer(), appBar: AppBar( diff --git a/lib/pages/practice/month/MonthPracticeSetup.dart b/lib/pages/practice/month/MonthPracticeSetup.dart index 48717b2..ad39199 100644 --- a/lib/pages/practice/month/MonthPracticeSetup.dart +++ b/lib/pages/practice/month/MonthPracticeSetup.dart @@ -1,5 +1,6 @@ class MonthPracticeSetup { final int count; + final bool showCorrect; - MonthPracticeSetup(this.count); + MonthPracticeSetup(this.count, this.showCorrect); } \ No newline at end of file diff --git a/lib/pages/practice/month/MonthPracticeSetupPage.dart b/lib/pages/practice/month/MonthPracticeSetupPage.dart index 585f368..4ec49ec 100644 --- a/lib/pages/practice/month/MonthPracticeSetupPage.dart +++ b/lib/pages/practice/month/MonthPracticeSetupPage.dart @@ -10,6 +10,7 @@ class MonthPracticeSetupPage extends StatefulWidget { class _MonthPracticeSetupState extends State { int _count = 12; + bool _showCorrect = true; @override Widget build(BuildContext context){ return Scaffold( @@ -33,12 +34,23 @@ class _MonthPracticeSetupState extends State { 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!"),