Skip to content

Commit

Permalink
fixing formatting of players (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkieres authored Aug 7, 2022
1 parent cf1de82 commit 625fa0f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
6 changes: 4 additions & 2 deletions board_games_companion/lib/common/app_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ class AppText {
static const gamesPageSearchNoSearchResults =
'''It looks there's no games in your collections that match the search phrase ''';
static const gamesPageSearchClearSaerch = 'Clear search';
static const gamesPageSearchResultPlayersNumberGameStatFormat = '%i - %i players';
static const gamesPageSearchResultComplexityGameStatFormat = '%s (complexity rating)';
static const gamesPageSearchResultRefreshDetails =
'Games imported from the BGG collections are missing some details (e.g. complexity or expansions). Refresh the data to get the latest information.';
static const gamesPageSearchResultExpansionsSectionTitleFormat = 'Expansions (%i)';

static const gamePlaytimeStatFormat = '%s min';
static const gamePlaytimeFormat = '%s min';
static const gamePlayersSingularFormat = '%i players';
static const gamePlayersPluralFormat = '%i players';
static const gamePlayersRangeFormat = '%i - %i players';

static const aboutPageTitle = 'About';
static const collectionsPageTitle = 'Collections';
Expand Down
14 changes: 13 additions & 1 deletion board_games_companion/lib/models/hive/board_game_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,19 @@ abstract class _BoardGameDetails extends BaseBoardGame with Store {
}
}

return sprintf(AppText.gamePlaytimeStatFormat, [playtimeRange]);
return sprintf(AppText.gamePlaytimeFormat, [playtimeRange]);
}

String get playersFormatted {
if (_minPlayers == _maxPlayers || _maxPlayers == null) {
if (_minPlayers == 1) {
return sprintf(AppText.gamePlayersSingularFormat, [_minPlayers]);
}

return sprintf(AppText.gamePlayersPluralFormat, [_minPlayers]);
}

return sprintf(AppText.gamePlayersRangeFormat, [_minPlayers, _maxPlayers]);
}

String? get rankFormatted {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,7 @@ class _FirstRowGeneralInfoPanels extends StatelessWidget {
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Flexible(
child: _InfoPanel(
title: '${boardGameDetails!.minPlayers} - ${boardGameDetails!.maxPlayers} Players',
),
),
Flexible(child: _InfoPanel(title: boardGameDetails!.playersFormatted)),
const SizedBox(width: Dimensions.standardSpacing),
Flexible(
child: _InfoPanel(
Expand Down
5 changes: 1 addition & 4 deletions board_games_companion/lib/pages/games/games_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -957,10 +957,7 @@ class _SearchResultGameDetails extends StatelessWidget {
const SizedBox(height: Dimensions.standardSpacing),
_SearchResultGameGeneralStats(
icon: const Icon(Icons.people, size: _gameStatIconSize),
statistic: sprintf(
AppText.gamesPageSearchResultPlayersNumberGameStatFormat,
[boardGame.minPlayers, boardGame.maxPlayers],
),
statistic: boardGame.playersFormatted,
),
const SizedBox(height: Dimensions.standardSpacing),
_SearchResultGameGeneralStats(
Expand Down

0 comments on commit 625fa0f

Please sign in to comment.