Implememented different result tiles in match detail view for different rulesets

This commit is contained in:
2026-03-08 22:25:23 +01:00
parent 84b8541822
commit d5a7bb320f
7 changed files with 126 additions and 37 deletions

View File

@@ -85,21 +85,21 @@ class CustomTheme {
); );
static const SearchBarThemeData searchBarTheme = SearchBarThemeData( static const SearchBarThemeData searchBarTheme = SearchBarThemeData(
textStyle: WidgetStatePropertyAll(TextStyle(color: CustomTheme.textColor)), textStyle: WidgetStatePropertyAll(TextStyle(color: textColor)),
hintStyle: WidgetStatePropertyAll(TextStyle(color: CustomTheme.hintColor)), hintStyle: WidgetStatePropertyAll(TextStyle(color: hintColor)),
); );
static final RadioThemeData radioTheme = RadioThemeData( static final RadioThemeData radioTheme = RadioThemeData(
fillColor: WidgetStateProperty.resolveWith<Color>((states) { fillColor: WidgetStateProperty.resolveWith<Color>((states) {
if (states.contains(WidgetState.selected)) { if (states.contains(WidgetState.selected)) {
return CustomTheme.primaryColor; return primaryColor;
} }
return CustomTheme.textColor; return textColor;
}), }),
); );
static const InputDecorationTheme inputDecorationTheme = InputDecorationTheme( static const InputDecorationTheme inputDecorationTheme = InputDecorationTheme(
labelStyle: TextStyle(color: CustomTheme.textColor), labelStyle: TextStyle(color: textColor),
hintStyle: TextStyle(color: CustomTheme.hintColor), hintStyle: TextStyle(color: hintColor),
); );
} }

View File

@@ -75,6 +75,7 @@
"player_name": "Spieler:innenname", "player_name": "Spieler:innenname",
"players": "Spieler:innen", "players": "Spieler:innen",
"players_count": "{count} Spieler", "players_count": "{count} Spieler",
"points": "Punkte",
"privacy_policy": "Datenschutzerklärung", "privacy_policy": "Datenschutzerklärung",
"quick_create": "Schnellzugriff", "quick_create": "Schnellzugriff",
"recent_matches": "Letzte Spiele", "recent_matches": "Letzte Spiele",
@@ -95,6 +96,7 @@
"single_loser": "Ein:e Verlierer:in", "single_loser": "Ein:e Verlierer:in",
"single_winner": "Ein:e Gewinner:in", "single_winner": "Ein:e Gewinner:in",
"highest_score": "Höchste Punkte", "highest_score": "Höchste Punkte",
"loser": "Verlierer:in",
"lowest_score": "Niedrigste Punkte", "lowest_score": "Niedrigste Punkte",
"multiple_winners": "Mehrere Gewinner:innen", "multiple_winners": "Mehrere Gewinner:innen",
"statistics": "Statistiken", "statistics": "Statistiken",

View File

@@ -235,6 +235,9 @@
} }
} }
}, },
"@points": {
"description": "Points label"
},
"@privacy_policy": { "@privacy_policy": {
"description": "Privacy policy menu item" "description": "Privacy policy menu item"
}, },
@@ -406,6 +409,7 @@
"player_name": "Player name", "player_name": "Player name",
"players": "Players", "players": "Players",
"players_count": "{count} Players", "players_count": "{count} Players",
"points": "Points",
"privacy_policy": "Privacy Policy", "privacy_policy": "Privacy Policy",
"quick_create": "Quick Create", "quick_create": "Quick Create",
"recent_matches": "Recent Matches", "recent_matches": "Recent Matches",
@@ -425,6 +429,7 @@
"single_loser": "Single Loser", "single_loser": "Single Loser",
"single_winner": "Single Winner", "single_winner": "Single Winner",
"highest_score": "Highest Score", "highest_score": "Highest Score",
"loser": "Loser",
"lowest_score": "Lowest Score", "lowest_score": "Lowest Score",
"multiple_winners": "Multiple Winners", "multiple_winners": "Multiple Winners",
"statistics": "Statistics", "statistics": "Statistics",

View File

@@ -548,6 +548,12 @@ abstract class AppLocalizations {
/// **'{count} Players'** /// **'{count} Players'**
String players_count(int count); String players_count(int count);
/// Points label
///
/// In en, this message translates to:
/// **'Points'**
String get points;
/// Privacy policy menu item /// Privacy policy menu item
/// ///
/// In en, this message translates to: /// In en, this message translates to:
@@ -662,6 +668,12 @@ abstract class AppLocalizations {
/// **'Highest Score'** /// **'Highest Score'**
String get highest_score; String get highest_score;
/// No description provided for @loser.
///
/// In en, this message translates to:
/// **'Loser'**
String get loser;
/// No description provided for @lowest_score. /// No description provided for @lowest_score.
/// ///
/// In en, this message translates to: /// In en, this message translates to:

View File

@@ -243,6 +243,9 @@ class AppLocalizationsDe extends AppLocalizations {
return '$count Spieler'; return '$count Spieler';
} }
@override
String get points => 'Punkte';
@override @override
String get privacy_policy => 'Datenschutzerklärung'; String get privacy_policy => 'Datenschutzerklärung';
@@ -304,6 +307,9 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get highest_score => 'Höchste Punkte'; String get highest_score => 'Höchste Punkte';
@override
String get loser => 'Verlierer:in';
@override @override
String get lowest_score => 'Niedrigste Punkte'; String get lowest_score => 'Niedrigste Punkte';

View File

@@ -243,6 +243,9 @@ class AppLocalizationsEn extends AppLocalizations {
return '$count Players'; return '$count Players';
} }
@override
String get points => 'Points';
@override @override
String get privacy_policy => 'Privacy Policy'; String get privacy_policy => 'Privacy Policy';
@@ -304,6 +307,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get highest_score => 'Highest Score'; String get highest_score => 'Highest Score';
@override
String get loser => 'Loser';
@override @override
String get lowest_score => 'Lowest Score'; String get lowest_score => 'Lowest Score';

View File

@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
import 'package:tallee/core/adaptive_page_route.dart'; import 'package:tallee/core/adaptive_page_route.dart';
import 'package:tallee/core/common.dart'; import 'package:tallee/core/common.dart';
import 'package:tallee/core/custom_theme.dart'; import 'package:tallee/core/custom_theme.dart';
import 'package:tallee/core/enums.dart';
import 'package:tallee/data/db/database.dart'; import 'package:tallee/data/db/database.dart';
import 'package:tallee/data/dto/match.dart'; import 'package:tallee/data/dto/match.dart';
import 'package:tallee/l10n/generated/app_localizations.dart'; import 'package:tallee/l10n/generated/app_localizations.dart';
@@ -175,37 +176,7 @@ class _MatchDetailViewState extends State<MatchDetailView> {
vertical: 4, vertical: 4,
horizontal: 8, horizontal: 8,
), ),
child: Row( child: getResultWidget(loc),
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
/// TODO: Implement different ruleset results display
if (match.winner != null) ...[
Text(
loc.winner,
style: const TextStyle(
fontSize: 16,
color: CustomTheme.textColor,
),
),
Text(
match.winner!.name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: CustomTheme.primaryColor,
),
),
] else ...[
Text(
loc.no_results_entered_yet,
style: const TextStyle(
fontSize: 14,
color: CustomTheme.textColor,
),
),
],
],
),
), ),
), ),
], ],
@@ -264,4 +235,91 @@ class _MatchDetailViewState extends State<MatchDetailView> {
}); });
widget.onMatchUpdate.call(); widget.onMatchUpdate.call();
} }
/// Returns the widget to be displayed in the result [InfoTile]
/// TODO: Update when score logic is overhauled
Widget getResultWidget(AppLocalizations loc) {
if (isSingleRowResult()) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: getResultRow(loc),
);
} else {
return Column(
children: [
for (var player in match.players)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
player.name,
style: const TextStyle(
fontSize: 16,
color: CustomTheme.textColor,
),
),
Text(
'0 ${loc.points}',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: CustomTheme.primaryColor,
),
),
],
),
],
);
}
}
/// Returns the result row for single winner/loser rulesets or a placeholder
/// if no result is entered yet
/// TODO: Update when score logic is overhauled
List<Widget> getResultRow(AppLocalizations loc) {
if (match.winner != null && match.game.ruleset == Ruleset.singleWinner) {
return [
Text(
loc.winner,
style: const TextStyle(fontSize: 16, color: CustomTheme.textColor),
),
Text(
match.winner!.name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: CustomTheme.primaryColor,
),
),
];
} else if (match.game.ruleset == Ruleset.singleLoser) {
return [
Text(
loc.loser,
style: const TextStyle(fontSize: 16, color: CustomTheme.textColor),
),
Text(
match.winner!.name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: CustomTheme.primaryColor,
),
),
];
} else {
return [
Text(
loc.no_results_entered_yet,
style: const TextStyle(fontSize: 14, color: CustomTheme.textColor),
),
];
}
}
// Returns if the result can be displayed in a single row
bool isSingleRowResult() {
return match.game.ruleset == Ruleset.singleWinner ||
match.game.ruleset == Ruleset.singleLoser;
}
} }