diff --git a/lib/main.dart b/lib/main.dart index f00f7d7..a4ab49d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -80,11 +80,18 @@ class MainPageState extends State { builder: (context) => Column(children: [ Padding( padding: const EdgeInsets.all(8), - child: Text(v.name, - style: const TextStyle( - fontSize: 20.0, - fontWeight: FontWeight.bold, - ))), + child: Column(children: [ + Text(v.name, + style: const TextStyle( + fontSize: 20.0, + fontWeight: FontWeight.bold, + )), + Text('Stats: ${v.txtVals()}', + style: const TextStyle( + fontSize: 10.0, + fontWeight: FontWeight.bold, + )) + ])), ListTile( leading: const Icon(Icons.restore), title: const Text("Reset Vault"), @@ -195,8 +202,6 @@ class MainPageState extends State { } } - - @override Widget build(BuildContext context) { return Scaffold( @@ -213,7 +218,8 @@ class MainPageState extends State { onPressed: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => QuizPage(e, saveStateList)), + MaterialPageRoute( + builder: (context) => QuizPage(e, saveStateList)), ); }, onLongPress: () { @@ -303,6 +309,23 @@ class Vault { } } + (int, double, int) vals() { + int min = 0xffffff; + int total = 0; + int max = 0; + for (var q in questions) { + if (q.drawer > max) max = q.drawer; + if (q.drawer < min) min = q.drawer; + total += q.drawer; + } + return (min, total.toDouble() / questions.length, max); + } + + String txtVals(){ + var (min, avg, max) = vals(); + return '($min, ${(avg*100).round()/100.0}, $max)'; + } + factory Vault.fromJson(Map json) { if (json["name"] is! String) { throw ErrorDescription("fromJSON Error: name");