moved practice buttons to practice thing, so that leap practicething can only give two buttons (0 and 1)
This commit is contained in:
parent
fb66b095ab
commit
2a206c8960
8 changed files with 94 additions and 50 deletions
|
@ -18,10 +18,10 @@ class PracticePage extends StatefulWidget {
|
||||||
this.practiceSetup
|
this.practiceSetup
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
_PracticeState createState() => _PracticeState(practiceSetup);
|
PracticePageState createState() => PracticePageState(practiceSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PracticeState extends State<PracticePage> {
|
class PracticePageState extends State<PracticePage> {
|
||||||
int _startCount = 0;
|
int _startCount = 0;
|
||||||
bool _showCorrect = true;
|
bool _showCorrect = true;
|
||||||
PracticeType practiceType;
|
PracticeType practiceType;
|
||||||
|
@ -31,37 +31,36 @@ class _PracticeState extends State<PracticePage> {
|
||||||
int _correct = 0;
|
int _correct = 0;
|
||||||
int _incorrect = 0;
|
int _incorrect = 0;
|
||||||
|
|
||||||
_PracticeState(PracticeSetup practiceSetup){
|
PracticePageState(PracticeSetup practiceSetup){
|
||||||
this._startCount = practiceSetup.count;
|
this._startCount = practiceSetup.count;
|
||||||
this._showCorrect = practiceSetup.showCorrect;
|
this._showCorrect = practiceSetup.showCorrect;
|
||||||
practiceType = practiceSetup.practiceType;
|
practiceType = practiceSetup.practiceType;
|
||||||
switch(practiceType){
|
switch(practiceType){
|
||||||
case (PracticeType.month): {
|
case (PracticeType.month): {
|
||||||
this.practiceThing = PracticeThingMonth();
|
this.practiceThing = PracticeThingMonth(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (PracticeType.year): {
|
case (PracticeType.year): {
|
||||||
this.practiceThing = PracticeThingYear();
|
this.practiceThing = PracticeThingYear(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (PracticeType.century): {
|
case (PracticeType.century): {
|
||||||
this.practiceThing = PracticeThingCentury();
|
this.practiceThing = PracticeThingCentury(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (PracticeType.leap): {
|
case (PracticeType.leap): {
|
||||||
this.practiceThing = PracticeThingLeap();
|
this.practiceThing = PracticeThingLeap(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (PracticeType.mod): {
|
case (PracticeType.mod): {
|
||||||
this.practiceThing = PracticeThingMod();
|
this.practiceThing = PracticeThingMod(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (PracticeType.all): {
|
case (PracticeType.all): {
|
||||||
this.practiceThing = PracticeThingAll();
|
this.practiceThing = PracticeThingAll(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,38 +77,6 @@ class _PracticeState extends State<PracticePage> {
|
||||||
return Row(children: answerBoxes);
|
return Row(children: answerBoxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getButtons(){
|
|
||||||
List<Widget> buttons = List<Widget>();
|
|
||||||
for(int i in [1,2,3,4,5,6,-1,0,-1]){
|
|
||||||
if (i == -1){
|
|
||||||
buttons.add(Container());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
buttons.add(
|
|
||||||
FlatButton(
|
|
||||||
onPressed: () {
|
|
||||||
checkAnswer(i);
|
|
||||||
},
|
|
||||||
color: Colors.blue,
|
|
||||||
textColor: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
i.toString(),
|
|
||||||
style: TextStyle(fontSize: 30)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return GridView.count(
|
|
||||||
primary: false,
|
|
||||||
crossAxisCount: 3,
|
|
||||||
padding: EdgeInsets.fromLTRB(0, 20, 0, 20),
|
|
||||||
mainAxisSpacing: 10,
|
|
||||||
crossAxisSpacing: 10,
|
|
||||||
shrinkWrap: true,
|
|
||||||
children: buttons
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleDialog finishedPracticeDialog() {
|
SimpleDialog finishedPracticeDialog() {
|
||||||
return SimpleDialog(
|
return SimpleDialog(
|
||||||
title: Text(
|
title: Text(
|
||||||
|
@ -203,7 +170,7 @@ class _PracticeState extends State<PracticePage> {
|
||||||
practiceThing.getCurrentQuestionText()
|
practiceThing.getCurrentQuestionText()
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
getButtons(),
|
practiceThing.getButtons(),
|
||||||
Align(
|
Align(
|
||||||
alignment: FractionalOffset.bottomCenter,
|
alignment: FractionalOffset.bottomCenter,
|
||||||
child: getAnswerRow()
|
child: getAnswerRow()
|
||||||
|
|
|
@ -3,11 +3,18 @@ import 'dart:math';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
||||||
|
import 'package:ohthatsa/pages/practice/PracticePage.dart';
|
||||||
|
|
||||||
abstract class PracticeThing {
|
abstract class PracticeThing {
|
||||||
final random = Random();
|
final random = Random();
|
||||||
final List<PracticeAnswer> answers = new List<PracticeAnswer>();
|
final List<PracticeAnswer> answers = new List<PracticeAnswer>();
|
||||||
|
|
||||||
|
final PracticePageState practicePageState;
|
||||||
|
|
||||||
|
PracticeThing(this.practicePageState){
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
|
||||||
bool isCorrect(int answer);
|
bool isCorrect(int answer);
|
||||||
bool answer(int answer);
|
bool answer(int answer);
|
||||||
void next();
|
void next();
|
||||||
|
@ -16,4 +23,36 @@ abstract class PracticeThing {
|
||||||
Text getCurrentQuestionText();
|
Text getCurrentQuestionText();
|
||||||
Text getLastAnswerText(bool showCorrect);
|
Text getLastAnswerText(bool showCorrect);
|
||||||
Text getSecondLastAnswerText(bool showCorrect);
|
Text getSecondLastAnswerText(bool showCorrect);
|
||||||
|
|
||||||
|
Widget getButtons(){
|
||||||
|
List<Widget> buttons = List<Widget>();
|
||||||
|
for(int i in [1,2,3,4,5,6,-1,0,-1]){
|
||||||
|
if (i == -1){
|
||||||
|
buttons.add(Container());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
buttons.add(
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () {
|
||||||
|
practicePageState.checkAnswer(i);
|
||||||
|
},
|
||||||
|
color: Colors.blue,
|
||||||
|
textColor: Colors.white,
|
||||||
|
child: Text(
|
||||||
|
i.toString(),
|
||||||
|
style: TextStyle(fontSize: 30)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return GridView.count(
|
||||||
|
primary: false,
|
||||||
|
crossAxisCount: 3,
|
||||||
|
padding: EdgeInsets.fromLTRB(0, 20, 0, 20),
|
||||||
|
mainAxisSpacing: 10,
|
||||||
|
crossAxisSpacing: 10,
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: buttons
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:flutter/src/widgets/text.dart';
|
import 'package:flutter/src/widgets/text.dart';
|
||||||
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
||||||
|
import 'package:ohthatsa/pages/practice/PracticePage.dart';
|
||||||
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
||||||
|
|
||||||
class PracticeThingAll extends PracticeThing {
|
class PracticeThingAll extends PracticeThing {
|
||||||
|
@ -23,7 +24,7 @@ class PracticeThingAll extends PracticeThing {
|
||||||
DateTime.december
|
DateTime.december
|
||||||
];
|
];
|
||||||
|
|
||||||
PracticeThingAll() {
|
PracticeThingAll(PracticePageState practicePageState) : super(practicePageState) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,14 @@ import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
||||||
|
import 'package:ohthatsa/pages/practice/PracticePage.dart';
|
||||||
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
||||||
import 'package:ohthatsa/util/DayCalculator.dart';
|
import 'package:ohthatsa/util/DayCalculator.dart';
|
||||||
|
|
||||||
class PracticeThingCentury extends PracticeThing {
|
class PracticeThingCentury extends PracticeThing {
|
||||||
int current;
|
int current;
|
||||||
|
|
||||||
PracticeThingCentury(){
|
PracticeThingCentury(PracticePageState practicePageState) : super(practicePageState) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/src/widgets/text.dart';
|
import 'package:flutter/src/widgets/text.dart';
|
||||||
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
||||||
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
||||||
import 'package:ohthatsa/pages/practice/PracticeType.dart';
|
import 'package:ohthatsa/pages/practice/PracticePage.dart';
|
||||||
import 'package:ohthatsa/util/DayCalculator.dart';
|
import 'package:ohthatsa/util/DayCalculator.dart';
|
||||||
|
|
||||||
class PracticeThingLeap extends PracticeThing {
|
class PracticeThingLeap extends PracticeThing {
|
||||||
int current;
|
int current;
|
||||||
|
|
||||||
PracticeThingLeap(){
|
PracticeThingLeap(PracticePageState practicePageState) : super(practicePageState) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,4 +87,37 @@ class PracticeThingLeap extends PracticeThing {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget getButtons(){
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.fromLTRB(0, 20, 0, 20),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () {
|
||||||
|
practicePageState.checkAnswer(0);
|
||||||
|
},
|
||||||
|
color: Colors.blue,
|
||||||
|
textColor: Colors.white,
|
||||||
|
child: Text(
|
||||||
|
"0",
|
||||||
|
style: TextStyle(fontSize: 30)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () {
|
||||||
|
practicePageState.checkAnswer(1);
|
||||||
|
},
|
||||||
|
color: Colors.blue,
|
||||||
|
textColor: Colors.white,
|
||||||
|
child: Text(
|
||||||
|
"1",
|
||||||
|
style: TextStyle(fontSize: 30)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,13 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
||||||
|
import 'package:ohthatsa/pages/practice/PracticePage.dart';
|
||||||
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
||||||
import 'package:ohthatsa/pages/practice/PracticeType.dart';
|
import 'package:ohthatsa/pages/practice/PracticeType.dart';
|
||||||
|
|
||||||
class PracticeThingMod extends PracticeThing {
|
class PracticeThingMod extends PracticeThing {
|
||||||
int current;
|
int current;
|
||||||
|
|
||||||
PracticeThingMod() {
|
PracticeThingMod(PracticePageState practicePageState) : super(practicePageState) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:ohthatsa/pages/practice/PracticePage.dart';
|
||||||
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
||||||
import 'package:ohthatsa/pages/practice/PracticeType.dart';
|
import 'package:ohthatsa/pages/practice/PracticeType.dart';
|
||||||
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
||||||
|
@ -11,7 +12,7 @@ class PracticeThingMonth extends PracticeThing {
|
||||||
|
|
||||||
Month current;
|
Month current;
|
||||||
|
|
||||||
PracticeThingMonth(){
|
PracticeThingMonth(PracticePageState practicePageState) : super(practicePageState) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
||||||
|
import 'package:ohthatsa/pages/practice/PracticePage.dart';
|
||||||
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
||||||
import 'package:ohthatsa/util/DayCalculator.dart';
|
import 'package:ohthatsa/util/DayCalculator.dart';
|
||||||
|
|
||||||
class PracticeThingYear extends PracticeThing {
|
class PracticeThingYear extends PracticeThing {
|
||||||
int current;
|
int current;
|
||||||
|
|
||||||
PracticeThingYear() {
|
PracticeThingYear(PracticePageState practicePageState) : super(practicePageState) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue