From 685323adeab3d27bff4df16a201f9f14688475d5 Mon Sep 17 00:00:00 2001 From: Orangerot Date: Tue, 7 Jan 2025 06:05:28 +0100 Subject: feat: GameOverStats Widgets shows stats after a course --- lib/game_over_stats.dart | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 lib/game_over_stats.dart (limited to 'lib/game_over_stats.dart') diff --git a/lib/game_over_stats.dart b/lib/game_over_stats.dart new file mode 100644 index 0000000..a80617c --- /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 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(stepmaniaFolderPath: simfile.directoryPath)); + Navigator.pushReplacement(context, route); + }, + child: Text('Retry')) + ], + ), + ), + ); + } +} -- cgit v1.2.3