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: [
|
builder: (context) => Column(children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Text(v.name,
|
child: Column(children: [
|
||||||
style: const TextStyle(
|
Text(v.name,
|
||||||
fontSize: 20.0,
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontSize: 20.0,
|
||||||
))),
|
fontWeight: FontWeight.bold,
|
||||||
|
)),
|
||||||
|
Text('Stats: ${v.txtVals()}',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 10.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
))
|
||||||
|
])),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.restore),
|
leading: const Icon(Icons.restore),
|
||||||
title: const Text("Reset Vault"),
|
title: const Text("Reset Vault"),
|
||||||
|
@ -195,8 +202,6 @@ class MainPageState extends State<MainPage> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -213,7 +218,8 @@ class MainPageState extends State<MainPage> {
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => QuizPage(e, saveStateList)),
|
MaterialPageRoute(
|
||||||
|
builder: (context) => QuizPage(e, saveStateList)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onLongPress: () {
|
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) {
|
factory Vault.fromJson(Map<String, dynamic> json) {
|
||||||
if (json["name"] is! String) {
|
if (json["name"] is! String) {
|
||||||
throw ErrorDescription("fromJSON Error: name");
|
throw ErrorDescription("fromJSON Error: name");
|
||||||
|
|
Loading…
Reference in a new issue