GameResultView erstellen #62
@@ -6,142 +6,132 @@ import 'package:intl/intl.dart';
|
|||||||
|
|
||||||
class GameHistoryTile extends StatefulWidget {
|
class GameHistoryTile extends StatefulWidget {
|
||||||
final Game game;
|
final Game game;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
const GameHistoryTile({
|
const GameHistoryTile({super.key, required this.game, required this.onTap});
|
||||||
super.key,
|
|
||||||
required this.game,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<GameHistoryTile> createState() => _GameHistoryTileState();
|
State<GameHistoryTile> createState() => _GameHistoryTileState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GameHistoryTileState extends State<GameHistoryTile> {
|
class _GameHistoryTileState extends State<GameHistoryTile> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final group = widget.game.group;
|
final group = widget.game.group;
|
||||||
final winner = widget.game.winner;
|
final winner = widget.game.winner;
|
||||||
final allPlayers = _getAllPlayers();
|
final allPlayers = _getAllPlayers();
|
||||||
|
|
||||||
return Container(
|
return GestureDetector(
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
onTap: widget.onTap,
|
||||||
padding: const EdgeInsets.all(16),
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
color: CustomTheme.boxColor,
|
padding: const EdgeInsets.all(16),
|
||||||
border: Border.all(color: CustomTheme.boxBorder),
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(12),
|
color: CustomTheme.boxColor,
|
||||||
),
|
border: Border.all(color: CustomTheme.boxBorder),
|
||||||
child: Column(
|
borderRadius: BorderRadius.circular(12),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
),
|
||||||
children: [
|
child: Column(
|
||||||
Row(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: [
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
widget.game.name,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
_formatDate(widget.game.createdAt),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
|
|
||||||
if (group != null) ...[
|
|
||||||
Row(
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Icon(
|
|
||||||
Icons.group,
|
|
||||||
size: 16,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
group.name,
|
widget.game.name,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 18,
|
||||||
color: Colors.grey,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Text(
|
||||||
|
_formatDate(widget.game.createdAt),
|
||||||
|
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
|
||||||
],
|
|
||||||
|
|
||||||
if (winner != null) ...[
|
const SizedBox(height: 8),
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
|
if (group != null) ...[
|
||||||
decoration: BoxDecoration(
|
Row(
|
||||||
color: Colors.green.withValues(alpha: 0.1),
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.green.withValues(alpha: 0.3),
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
children: [
|
||||||
const Icon(
|
const Icon(Icons.group, size: 16, color: Colors.grey),
|
||||||
Icons.emoji_events,
|
const SizedBox(width: 6),
|
||||||
size: 20,
|
|
||||||
color: Colors.amber,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Winner: ${winner.name}',
|
group.name,
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 14, color: Colors.grey),
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 12),
|
||||||
const SizedBox(height: 12),
|
],
|
||||||
],
|
|
||||||
|
|
||||||
if (allPlayers.isNotEmpty) ...[
|
if (winner != null) ...[
|
||||||
const Text(
|
Container(
|
||||||
'Players',
|
padding: const EdgeInsets.symmetric(
|
||||||
style: TextStyle(
|
vertical: 8,
|
||||||
fontSize: 13,
|
horizontal: 12,
|
||||||
color: Colors.grey,
|
),
|
||||||
fontWeight: FontWeight.w500,
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.green.withValues(alpha: 0.1),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.green.withValues(alpha: 0.3),
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.emoji_events,
|
||||||
|
size: 20,
|
||||||
|
color: Colors.amber,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'Winner: ${winner.name}',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 12),
|
||||||
const SizedBox(height: 6),
|
],
|
||||||
Wrap(
|
|
||||||
spacing: 6,
|
if (allPlayers.isNotEmpty) ...[
|
||||||
runSpacing: 6,
|
const Text(
|
||||||
children: allPlayers.map((player) {
|
'Players',
|
||||||
return TextIconTile(
|
style: TextStyle(
|
||||||
text: player.name,
|
fontSize: 13,
|
||||||
iconEnabled: false,
|
color: Colors.grey,
|
||||||
);
|
fontWeight: FontWeight.w500,
|
||||||
}).toList(),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Wrap(
|
||||||
|
spacing: 6,
|
||||||
|
runSpacing: 6,
|
||||||
|
children: allPlayers.map((player) {
|
||||||
|
return TextIconTile(text: player.name, iconEnabled: false);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -187,5 +177,4 @@ class _GameHistoryTileState extends State<GameHistoryTile> {
|
|||||||
|
|
||||||
return allPlayers;
|
return allPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user