From 2de8cef18dee21340a27a93f11ce6e93767499ff Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sun, 17 May 2026 23:35:02 +0200 Subject: [PATCH] feat: implemented teams im match tile --- .../widgets/tiles/match_tile.dart | 130 ++++++++++++++++-- pubspec.yaml | 2 +- 2 files changed, 122 insertions(+), 10 deletions(-) diff --git a/lib/presentation/widgets/tiles/match_tile.dart b/lib/presentation/widgets/tiles/match_tile.dart index 9274838..8337c59 100644 --- a/lib/presentation/widgets/tiles/match_tile.dart +++ b/lib/presentation/widgets/tiles/match_tile.dart @@ -128,14 +128,41 @@ class _MatchTileState extends State { const SizedBox(height: 12), - Text( - 'team match: ${match.isTeamMatch}', - style: const TextStyle(fontSize: 14, color: Colors.white), - ), - - const SizedBox(height: 12), // Winner / In Progress Info - if (match.mvp.isNotEmpty) ...[ + if (match.isTeamMatch && match.mvt.isNotEmpty) ...[ + Container( + padding: const EdgeInsets.symmetric( + vertical: 8, + horizontal: 12, + ), + 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: [ + getMvpIcon(), + const SizedBox(width: 8), + Expanded( + child: Text( + getMvtText(loc), + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: CustomTheme.textColor, + ), + overflow: TextOverflow.ellipsis, + ), + ), + ], + ), + ), + const SizedBox(height: 12), + ] else if (match.mvp.isNotEmpty) ...[ Container( padding: const EdgeInsets.symmetric( vertical: 8, @@ -207,8 +234,69 @@ class _MatchTileState extends State { const SizedBox(height: 12), ], - // Players List - if (players.isNotEmpty && widget.compact == false) ...[ + if (match.teams != null && match.teams!.isNotEmpty) ...[ + const Text( + 'Teams', + style: TextStyle( + fontSize: 13, + color: Colors.grey, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + for (var team in match.teams!) ...[ + Container( + width: double.infinity, + padding: const EdgeInsets.symmetric( + vertical: 6, + horizontal: 12, + ), + decoration: BoxDecoration( + color: getColorFromGameColor( + team.color, + ).withValues(alpha: 0.1), + borderRadius: BorderRadius.circular(8), + border: Border.all( + color: getColorFromGameColor( + team.color, + ).withValues(alpha: 0.3), + width: 1, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + team.name, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: CustomTheme.textColor, + ), + ), + Wrap( + spacing: 6, + runSpacing: 6, + children: team.members.map((player) { + return TextIconTile( + text: player.name, + suffixText: getNameCountText(player), + iconEnabled: false, + ); + }).toList(), + ), + ], + ), + ), + const SizedBox(height: 12), + ], + ], + ), + const SizedBox(height: 12), + ] else if (players.isNotEmpty && widget.compact == false) ...[ Text( loc.players, style: const TextStyle( @@ -274,6 +362,30 @@ class _MatchTileState extends State { return '${loc.winner}: n.A.'; } + String getMvtText(AppLocalizations loc) { + if (widget.match.mvt.isEmpty) return ''; + final ruleset = widget.match.game.ruleset; + + if (ruleset == Ruleset.singleWinner) { + return '${loc.winner}: ${widget.match.mvt.first.name}'; + } else if (ruleset == Ruleset.singleLoser) { + return '${loc.loser}: ${widget.match.mvt.first.name}'; + } else if (ruleset == Ruleset.highestScore || + ruleset == Ruleset.lowestScore) { + final mvt = widget.match.mvt; + final mvtScore = + widget.match.teams! + .firstWhere((team) => team.id == mvt.first.id) + .score ?? + 0; + final mvtNames = mvt.map((team) => team.name).join(', '); + return '${loc.winner}: $mvtNames (${getPointLabel(loc, mvtScore)})'; + } else if (ruleset == Ruleset.placement) { + return '${loc.winner}: ${widget.match.mvt.first.name}'; + } + return '${loc.winner}: n.A.'; + } + Icon getMvpIcon() { final icon = getRulesetIcon(widget.match.game.ruleset); diff --git a/pubspec.yaml b/pubspec.yaml index 91bc4e4..33dc417 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: tallee description: "Tracking App for Card Games" publish_to: 'none' -version: 0.0.30+285 +version: 0.0.30+287 environment: sdk: ^3.8.1