feat: implemented team card

This commit is contained in:
2026-05-18 00:02:59 +02:00
parent 2de8cef18d
commit d9e0cdf506
10 changed files with 182 additions and 72 deletions

View File

@@ -132,6 +132,7 @@
"statistics": "Statistiken", "statistics": "Statistiken",
"stats": "Statistiken", "stats": "Statistiken",
"successfully_added_player": "Spieler:in {playerName} erfolgreich hinzugefügt", "successfully_added_player": "Spieler:in {playerName} erfolgreich hinzugefügt",
"teams": "Teams",
"there_are_no_games_matching_your_search": "Es gibt keine Spielvorlagen, die deiner Suche entspricht", "there_are_no_games_matching_your_search": "Es gibt keine Spielvorlagen, die deiner Suche entspricht",
"there_is_no_group_matching_your_search": "Es gibt keine Gruppe, die deiner Suche entspricht", "there_is_no_group_matching_your_search": "Es gibt keine Gruppe, die deiner Suche entspricht",
"this_cannot_be_undone": "Dies kann nicht rückgängig gemacht werden.", "this_cannot_be_undone": "Dies kann nicht rückgängig gemacht werden.",

View File

@@ -141,6 +141,7 @@
} }
} }
}, },
"teams": "Teams",
"there_are_no_games_matching_your_search": "There are no games matching your search", "there_are_no_games_matching_your_search": "There are no games matching your search",
"there_is_no_group_matching_your_search": "There is no group matching your search", "there_is_no_group_matching_your_search": "There is no group matching your search",
"this_cannot_be_undone": "This can't be undone.", "this_cannot_be_undone": "This can't be undone.",

View File

@@ -842,6 +842,12 @@ abstract class AppLocalizations {
/// **'Successfully added player {playerName}'** /// **'Successfully added player {playerName}'**
String successfully_added_player(String playerName); String successfully_added_player(String playerName);
/// No description provided for @teams.
///
/// In en, this message translates to:
/// **'Teams'**
String get teams;
/// No description provided for @there_are_no_games_matching_your_search. /// No description provided for @there_are_no_games_matching_your_search.
/// ///
/// In en, this message translates to: /// In en, this message translates to:

View File

@@ -404,6 +404,9 @@ class AppLocalizationsDe extends AppLocalizations {
return 'Spieler:in $playerName erfolgreich hinzugefügt'; return 'Spieler:in $playerName erfolgreich hinzugefügt';
} }
@override
String get teams => 'Teams';
@override @override
String get there_are_no_games_matching_your_search => String get there_are_no_games_matching_your_search =>
'Es gibt keine Spielvorlagen, die deiner Suche entspricht'; 'Es gibt keine Spielvorlagen, die deiner Suche entspricht';

View File

@@ -404,6 +404,9 @@ class AppLocalizationsEn extends AppLocalizations {
return 'Successfully added player $playerName'; return 'Successfully added player $playerName';
} }
@override
String get teams => 'Teams';
@override @override
String get there_are_no_games_matching_your_search => String get there_are_no_games_matching_your_search =>
'There are no games matching your search'; 'There are no games matching your search';

View File

@@ -12,6 +12,7 @@ import 'package:tallee/l10n/generated/app_localizations.dart';
import 'package:tallee/presentation/views/main_menu/match_view/create_match/create_match_view.dart'; import 'package:tallee/presentation/views/main_menu/match_view/create_match/create_match_view.dart';
import 'package:tallee/presentation/views/main_menu/match_view/match_result_view.dart'; import 'package:tallee/presentation/views/main_menu/match_view/match_result_view.dart';
import 'package:tallee/presentation/widgets/buttons/main_menu_button.dart'; import 'package:tallee/presentation/widgets/buttons/main_menu_button.dart';
import 'package:tallee/presentation/widgets/cards/team_card.dart';
import 'package:tallee/presentation/widgets/colored_icon_container.dart'; import 'package:tallee/presentation/widgets/colored_icon_container.dart';
import 'package:tallee/presentation/widgets/dialog/custom_alert_dialog.dart'; import 'package:tallee/presentation/widgets/dialog/custom_alert_dialog.dart';
import 'package:tallee/presentation/widgets/dialog/custom_dialog_action.dart'; import 'package:tallee/presentation/widgets/dialog/custom_dialog_action.dart';
@@ -153,25 +154,43 @@ class _MatchDetailViewState extends State<MatchDetailView> {
const SizedBox(height: 20), const SizedBox(height: 20),
], ],
// Players if (match.isTeamMatch) ...[
InfoTile( // Teams
title: loc.players, InfoTile(
icon: Icons.people, title: loc.teams,
horizontalAlignment: CrossAxisAlignment.start, icon: Icons.scoreboard,
content: Wrap( horizontalAlignment: CrossAxisAlignment.start,
alignment: WrapAlignment.start, content: Wrap(
crossAxisAlignment: WrapCrossAlignment.start, alignment: WrapAlignment.start,
spacing: 12, crossAxisAlignment: WrapCrossAlignment.start,
runSpacing: 8, spacing: 12,
children: match.players.map((player) { runSpacing: 8,
return TextIconTile( children: match.teams!.map((team) {
text: player.name, return TeamCard(team: team);
suffixText: getNameCountText(player), }).toList(),
iconEnabled: false, ),
);
}).toList(),
), ),
), ] else ...[
// Players
InfoTile(
title: loc.players,
icon: Icons.people,
horizontalAlignment: CrossAxisAlignment.start,
content: Wrap(
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.start,
spacing: 12,
runSpacing: 8,
children: match.players.map((player) {
return TextIconTile(
text: player.name,
suffixText: getNameCountText(player),
iconEnabled: false,
);
}).toList(),
),
),
],
const SizedBox(height: 15), const SizedBox(height: 15),
// Game // Game

View File

@@ -59,7 +59,6 @@ class _MatchResultViewState extends State<MatchResultView> {
ruleset = widget.match.game.ruleset; ruleset = widget.match.game.ruleset;
canSave = !rulesetSupportsScoreEntry(); canSave = !rulesetSupportsScoreEntry();
isTeamMatch = widget.match.isTeamMatch; isTeamMatch = widget.match.isTeamMatch;
print(widget.match.teams);
if (isTeamMatch) { if (isTeamMatch) {
initializeAsTeamMatch(); initializeAsTeamMatch();
@@ -290,12 +289,12 @@ class _MatchResultViewState extends State<MatchResultView> {
Future<bool> _handleWinner() async { Future<bool> _handleWinner() async {
if (isTeamMatch) { if (isTeamMatch) {
if (_selectedTeam == null) { if (_selectedTeam == null) {
return await db.teamDao.setWinnerTeam( return await db.teamDao.removeWinnerTeam(
matchId: widget.match.id, matchId: widget.match.id,
teamId: _selectedTeam!.id, teamId: _selectedTeam!.id,
); );
} else { } else {
return await db.teamDao.setLoserTeam( return await db.teamDao.setWinnerTeam(
matchId: widget.match.id, matchId: widget.match.id,
teamId: _selectedTeam!.id, teamId: _selectedTeam!.id,
); );

View File

@@ -0,0 +1,104 @@
import 'package:flutter/material.dart';
import 'package:tallee/core/common.dart';
import 'package:tallee/core/custom_theme.dart';
import 'package:tallee/data/models/team.dart';
import 'package:tallee/presentation/widgets/tiles/text_icon_tile.dart';
class TeamCard extends StatelessWidget {
const TeamCard({
super.key,
required this.team,
this.compact = false,
this.width = double.infinity,
});
final Team team;
final bool compact;
final double width;
@override
Widget build(BuildContext context) {
final teamColor = getColorFromGameColor(team.color);
if (compact) {
return Container(
width: width,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
color: teamColor.withAlpha(50),
borderRadius: BorderRadius.circular(10),
border: Border.all(color: teamColor, width: 2),
),
child: Row(
children: [
Expanded(
child: Text(
team.name,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
color: Colors.white,
),
overflow: TextOverflow.ellipsis,
),
),
const SizedBox(width: 8),
Container(
width: 1,
height: 14,
color: Colors.white.withValues(alpha: 0.35),
),
const SizedBox(width: 8),
const Icon(Icons.people_alt_rounded, size: 14, color: Colors.white),
const SizedBox(width: 4),
Text(
'${team.members.length}',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
],
),
);
} else {
return Container(
width: width,
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
decoration: BoxDecoration(
color: teamColor.withAlpha(50),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: teamColor, width: 2),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 6,
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(),
),
],
),
);
}
}
}

View File

@@ -7,6 +7,7 @@ import 'package:tallee/core/custom_theme.dart';
import 'package:tallee/core/enums.dart'; import 'package:tallee/core/enums.dart';
import 'package:tallee/data/models/match.dart'; import 'package:tallee/data/models/match.dart';
import 'package:tallee/l10n/generated/app_localizations.dart'; import 'package:tallee/l10n/generated/app_localizations.dart';
import 'package:tallee/presentation/widgets/cards/team_card.dart';
import 'package:tallee/presentation/widgets/game_label.dart'; import 'package:tallee/presentation/widgets/game_label.dart';
import 'package:tallee/presentation/widgets/tiles/text_icon_tile.dart'; import 'package:tallee/presentation/widgets/tiles/text_icon_tile.dart';
@@ -244,56 +245,29 @@ class _MatchTileState extends State<MatchTile> {
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
Column( LayoutBuilder(
crossAxisAlignment: CrossAxisAlignment.start, builder: (context, constraints) {
children: [ final useSingleColumn = match.teams!.any(
for (var team in match.teams!) ...[ (team) => team.name.length > 14,
Container( );
width: double.infinity,
padding: const EdgeInsets.symmetric( const spacing = 8.0;
vertical: 6, final itemWidth = useSingleColumn
horizontal: 12, ? constraints.maxWidth
), : (constraints.maxWidth - spacing) / 2;
decoration: BoxDecoration(
color: getColorFromGameColor( return Wrap(
team.color, spacing: spacing,
).withValues(alpha: 0.1), runSpacing: spacing,
borderRadius: BorderRadius.circular(8), children: match.teams!.map((team) {
border: Border.all( return TeamCard(
color: getColorFromGameColor( team: team,
team.color, compact: true,
).withValues(alpha: 0.3), width: itemWidth,
width: 1, );
), }).toList(),
), );
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), const SizedBox(height: 12),
] else if (players.isNotEmpty && widget.compact == false) ...[ ] else if (players.isNotEmpty && widget.compact == false) ...[

View File

@@ -1,7 +1,7 @@
name: tallee name: tallee
description: "Tracking App for Card Games" description: "Tracking App for Card Games"
publish_to: 'none' publish_to: 'none'
version: 0.0.30+287 version: 0.0.30+294
environment: environment:
sdk: ^3.8.1 sdk: ^3.8.1