diff --git a/lib/pages/practice/PracticePage.dart b/lib/pages/practice/PracticePage.dart index 160e8cb..ca9706b 100644 --- a/lib/pages/practice/PracticePage.dart +++ b/lib/pages/practice/PracticePage.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:ohthatsa/pages/practice/PracticeSetup.dart'; import 'package:ohthatsa/pages/practice/PracticeThing.dart'; +import 'package:ohthatsa/pages/practice/PracticeThingCentury.dart'; import 'package:ohthatsa/pages/practice/PracticeThingMonth.dart'; import 'package:ohthatsa/AppDrawer.dart'; import 'package:ohthatsa/pages/practice/PracticeType.dart'; @@ -34,6 +35,10 @@ class _PracticeState extends State { this.practiceThing = PracticeThingMonth(); break; } + case (PracticeType.century): { + this.practiceThing = PracticeThingCentury(); + break; + } default: { // } diff --git a/lib/pages/practice/PracticeSetupPage.dart b/lib/pages/practice/PracticeSetupPage.dart index 95c11e6..a132d07 100644 --- a/lib/pages/practice/PracticeSetupPage.dart +++ b/lib/pages/practice/PracticeSetupPage.dart @@ -90,10 +90,16 @@ class _PracticeSetupState extends State { TableRow( children: [ FlatButton( - child: Text("Year"), + child: Text("Century"), color: Colors.blue, textColor: Colors.white, - onPressed: () {}, + onPressed: () { + Navigator.pushNamed( + context, + '/practice/practice', + arguments: PracticeSetup(_count, _showCorrect, PracticeType.century) + ); + }, ), Text("80%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), Text("70%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), diff --git a/lib/pages/practice/PracticeThingCentury.dart b/lib/pages/practice/PracticeThingCentury.dart new file mode 100644 index 0000000..f280ec6 --- /dev/null +++ b/lib/pages/practice/PracticeThingCentury.dart @@ -0,0 +1,85 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:ohthatsa/pages/practice/PracticeAnswer.dart'; +import 'package:ohthatsa/pages/practice/PracticeThing.dart'; +import 'package:ohthatsa/pages/practice/PracticeType.dart'; +import 'package:ohthatsa/util/DayCalculator.dart'; + +class PracticeThingCentury extends PracticeThing { + int current; + + PracticeThingCentury(){ + next(); + } + + @override + bool answer(int answer) { + answers.add(PracticeAnswer(current, answer, PracticeType.month)); + final correctAnswer = DayCalculator.getCenturyValue(current); + return answer == correctAnswer; + } + + @override + void next() { + current = 1700 + random.nextInt(500); + } + + List getBoolAnswers(){ + return answers.map((answer) => + answer.answer == DayCalculator.getCenturyValue(answer.question) + ).toList(); + } + + Text getAppBarTitleText(){ + return Text("Practicing Centuries"); + } + + Text getCurrentQuestionText(){ + return Text( + current.toString(), + style: TextStyle( + fontSize: 30 + ) + ); + } + + Text getLastAnswerText(bool showCorrect){ + String text = "-"; + Color color = Colors.red; + if(answers.length >= 1){ + final answer = answers[answers.length - 1]; + final correctAnswer = DayCalculator.getCenturyValue(answer.question); + text = answer.question.toString() + (showCorrect ? ": $correctAnswer" : ""); + if(answer.answer == correctAnswer){ + color = Colors.green; + } + } + return Text( + text, + style: TextStyle( + fontSize: 15, + color: color + ) + ); + } + Text getSecondLastAnswerText(bool showCorrect){ + String text = "-"; + Color color = Colors.red; + if(answers.length >= 2){ + final answer = answers[answers.length - 2]; + final correctAnswer = DayCalculator.getCenturyValue(answer.question); + text = answer.question.toString() + (showCorrect ? ": $correctAnswer" : ""); + if(answer.answer == correctAnswer){ + color = Colors.green; + } + } + return Text( + text, + style: TextStyle( + fontSize: 10, + color: color + ) + ); + } +} \ No newline at end of file diff --git a/lib/pages/practice/PracticeThingMonth.dart b/lib/pages/practice/PracticeThingMonth.dart index 98b8e83..38a1736 100644 --- a/lib/pages/practice/PracticeThingMonth.dart +++ b/lib/pages/practice/PracticeThingMonth.dart @@ -72,11 +72,11 @@ class PracticeThingMonth extends PracticeThing { } } return Text( - text, - style: TextStyle( - fontSize: 10, - color: color - ) + text, + style: TextStyle( + fontSize: 10, + color: color + ) ); } } \ No newline at end of file