64 lines
2 KiB
Dart
64 lines
2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:sense_the_rhythm/models/note.dart';
|
|
import 'package:sense_the_rhythm/utils/simfile.dart';
|
|
import 'package:sense_the_rhythm/screens/level.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'))
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|