This commit is contained in:
jusax23 2023-06-01 21:40:16 +02:00
parent 364ea48bcd
commit 0c55e59bce
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41

View file

@ -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: [
Text(v.name,
style: const TextStyle( style: const TextStyle(
fontSize: 20.0, fontSize: 20.0,
fontWeight: FontWeight.bold, 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");