Renamed every instance of "game" to "match"
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
import 'package:game_tracker/data/dto/game.dart';
|
||||
import 'package:game_tracker/data/dto/match.dart';
|
||||
import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class GameHistoryTile extends StatefulWidget {
|
||||
final Game game;
|
||||
final Match match;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const GameHistoryTile({super.key, required this.game, required this.onTap});
|
||||
const GameHistoryTile({super.key, required this.match, required this.onTap});
|
||||
|
||||
@override
|
||||
State<GameHistoryTile> createState() => _GameHistoryTileState();
|
||||
@@ -17,8 +17,8 @@ class GameHistoryTile extends StatefulWidget {
|
||||
class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final group = widget.game.group;
|
||||
final winner = widget.game.winner;
|
||||
final group = widget.match.group;
|
||||
final winner = widget.match.winner;
|
||||
final allPlayers = _getAllPlayers();
|
||||
|
||||
return GestureDetector(
|
||||
@@ -39,7 +39,7 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.game.name,
|
||||
widget.match.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -48,7 +48,7 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
_formatDate(widget.game.createdAt),
|
||||
_formatDate(widget.match.createdAt),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
@@ -156,8 +156,8 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
final playerIds = <String>{};
|
||||
|
||||
// Add players from game.players
|
||||
if (widget.game.players != null) {
|
||||
for (var player in widget.game.players!) {
|
||||
if (widget.match.players != null) {
|
||||
for (var player in widget.match.players!) {
|
||||
if (!playerIds.contains(player.id)) {
|
||||
allPlayers.add(player);
|
||||
playerIds.add(player.id);
|
||||
@@ -166,8 +166,8 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||
}
|
||||
|
||||
// Add players from game.group.players
|
||||
if (widget.game.group?.members != null) {
|
||||
for (var player in widget.game.group!.members) {
|
||||
if (widget.match.group?.members != null) {
|
||||
for (var player in widget.match.group!.members) {
|
||||
if (!playerIds.contains(player.id)) {
|
||||
allPlayers.add(player);
|
||||
playerIds.add(player.id);
|
||||
|
||||
@@ -2,27 +2,27 @@ import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
|
||||
class GameTile extends StatefulWidget {
|
||||
final String gameTitle;
|
||||
final String gameType;
|
||||
class MatchTile extends StatefulWidget {
|
||||
final String matchTitle;
|
||||
final String game;
|
||||
final String ruleset;
|
||||
final String players;
|
||||
final String winner;
|
||||
|
||||
const GameTile({
|
||||
const MatchTile({
|
||||
super.key,
|
||||
required this.gameTitle,
|
||||
required this.gameType,
|
||||
required this.matchTitle,
|
||||
required this.game,
|
||||
required this.ruleset,
|
||||
required this.players,
|
||||
required this.winner,
|
||||
});
|
||||
|
||||
@override
|
||||
State<GameTile> createState() => _GameTileState();
|
||||
State<MatchTile> createState() => _MatchTileState();
|
||||
}
|
||||
|
||||
class _GameTileState extends State<GameTile> {
|
||||
class _MatchTileState extends State<MatchTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
@@ -31,12 +31,12 @@ class _GameTileState extends State<GameTile> {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
widget.gameTitle,
|
||||
widget.matchTitle,
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
widget.gameType,
|
||||
widget.game,
|
||||
style: const TextStyle(fontSize: 14, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -40,11 +40,11 @@ class StatisticsTile extends StatelessWidget {
|
||||
child: Column(
|
||||
children: List.generate(min(values.length, itemCount), (index) {
|
||||
/// The maximum wins among all players
|
||||
final maxGames = values.isNotEmpty ? values[0].$2 : 0;
|
||||
final maxMatches = values.isNotEmpty ? values[0].$2 : 0;
|
||||
|
||||
/// Fraction of wins
|
||||
final double fraction = (maxGames > 0)
|
||||
? (values[index].$2 / maxGames)
|
||||
final double fraction = (maxMatches > 0)
|
||||
? (values[index].$2 / maxMatches)
|
||||
: 0.0;
|
||||
|
||||
/// Calculated width for current the bar
|
||||
|
||||
Reference in New Issue
Block a user