Merge pull request #102 from flixcoo/enhance/100-graph-enhancements

Graph Enhancements
This commit is contained in:
2025-07-13 11:58:58 +02:00
committed by GitHub
8 changed files with 27 additions and 33 deletions

View File

@@ -74,7 +74,6 @@
"done": "Fertig", "done": "Fertig",
"next_round": "Nächste Runde", "next_round": "Nächste Runde",
"statistics": "Statistiken",
"end_game": "Spiel beenden", "end_game": "Spiel beenden",
"delete_game": "Spiel löschen", "delete_game": "Spiel löschen",
"new_game_same_settings": "Neues Spiel mit gleichen Einstellungen", "new_game_same_settings": "Neues Spiel mit gleichen Einstellungen",
@@ -85,7 +84,7 @@
"end_game_message": "Möchtest du das Spiel beenden? Das Spiel wird als beendet markiert und kann nicht fortgeführt werden.", "end_game_message": "Möchtest du das Spiel beenden? Das Spiel wird als beendet markiert und kann nicht fortgeführt werden.",
"game_process": "Spielverlauf", "game_process": "Spielverlauf",
"empty_graph_text": "Du musst mindestens zwei Runden spielen, damit der Graph des Spielverlaufes angezeigt werden kann.", "empty_graph_text": "Du musst mindestens eine Runde spielen, damit der Graph des Spielverlaufes angezeigt werden kann.",
"settings": "Einstellungen", "settings": "Einstellungen",
"cabo_penalty": "Cabo-Strafe", "cabo_penalty": "Cabo-Strafe",

View File

@@ -74,8 +74,6 @@
"done": "Done", "done": "Done",
"next_round": "Next Round", "next_round": "Next Round",
"statistics": "Statistics",
"end_game": "End Game", "end_game": "End Game",
"delete_game": "Delete Game", "delete_game": "Delete Game",
"new_game_same_settings": "New Game with same Settings", "new_game_same_settings": "New Game with same Settings",
@@ -86,7 +84,7 @@
"end_game_message": "Do you want to end the game? The game gets marked as finished and cannot be continued.", "end_game_message": "Do you want to end the game? The game gets marked as finished and cannot be continued.",
"game_process": "Scoring History", "game_process": "Scoring History",
"empty_graph_text": "You must play at least two rounds for the game progress graph to be displayed.", "empty_graph_text": "You must play at least one round for the game progress graph to be displayed.",
"settings": "Settings", "settings": "Settings",
"cabo_penalty": "Cabo Penalty", "cabo_penalty": "Cabo Penalty",

View File

@@ -416,12 +416,6 @@ abstract class AppLocalizations {
/// **'Nächste Runde'** /// **'Nächste Runde'**
String get next_round; String get next_round;
/// No description provided for @statistics.
///
/// In de, this message translates to:
/// **'Statistiken'**
String get statistics;
/// No description provided for @end_game. /// No description provided for @end_game.
/// ///
/// In de, this message translates to: /// In de, this message translates to:
@@ -479,7 +473,7 @@ abstract class AppLocalizations {
/// No description provided for @empty_graph_text. /// No description provided for @empty_graph_text.
/// ///
/// In de, this message translates to: /// In de, this message translates to:
/// **'Du musst mindestens zwei Runden spielen, damit der Graph des Spielverlaufes angezeigt werden kann.'** /// **'Du musst mindestens eine Runde spielen, damit der Graph des Spielverlaufes angezeigt werden kann.'**
String get empty_graph_text; String get empty_graph_text;
/// No description provided for @settings. /// No description provided for @settings.

View File

@@ -178,9 +178,6 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get next_round => 'Nächste Runde'; String get next_round => 'Nächste Runde';
@override
String get statistics => 'Statistiken';
@override @override
String get end_game => 'Spiel beenden'; String get end_game => 'Spiel beenden';
@@ -212,7 +209,7 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get empty_graph_text => String get empty_graph_text =>
'Du musst mindestens zwei Runden spielen, damit der Graph des Spielverlaufes angezeigt werden kann.'; 'Du musst mindestens eine Runde spielen, damit der Graph des Spielverlaufes angezeigt werden kann.';
@override @override
String get settings => 'Einstellungen'; String get settings => 'Einstellungen';

View File

@@ -175,9 +175,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get next_round => 'Next Round'; String get next_round => 'Next Round';
@override
String get statistics => 'Statistics';
@override @override
String get end_game => 'End Game'; String get end_game => 'End Game';
@@ -209,7 +206,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get empty_graph_text => String get empty_graph_text =>
'You must play at least two rounds for the game progress graph to be displayed.'; 'You must play at least one round for the game progress graph to be displayed.';
@override @override
String get settings => 'Settings'; String get settings => 'Settings';

View File

@@ -121,7 +121,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
children: [ children: [
CupertinoListTile( CupertinoListTile(
title: Text( title: Text(
AppLocalizations.of(context).statistics, AppLocalizations.of(context).game_process,
), ),
backgroundColorActivated: backgroundColorActivated:
CustomTheme.backgroundColor, CustomTheme.backgroundColor,
@@ -131,8 +131,9 @@ class _ActiveGameViewState extends State<ActiveGameView> {
builder: (_) => GraphView( builder: (_) => GraphView(
gameSession: gameSession, gameSession: gameSession,
)))), )))),
if (!gameSession.isPointsLimitEnabled) Visibility(
CupertinoListTile( visible: !gameSession.isPointsLimitEnabled,
child: CupertinoListTile(
title: Text( title: Text(
AppLocalizations.of(context).end_game, AppLocalizations.of(context).end_game,
style: gameSession.roundNumber > 1 && style: gameSession.roundNumber > 1 &&
@@ -148,6 +149,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
_showEndGameDialog(); _showEndGameDialog();
} }
}), }),
),
CupertinoListTile( CupertinoListTile(
title: Text( title: Text(
AppLocalizations.of(context).delete_game, AppLocalizations.of(context).delete_game,

View File

@@ -30,17 +30,22 @@ class _GraphViewState extends State<GraphView> {
middle: Text(AppLocalizations.of(context).game_process), middle: Text(AppLocalizations.of(context).game_process),
previousPageTitle: AppLocalizations.of(context).back, previousPageTitle: AppLocalizations.of(context).back,
), ),
child: widget.gameSession.roundNumber > 2 child: widget.gameSession.roundNumber > 1
? Padding( ? Padding(
padding: const EdgeInsets.fromLTRB(0, 100, 0, 0), padding: const EdgeInsets.fromLTRB(0, 100, 0, 0),
child: SfCartesianChart( child: SfCartesianChart(
legend: const Legend( legend: const Legend(
isVisible: true, position: LegendPosition.bottom), overflowMode: LegendItemOverflowMode.wrap,
isVisible: true,
position: LegendPosition.bottom),
primaryXAxis: const NumericAxis( primaryXAxis: const NumericAxis(
interval: 1, interval: 1,
decimalPlaces: 0, decimalPlaces: 0,
), ),
primaryYAxis: const NumericAxis(), primaryYAxis: const NumericAxis(
interval: 1,
decimalPlaces: 0,
),
series: getCumulativeScores(), series: getCumulativeScores(),
), ),
) )
@@ -82,19 +87,21 @@ class _GraphViewState extends State<GraphView> {
} }
} }
const double jitterStep = 0.15; const double jitterStep = 0.03;
/// Create a list of LineSeries for each player /// Create a list of LineSeries for each player
/// Each series contains data points for each round /// Each series contains data points for each round
return List.generate(playerCount, (i) { return List.generate(playerCount, (i) {
final data = List.generate( final data = List.generate(
cumulativeScores[i].length, cumulativeScores[i].length + 1,
(j) => ( (j) => (
j + 1, j,
j == 0 || cumulativeScores[i][j - 1] == 0
? 0 // 0 points at the start of the game or when the value is 0 (don't subtract jitter step)
// Add a small jitter to the cumulative scores to prevent overlapping data points in the graph. // Adds a small jitter to the cumulative scores to prevent overlapping data points in the graph.
// The jitter is centered around zero by subtracting playerCount ~/ 2 from the player index i. // The jitter is centered around zero by subtracting playerCount ~/ 2 from the player index i.
cumulativeScores[i][j] + (i - playerCount ~/ 2) * jitterStep : cumulativeScores[i][j - 1] + (i - playerCount ~/ 2) * jitterStep
), ),
); );

View File

@@ -2,7 +2,7 @@ name: cabo_counter
description: "Mobile app for the card game Cabo" description: "Mobile app for the card game Cabo"
publish_to: 'none' publish_to: 'none'
version: 0.4.3+479 version: 0.4.4+485
environment: environment:
sdk: ^3.5.4 sdk: ^3.5.4