Got single value working for month practice 7d

This commit is contained in:
BroodjeAap 2020-11-16 19:51:40 +01:00
parent 3a25d17c94
commit bc8b08bcf4

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:numberpicker/numberpicker.dart'; import 'package:numberpicker/numberpicker.dart';
import 'package:ohthatsa/AppDrawer.dart'; import 'package:ohthatsa/AppDrawer.dart';
import 'package:ohthatsa/pages/practice/PracticeDatabase.dart';
import 'package:ohthatsa/pages/practice/PracticeSetup.dart'; import 'package:ohthatsa/pages/practice/PracticeSetup.dart';
import 'package:ohthatsa/pages/practice/PracticeType.dart'; import 'package:ohthatsa/pages/practice/PracticeType.dart';
@ -12,6 +13,19 @@ class PracticeSetupPage extends StatefulWidget {
class _PracticeSetupState extends State<PracticeSetupPage> { class _PracticeSetupState extends State<PracticeSetupPage> {
int _count = 12; int _count = 12;
bool _showCorrect = true; bool _showCorrect = true;
Future<Map<String, double>> _answerStats;
@override
void initState() {
this._answerStats = PracticeDatabase.getStats();
super.initState();
}
Table getStatsTable(BuildContext context, AsyncSnapshot<Map<String, double>> snapshot){
}
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return Scaffold( return Scaffold(
@ -53,15 +67,13 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
} }
), ),
Spacer(), Spacer(),
Table( FutureBuilder<Map<String, double>>(
border: TableBorder( future: _answerStats,
//horizontalInside: BorderSide(), builder: (BuildContext context, AsyncSnapshot<Map<String, double>> snapshot){
//verticalInside: BorderSide() return Table(
),
children: <TableRow>[ children: <TableRow>[
TableRow( TableRow(
children: <Widget>[ children: <Widget>[ // Header
// Header
Text(""), Text(""),
Text("7d", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), Text("7d", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
Text("30d", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), Text("30d", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
@ -82,83 +94,19 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
); );
}, },
), ),
Text("85%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), Text(
snapshot.hasData ?
snapshot.data["All month"].round().toString() + "%" : "-",
textAlign: TextAlign.center, style: TextStyle(fontSize: 25)
),
Text("70%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), Text("70%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
Text("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)) Text("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25))
] ]
), ),
TableRow( ]
children: <Widget>[
FlatButton(
child: Text("Century"),
color: Colors.blue,
textColor: Colors.white,
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)),
Text("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25))
]
),
TableRow(
children: <Widget>[
FlatButton(
child: Text("Leap"),
color: Colors.blue,
textColor: Colors.white,
onPressed: () {
Navigator.pushNamed(
context,
'/practice/practice',
arguments: PracticeSetup(_count, _showCorrect, PracticeType.leap)
);
},
),
Text("80%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
Text("70%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
Text("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25))
]
),
TableRow(
children: <Widget>[
FlatButton(
child: Text("Modulo 7"),
color: Colors.blue,
textColor: Colors.white,
onPressed: () {
Navigator.pushNamed(
context,
'/practice/practice',
arguments: PracticeSetup(_count, _showCorrect, PracticeType.mod)
);
},
),
Text("80%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
Text("70%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
Text("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25))
]
),
TableRow(
children: <Widget>[
FlatButton(
child: Text("All"),
color: Colors.blue,
textColor: Colors.white,
onPressed: () {},
),
Text("80%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
Text("70%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
Text("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25))
]
),
]
),
] ]
) )
) )