diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 542899a..2f9e53f 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -120,10 +120,11 @@ "percentageFinishedFirstFinishedThisYearString": "{total} of Finished first finished this year", "percentagePlayedString": "{total} of Played", "percentageFinishedString": "{total} of Finished", + "percentageRatedString": "{total} of Rated", "playTimeString": "{total} Play Time", "totalPlayedString": "{total} Played", - "totalRatedString": "{total} Rated", "totalFinishedString": "{total} Finished", + "totalRatedString": "{total} Rated", "sessionsPlayedString" : "{total} {total, plural, =1{Session} other{Sessions}} Played", "totalGamesPlayedString": "{total} {total, plural, =1{Game} other{Games}} Played", "totalFirstPlayedString": "{total} First Played", @@ -146,15 +147,13 @@ "gamesPlayedByRatingString": "Games played by rating", "gamesFinishedByMonthString": "Games finished by month", "playedInString": "Played in {month}", - "ratedWithString": "Rated with {rating, select, 8{an} other{a}} {rating}", "finishedInString": "Finished in {month}", + "ratedWithString": "Rated with {rating, select, 8{an} other{a}} {rating}", "newRelasesString": "New releases", "recentString": "Recent", "classicGamesString": "Classic", "recentDescriptionString": "Released in the last 1-{yearsMax} years", "classicGamesDescriptionString": "Released {yearsMax} or more years ago", - "noRatingString": "Without rating", - "noRatingShortString": "N/A", "fieldUpdatedString": "Field updated", "unableToUpdateFieldString": "Unable to update field", "uploadImageString": "Upload image", diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 5278eee..ea4428e 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -120,10 +120,11 @@ "percentageFinishedFirstFinishedThisYearString": "{total} de juegos terminados por primera vez este año", "percentagePlayedString": "{total} de los jugados", "percentageFinishedString": "{total} de los terminados", + "percentageRatedString": "{total} de los puntuados", "playTimeString": "{total} de tiempo de juego", "totalPlayedString": "{total} {total, plural, =1{jugado} other{jugados}}", - "totalRatedString": "{total} {total, plural, =1{puntuado} other{puntuados}}", "totalFinishedString": "{total} {total, plural, =1{terminado} other{terminados}}", + "totalRatedString": "{total} {total, plural, =1{puntuado} other{puntuados}}", "sessionsPlayedString" : "{total} {total, plural, =1{sesión} other{sesiones}}", "totalGamesPlayedString": "{total} {total, plural, =1{juego} other{juegos}}", "totalFirstPlayedString": "{total} {total, plural, =1{jugado} other{jugados}} por primera vez", @@ -146,15 +147,13 @@ "gamesPlayedByRatingString": "Juegos por puntuación", "gamesFinishedByMonthString": "Juegos terminados por mes", "playedInString": "Jugado en {month}", - "ratedWithString": "Puntuado con un {rating}", "finishedInString": "Terminados en {month}", + "ratedWithString": "Puntuado con un {rating}", "newRelasesString": "Nuevos lanzamientos", "recentString": "Recientes", "classicGamesString": "Clásicos", "recentDescriptionString": "Lanzados durante los últimos 1-{yearsMax} años", "classicGamesDescriptionString": "Lanzados hace {yearsMax} años o más", - "noRatingString": "Sin puntuación", - "noRatingShortString": "N/A", "fieldUpdatedString": "Campo actualizado", "unableToUpdateFieldString": "No ha sido posible actualizar el campo", "uploadImageString": "Subir imagen", diff --git a/lib/ui/review/review_year.dart b/lib/ui/review/review_year.dart index 23d0c94..b18ab42 100644 --- a/lib/ui/review/review_year.dart +++ b/lib/ui/review/review_year.dart @@ -290,11 +290,11 @@ class _ReviewYearBody extends StatelessWidget { ), ); widgets.add( - _buildTotalPlayedByRatingChart( + _buildTotalRatedByRatingChart( context, gamesColour, - playedData.totalPlayedByRating, - playedData.totalPlayed, + playedData.totalRatedByRating, + playedData.totalRated, games, finishedGames, playedData.totalTime, @@ -721,11 +721,11 @@ class _ReviewYearBody extends StatelessWidget { ); } - Widget _buildTotalPlayedByRatingChart( + Widget _buildTotalRatedByRatingChart( BuildContext context, Map gamesColour, - Map totalPlayedByRating, - int totalPlayed, + Map totalRatedByRating, + int totalRated, List games, List finishedGames, Duration totalTime, @@ -733,16 +733,16 @@ class _ReviewYearBody extends StatelessWidget { return _buildChartCard( context, AppLocalizations.of(context)!.gamesPlayedByRatingString, - _buildTotalPlayedByRatingBarChart( + _buildTotalRatedByRatingBarChart( context, - totalPlayedByRating, - totalPlayed, - (int rating) => _onPlayedRatingTap( + totalRatedByRating, + totalRated, + (int rating) => _onRatedRatingTap( context, gamesColour, rating, - totalPlayedByRating[rating] ?? 0, - totalPlayed, + totalRatedByRating[rating] ?? 0, + totalRated, games, finishedGames, totalTime, @@ -788,11 +788,15 @@ class _ReviewYearBody extends StatelessWidget { ) { return Card( margin: EdgeInsets.zero, - child: _buildChartWithTitle(title, chartWidget), + child: _buildChartWithTitle(context, title, chartWidget), ); } - Column _buildChartWithTitle(String title, Widget chartWidget) { + Column _buildChartWithTitle( + BuildContext context, + String title, + Widget chartWidget, + ) { return Column( mainAxisSize: MainAxisSize.min, children: [ @@ -805,7 +809,10 @@ class _ReviewYearBody extends StatelessWidget { right: 0.0, // Use blank space to the right bottom: 8.0, ), - child: chartWidget, + child: SizedBox( + height: MediaQuery.of(context).size.height / 2.5, + child: chartWidget, + ), ), ], ); @@ -890,161 +897,141 @@ class _ReviewYearBody extends StatelessWidget { ); } - SizedBox _buildTotalPlayedByReleaseYearPieChart( + Widget _buildTotalPlayedByReleaseYearPieChart( BuildContext context, List colours, List releasedTypeTotals, int totalPlayed, void Function(int type) onTypeTap, ) { - return SizedBox( - height: MediaQuery.of(context).size.height / 2.5, - child: StatisticsPieChart( - id: 'playedByReleaseYear', - domainLabels: GameTheme.releaseYearTypes(context), - values: releasedTypeTotals - .map( - (int totalReleaseYear) => totalReleaseYear / totalPlayed, - ) - .toList(growable: false), - colours: colours, - valueFormatter: (String domainLabel, _) => domainLabel, - onTap: onTypeTap, - ), + return StatisticsPieChart( + id: 'playedByReleaseYear', + domainLabels: GameTheme.releaseYearTypes(context), + values: releasedTypeTotals + .map( + (int totalReleaseYear) => totalReleaseYear / totalPlayed, + ) + .toList(growable: false), + colours: colours, + valueFormatter: (String domainLabel, _) => domainLabel, + onTap: onTypeTap, ); } - SizedBox _buildTotalFinishedByReleaseYearPieChart( + Widget _buildTotalFinishedByReleaseYearPieChart( BuildContext context, List colours, List releasedTypeTotals, int totalFinished, void Function(int type) onTypeTap, ) { - return SizedBox( - height: MediaQuery.of(context).size.height / 2.5, - child: StatisticsPieChart( - id: 'finishedByReleaseYear', - domainLabels: GameTheme.releaseYearTypes(context), - values: releasedTypeTotals - .map( - (int totalReleaseYear) => totalReleaseYear / totalFinished, - ) - .toList(growable: false), - colours: colours, - valueFormatter: (String domainLabel, _) => domainLabel, - onTap: onTypeTap, - ), + return StatisticsPieChart( + id: 'finishedByReleaseYear', + domainLabels: GameTheme.releaseYearTypes(context), + values: releasedTypeTotals + .map( + (int totalReleaseYear) => totalReleaseYear / totalFinished, + ) + .toList(growable: false), + colours: colours, + valueFormatter: (String domainLabel, _) => domainLabel, + onTap: onTypeTap, ); } - SizedBox _buildTotalTimeByMonthStackedBarChart( + Widget _buildTotalTimeByMonthStackedBarChart( BuildContext context, List colours, List> gamesTotalTimeGrouped, Duration totalTime, void Function(int month) onMonthTap, ) { - return SizedBox( - height: MediaQuery.of(context).size.height / 2.5, - child: StatisticsStackedHistogram( - id: 'playTimeByMonth', - domainLabels: AppLocalizationsUtils.monthsAbbr(), - stackedValues: gamesTotalTimeGrouped - .map( - (Map gameTotalTimeGrouped) => - // First normalise entries - List.generate( - DateTime.monthsPerYear, - (int index) { - final Duration gameMonthTotalTime = - gameTotalTimeGrouped[index + 1] ?? const Duration(); - return _preparePercentageForChart( - gameMonthTotalTime.inMinutes / totalTime.inMinutes, - ); - }, - ), - ) - .toList(growable: false), - colours: colours, - hideValueLabels: true, - measureFormatter: _formatPercentageMeasureForChart, - onTap: (int domainIndex) => onMonthTap(domainIndex + 1), - ), + return StatisticsStackedHistogram( + id: 'playTimeByMonth', + domainLabels: AppLocalizationsUtils.monthsAbbr(), + stackedValues: gamesTotalTimeGrouped + .map( + (Map gameTotalTimeGrouped) => + // First normalise entries + List.generate( + DateTime.monthsPerYear, + (int index) { + final Duration gameMonthTotalTime = + gameTotalTimeGrouped[index + 1] ?? const Duration(); + return _preparePercentageForChart( + gameMonthTotalTime.inMinutes / totalTime.inMinutes, + ); + }, + ), + ) + .toList(growable: false), + colours: colours, + hideValueLabels: true, + measureFormatter: _formatPercentageMeasureForChart, + onTap: (int domainIndex) => onMonthTap(domainIndex + 1), ); } - SizedBox _buildTotalPlayedByRatingBarChart( + Widget _buildTotalRatedByRatingBarChart( BuildContext context, - Map totalPlayedByRating, - int totalPlayed, + Map totalRatedByRating, + int totalRated, void Function(int rating) onRatingTap, ) { - return SizedBox( - height: MediaQuery.of(context).size.height / 2.5, - child: StatisticsHistogram( - id: 'playedByRating', - domainLabels: List.generate( - 10, - (int i) => i == 0 - ? AppLocalizations.of(context)!.noRatingShortString - : '${i + 1}', - growable: false, - ), - // First normalise entries - values: List.generate(10, (int rating) { - final int ratingTotalPlayed = totalPlayedByRating[rating] ?? 0; - return ratingTotalPlayed; - }).toList(growable: false), - onDomainTap: onRatingTap, + return StatisticsHistogram( + id: 'ratedByRating', + domainLabels: List.generate( + 10, + (int i) => '${i + 1}', + growable: false, ), + // First normalise entries + values: List.generate(10, (int index) { + final int ratingTotalRated = totalRatedByRating[index + 1] ?? 0; + return ratingTotalRated; + }).toList(growable: false), + onDomainTap: onRatingTap, ); } - SizedBox _buildTotalFinishedByMonthBarChart( + Widget _buildTotalFinishedByMonthBarChart( BuildContext context, Map totalFinishedGrouped, int totalFinished, void Function(int month) onMonthTap, ) { - return SizedBox( - height: MediaQuery.of(context).size.height / 2.5, - child: StatisticsHistogram( - id: 'finishedByMonth', - domainLabels: AppLocalizationsUtils.monthsAbbr(), - // First normalise entries - values: List.generate(DateTime.monthsPerYear, (int index) { - final int monthTotalFinished = totalFinishedGrouped[index + 1] ?? 0; - return monthTotalFinished; - }).toList(growable: false), - onDomainTap: (int domainIndex) => onMonthTap(domainIndex + 1), - ), + return StatisticsHistogram( + id: 'finishedByMonth', + domainLabels: AppLocalizationsUtils.monthsAbbr(), + // First normalise entries + values: List.generate(DateTime.monthsPerYear, (int index) { + final int monthTotalFinished = totalFinishedGrouped[index + 1] ?? 0; + return monthTotalFinished; + }).toList(growable: false), + onDomainTap: (int domainIndex) => onMonthTap(domainIndex + 1), ); } - SizedBox _buildGameTotalTimeByMonthBarChart( + Widget _buildGameTotalTimeByMonthBarChart( BuildContext context, Color colour, Map gameTotalTimeGrouped, Duration totalTime, ) { - return SizedBox( - height: MediaQuery.of(context).size.height / 2.5, - child: StatisticsHistogram( - id: 'gamePlayTimeByMonth', - domainLabels: AppLocalizationsUtils.monthsAbbr(), - // First normalise entries - values: List.generate(DateTime.monthsPerYear, (int index) { - final Duration gameMonthTotalTime = - gameTotalTimeGrouped[index + 1] ?? const Duration(); - return gameMonthTotalTime.inMinutes; - }).toList(growable: false), - colour: colour, - valueFormatter: (int minutes) => - _formatDurationValueForChart(context, minutes), - measureFormatter: (num? minutes) => - _formatDurationMeasureForChart(context, minutes), - ), + return StatisticsHistogram( + id: 'gamePlayTimeByMonth', + domainLabels: AppLocalizationsUtils.monthsAbbr(), + // First normalise entries + values: List.generate(DateTime.monthsPerYear, (int index) { + final Duration gameMonthTotalTime = + gameTotalTimeGrouped[index + 1] ?? const Duration(); + return gameMonthTotalTime.inMinutes; + }).toList(growable: false), + colour: colour, + valueFormatter: (int minutes) => + _formatDurationValueForChart(context, minutes), + measureFormatter: (num? minutes) => + _formatDurationMeasureForChart(context, minutes), ); } @@ -1633,28 +1620,28 @@ class _ReviewYearBody extends StatelessWidget { ); } - void _onPlayedRatingTap( + void _onRatedRatingTap( BuildContext context, Map gamesColour, int rating, - int ratingTotalPlayed, - int totalPlayed, + int ratingTotalRated, + int totalRated, List games, List finishedGames, Duration totalTime, ) async { - final List releasedTypeGames = games + final List ratingGames = games .where((GamePlayedReviewDTO game) => game.rating == rating) .toList(growable: false); // Sort by oldest release year - releasedTypeGames.sort( + ratingGames.sort( (GamePlayedReviewDTO a, GamePlayedReviewDTO b) => a.releaseYear != null && b.releaseYear != null ? a.releaseYear!.compareTo(b.releaseYear!) : 0, ); - if (releasedTypeGames.isEmpty) { + if (ratingGames.isEmpty) { return; } @@ -1667,19 +1654,19 @@ class _ReviewYearBody extends StatelessWidget { widgets.add( ListTile( title: Text( - '${AppLocalizations.of(context)!.percentagePlayedString( + '${AppLocalizations.of(context)!.percentageRatedString( _formatPercentageForCard( - ratingTotalPlayed / totalPlayed, + ratingTotalRated / totalRated, ), )} · ${AppLocalizations.of(context)!.totalRatedString( - ratingTotalPlayed, + ratingTotalRated, )}', textAlign: TextAlign.center, ), ), ); widgets.addAll( - releasedTypeGames.map((GamePlayedReviewDTO game) { + ratingGames.map((GamePlayedReviewDTO game) { final GameFinishedReviewDTO? finishedGame = _getFinishedGame(finishedGames, game.id); @@ -1699,9 +1686,7 @@ class _ReviewYearBody extends StatelessWidget { color: Colors.grey, child: ListHeader( icon: GameTheme.ratingIcon, - text: rating == 0 - ? AppLocalizations.of(context)!.noRatingString - : AppLocalizations.of(context)!.ratedWithString('$rating'), + text: AppLocalizations.of(context)!.ratedWithString('$rating'), ), ), Expanded( @@ -1858,6 +1843,7 @@ class _ReviewYearBody extends StatelessWidget { _buildGameLongestStreak(context, game), const ListDivider(), _buildChartWithTitle( + context, AppLocalizations.of(context)!.playTimeByMonthString, _buildGameTotalTimeByMonthBarChart( context, diff --git a/lib/ui/settings/server_settings.dart b/lib/ui/settings/server_settings.dart index 3601342..97d60ad 100644 --- a/lib/ui/settings/server_settings.dart +++ b/lib/ui/settings/server_settings.dart @@ -326,8 +326,12 @@ class _ShowHideTextFormFieldState extends State<_ShowHideTextFormField> { @override Widget build(BuildContext context) { return Padding( - padding: - const EdgeInsets.only(left: 8.0, top: 4.0, right: 8.0, bottom: 4.0), + padding: const EdgeInsets.only( + left: 8.0, + top: 4.0, + right: 8.0, + bottom: 4.0, + ), child: TextFormField( initialValue: widget.initialValue, obscureText: widget.allowObscureText ? obscureText : false, diff --git a/logic/pubspec.lock b/logic/pubspec.lock index e7fcbb7..71ab863 100644 --- a/logic/pubspec.lock +++ b/logic/pubspec.lock @@ -157,10 +157,10 @@ packages: description: path: "." ref: main - resolved-ref: "48e1692fd9db005366ef54a18969e9852457d52b" + resolved-ref: a5c98ac99fa850edcec7553c4e2d9c714f1c8593 url: "https://github.com/viplmad/game-oclock-client-dart.git" source: git - version: "1.3.6+50" + version: "1.3.7+52" http: dependency: "direct main" description: diff --git a/pubspec.lock b/pubspec.lock index 2fff664..98f8ff5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -330,10 +330,10 @@ packages: description: path: "." ref: main - resolved-ref: "48e1692fd9db005366ef54a18969e9852457d52b" + resolved-ref: a5c98ac99fa850edcec7553c4e2d9c714f1c8593 url: "https://github.com/viplmad/game-oclock-client-dart.git" source: git - version: "1.3.6+50" + version: "1.3.7+52" http: dependency: transitive description: