From bc8b08bcf4a3e2c66230670ff3d8b06ac976e0bc Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Mon, 16 Nov 2020 19:51:40 +0100 Subject: [PATCH] Got single value working for month practice 7d --- lib/pages/practice/PracticeSetupPage.dart | 154 +++++++--------------- 1 file changed, 51 insertions(+), 103 deletions(-) diff --git a/lib/pages/practice/PracticeSetupPage.dart b/lib/pages/practice/PracticeSetupPage.dart index 3e4b23f..c8f6950 100644 --- a/lib/pages/practice/PracticeSetupPage.dart +++ b/lib/pages/practice/PracticeSetupPage.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.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/PracticeType.dart'; @@ -12,6 +13,19 @@ class PracticeSetupPage extends StatefulWidget { class _PracticeSetupState extends State { int _count = 12; bool _showCorrect = true; + + Future> _answerStats; + + @override + void initState() { + this._answerStats = PracticeDatabase.getStats(); + super.initState(); + } + + Table getStatsTable(BuildContext context, AsyncSnapshot> snapshot){ + + } + @override Widget build(BuildContext context){ return Scaffold( @@ -53,112 +67,46 @@ class _PracticeSetupState extends State { } ), Spacer(), - Table( - border: TableBorder( - //horizontalInside: BorderSide(), - //verticalInside: BorderSide() - ), - children: [ - TableRow( - children: [ - // Header - Text(""), - Text("7d", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), - Text("30d", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), - Text("All", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)) - ] - ), - TableRow( - children: [ - FlatButton( - child: Text("Month"), - color: Colors.blue, - textColor: Colors.white, - onPressed: () { - Navigator.pushNamed( - context, - '/practice/practice', - arguments: PracticeSetup(_count, _showCorrect, PracticeType.month) - ); - }, + FutureBuilder>( + future: _answerStats, + builder: (BuildContext context, AsyncSnapshot> snapshot){ + return Table( + children: [ + TableRow( + children: [ // Header + Text(""), + Text("7d", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), + Text("30d", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)), + Text("All", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)) + ] ), - Text("85%", 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: [ - FlatButton( - child: Text("Century"), - color: Colors.blue, - textColor: Colors.white, - onPressed: () { - Navigator.pushNamed( - context, - '/practice/practice', - arguments: PracticeSetup(_count, _showCorrect, PracticeType.century) - ); - }, + TableRow( + children: [ + FlatButton( + child: Text("Month"), + color: Colors.blue, + textColor: Colors.white, + onPressed: () { + Navigator.pushNamed( + context, + '/practice/practice', + arguments: PracticeSetup(_count, _showCorrect, PracticeType.month) + ); + }, + ), + 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("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)) + ] ), - 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: [ - 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: [ - 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: [ - 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)) - ] - ), - ] - ), + ); + } + ) ] ) )