3 Commits

Author SHA1 Message Date
gelbeinhalb
8c005d6e5e fix possible render overflow
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m9s
Pull Request Pipeline / lint (pull_request) Successful in 2m10s
2025-11-27 17:06:32 +01:00
gelbeinhalb
cc50e497c9 merge duplicate if statements for group and winner sections 2025-11-27 17:04:08 +01:00
gelbeinhalb
ae348499d4 moved functionality methods to the bottom of the file 2025-11-27 17:00:13 +01:00

View File

@@ -17,47 +17,6 @@ class GameHistoryTile extends StatefulWidget {
} }
class _GameHistoryTileState extends State<GameHistoryTile> { class _GameHistoryTileState extends State<GameHistoryTile> {
String _formatDate(DateTime dateTime) {
final now = DateTime.now();
final difference = now.difference(dateTime);
if (difference.inDays == 0) {
return 'Today at ${DateFormat('HH:mm').format(dateTime)}';
} else if (difference.inDays == 1) {
return 'Yesterday at ${DateFormat('HH:mm').format(dateTime)}';
} else if (difference.inDays < 7) {
return '${difference.inDays} days ago';
} else {
return DateFormat('MMM d, yyyy').format(dateTime);
}
}
List<dynamic> _getAllPlayers() {
final allPlayers = <dynamic>[];
final playerIds = <String>{};
// Add players from game.players
if (widget.game.players != null) {
for (var player in widget.game.players!) {
if (!playerIds.contains(player.id)) {
allPlayers.add(player);
playerIds.add(player.id);
}
}
}
// Add players from game.group.players
if (widget.game.group?.members != null) {
for (var player in widget.game.group!.members) {
if (!playerIds.contains(player.id)) {
allPlayers.add(player);
playerIds.add(player.id);
}
}
}
return allPlayers;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -101,7 +60,7 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
const SizedBox(height: 8), const SizedBox(height: 8),
if (group != null) if (group != null) ...[
Row( Row(
children: [ children: [
const Icon( const Icon(
@@ -122,10 +81,10 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
), ),
], ],
), ),
const SizedBox(height: 12),
],
if (group != null) const SizedBox(height: 12), if (winner != null) ...[
if (winner != null)
Container( Container(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12), padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -144,19 +103,22 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
color: Colors.amber, color: Colors.amber,
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
Text( Expanded(
'Winner: ${winner.name}', child: Text(
style: const TextStyle( 'Winner: ${winner.name}',
fontSize: 14, style: const TextStyle(
fontWeight: FontWeight.w600, fontSize: 14,
color: Colors.white, fontWeight: FontWeight.w600,
color: Colors.white,
),
overflow: TextOverflow.ellipsis,
), ),
), ),
], ],
), ),
), ),
const SizedBox(height: 12),
if (winner != null) const SizedBox(height: 12), ],
if (allPlayers.isNotEmpty) ...[ if (allPlayers.isNotEmpty) ...[
const Text( const Text(
@@ -172,7 +134,6 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
spacing: 6, spacing: 6,
runSpacing: 6, runSpacing: 6,
children: allPlayers.map((player) { children: allPlayers.map((player) {
final isWinner = winner != null && player.id == winner.id;
return TextIconTile( return TextIconTile(
text: player.name, text: player.name,
iconEnabled: false, iconEnabled: false,
@@ -184,4 +145,47 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
), ),
); );
} }
String _formatDate(DateTime dateTime) {
final now = DateTime.now();
final difference = now.difference(dateTime);
if (difference.inDays == 0) {
return 'Today at ${DateFormat('HH:mm').format(dateTime)}';
} else if (difference.inDays == 1) {
return 'Yesterday at ${DateFormat('HH:mm').format(dateTime)}';
} else if (difference.inDays < 7) {
return '${difference.inDays} days ago';
} else {
return DateFormat('MMM d, yyyy').format(dateTime);
}
}
List<dynamic> _getAllPlayers() {
final allPlayers = <dynamic>[];
final playerIds = <String>{};
// Add players from game.players
if (widget.game.players != null) {
for (var player in widget.game.players!) {
if (!playerIds.contains(player.id)) {
allPlayers.add(player);
playerIds.add(player.id);
}
}
}
// Add players from game.group.players
if (widget.game.group?.members != null) {
for (var player in widget.game.group!.members) {
if (!playerIds.contains(player.id)) {
allPlayers.add(player);
playerIds.add(player.id);
}
}
}
return allPlayers;
}
} }