stats
This commit is contained in:
parent
364ea48bcd
commit
0c55e59bce
1 changed files with 31 additions and 8 deletions
|
@ -80,11 +80,18 @@ class MainPageState extends State<MainPage> {
|
|||
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<MainPage> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
@ -213,7 +218,8 @@ class MainPageState extends State<MainPage> {
|
|||
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<String, dynamic> json) {
|
||||
if (json["name"] is! String) {
|
||||
throw ErrorDescription("fromJSON Error: name");
|
||||
|
|
Loading…
Reference in a new issue