removed some 'month' specific things from practice page

This commit is contained in:
BroodjeAap 2020-11-02 17:22:49 +01:00
parent 25874a711d
commit ba7c909ac4
4 changed files with 16 additions and 11 deletions

View file

@ -3,7 +3,7 @@ import 'package:ohthatsa/pages/YearsPage.dart';
import 'package:ohthatsa/pages/practice/PracticeSetup.dart'; import 'package:ohthatsa/pages/practice/PracticeSetup.dart';
import 'package:ohthatsa/pages/practice/PracticeSetupPage.dart'; import 'package:ohthatsa/pages/practice/PracticeSetupPage.dart';
import 'package:ohthatsa/pages/practice/month/MonthPracticePage.dart'; import 'file:///D:/dev/projects/ohthatsa/lib/pages/practice/PracticePage.dart';
import 'package:ohthatsa/pages/MonthValuesPage.dart'; import 'package:ohthatsa/pages/MonthValuesPage.dart';
void main() { void main() {
@ -34,7 +34,7 @@ class RouteGenerator {
return MaterialPageRoute(builder: (context) => PracticeSetupPage()); return MaterialPageRoute(builder: (context) => PracticeSetupPage());
} }
case "/practice/month/practice": { case "/practice/month/practice": {
return MaterialPageRoute(builder: (context) => MonthPracticePage(settings.arguments)); return MaterialPageRoute(builder: (context) => PracticePage(settings.arguments));
} }
default: { default: {
return MaterialPageRoute(builder: (context) => YearsPage()); return MaterialPageRoute(builder: (context) => YearsPage());

View file

@ -5,18 +5,18 @@ import 'package:ohthatsa/pages/practice/PracticeThingMonth.dart';
import 'package:ohthatsa/AppDrawer.dart'; import 'package:ohthatsa/AppDrawer.dart';
import 'package:ohthatsa/util/Extensions.dart'; import 'package:ohthatsa/util/Extensions.dart';
import 'MonthPracticeAnswer.dart'; import 'month/MonthPracticeAnswer.dart';
class MonthPracticePage extends StatefulWidget { class PracticePage extends StatefulWidget {
final PracticeSetup practiceSetup; final PracticeSetup practiceSetup;
MonthPracticePage( PracticePage(
this.practiceSetup this.practiceSetup
); );
@override @override
_MonthPracticeState createState() => _MonthPracticeState(practiceSetup); _PracticeState createState() => _PracticeState(practiceSetup);
} }
class _MonthPracticeState extends State<MonthPracticePage> { class _PracticeState extends State<PracticePage> {
int _startCount = 0; int _startCount = 0;
bool _showCorrect = true; bool _showCorrect = true;
PracticeThing practiceThing; PracticeThing practiceThing;
@ -25,7 +25,7 @@ class _MonthPracticeState extends State<MonthPracticePage> {
int _correct = 0; int _correct = 0;
int _incorrect = 0; int _incorrect = 0;
_MonthPracticeState(PracticeSetup practiceSetup){ _PracticeState(PracticeSetup practiceSetup){
this._startCount = practiceSetup.count; this._startCount = practiceSetup.count;
this._showCorrect = practiceSetup.showCorrect; this._showCorrect = practiceSetup.showCorrect;
this.practiceThing = PracticeThingMonth(); this.practiceThing = PracticeThingMonth();
@ -52,7 +52,7 @@ class _MonthPracticeState extends State<MonthPracticePage> {
buttons.add( buttons.add(
FlatButton( FlatButton(
onPressed: () { onPressed: () {
checkMonth(i); checkAnswer(i);
}, },
color: Colors.blue, color: Colors.blue,
textColor: Colors.white, textColor: Colors.white,
@ -121,7 +121,7 @@ class _MonthPracticeState extends State<MonthPracticePage> {
return Scaffold( return Scaffold(
drawer: AppDrawer(), drawer: AppDrawer(),
appBar: AppBar( appBar: AppBar(
title: Text("Practicing months"), title: practiceThing.getAppBarTitleText(),
), ),
body: Center( body: Center(
child: Container( child: Container(
@ -176,7 +176,7 @@ class _MonthPracticeState extends State<MonthPracticePage> {
); );
} }
void checkMonth(int answer){ void checkAnswer(int answer){
if(practiceThing.answer(answer)){ if(practiceThing.answer(answer)){
_correct += 1; _correct += 1;
} else { } else {

View file

@ -4,6 +4,7 @@ abstract class PracticeThing {
bool answer(int answer); bool answer(int answer);
void next(); void next();
List<bool> getBoolAnswers(); List<bool> getBoolAnswers();
Text getAppBarTitleText();
Text getCurrentQuestionText(); Text getCurrentQuestionText();
Text getLastAnswerText(bool showCorrect); Text getLastAnswerText(bool showCorrect);
Text getSecondLastAnswerText(bool showCorrect); Text getSecondLastAnswerText(bool showCorrect);

View file

@ -28,6 +28,10 @@ class PracticeThingMonth extends PracticeThing {
return answers.map((answer) => answer.month.value == answer.answer).toList(); return answers.map((answer) => answer.month.value == answer.answer).toList();
} }
Text getAppBarTitleText(){
return Text("Practicing Months");
}
Text getCurrentQuestionText(){ Text getCurrentQuestionText(){
return Text( return Text(
current.toString(), current.toString(),