summaryrefslogtreecommitdiff
path: root/lib/game_over_stats.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/game_over_stats.dart')
-rw-r--r--lib/game_over_stats.dart63
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/game_over_stats.dart b/lib/game_over_stats.dart
new file mode 100644
index 0000000..0e73024
--- /dev/null
+++ b/lib/game_over_stats.dart
@@ -0,0 +1,63 @@
+import 'package:flutter/material.dart';
+import 'package:sense_the_rhythm/arrows.dart';
+import 'package:sense_the_rhythm/level.dart';
+import 'package:sense_the_rhythm/simfile.dart';
+
+class GameOverStats extends StatelessWidget {
+ const GameOverStats({super.key, required this.simfile, required this.notes});
+
+ final Simfile simfile;
+ final List<Note> notes;
+
+ @override
+ Widget build(BuildContext context) {
+ int hits = notes.where((note) => note.wasHit == true).length;
+ int misses = notes.where((note) => note.wasHit == false).length;
+ int total = notes.length;
+ int percent = (hits.toDouble() / total.toDouble() * 100).toInt();
+
+ return Scaffold(
+ appBar: AppBar(
+ leading: IconButton(
+ onPressed: () => Navigator.pop(context),
+ icon: Icon(Icons.arrow_back)),
+ title: Text('Game Stats'),
+ ),
+ body: Center(
+ child: Column(
+ children: [
+ Text(' $percent%',
+ style: TextStyle(
+ fontSize: 60,
+ fontWeight: FontWeight.bold,
+ color: Colors.orange)),
+ DataTable(columns: [
+ DataColumn(label: Container()),
+ DataColumn(label: Container()),
+ ], rows: [
+ DataRow(cells: [
+ DataCell(Text('Hits')),
+ DataCell(Text(hits.toString())),
+ ]),
+ DataRow(cells: [
+ DataCell(Text('Misses')),
+ DataCell(Text(misses.toString())),
+ ]),
+ DataRow(cells: [
+ DataCell(Text('Total')),
+ DataCell(Text(total.toString())),
+ ]),
+ ]),
+ TextButton(
+ onPressed: () {
+ Route route =
+ MaterialPageRoute(builder: (context) => Level(simfile));
+ Navigator.pushReplacement(context, route);
+ },
+ child: Text('Retry'))
+ ],
+ ),
+ ),
+ );
+ }
+}