implement changes
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m27s
Pull Request Pipeline / lint (pull_request) Successful in 2m33s

This commit is contained in:
2026-01-03 15:38:25 +01:00
parent 9fc308554c
commit ec94e12ed7
22 changed files with 247 additions and 282 deletions

View File

@@ -87,6 +87,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
return Container(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
@@ -97,7 +98,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
CustomSearchBar(
controller: _searchBarController,
constraints: const BoxConstraints(maxHeight: 45, minHeight: 45),
hintText: AppLocalizations.of(context).search_for_players,
hintText: loc.search_for_players,
trailingButtonShown: true,
trailingButtonicon: Icons.add_circle,
trailingButtonEnabled: _searchBarController.text.trim().isNotEmpty,
@@ -139,11 +140,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
SizedBox(
height: 50,
child: selectedPlayers.isEmpty
? Center(
child: Text(
AppLocalizations.of(context).no_players_selected,
),
)
? Center(child: Text(loc.no_players_selected))
: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
@@ -185,7 +182,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
),
const SizedBox(height: 10),
Text(
AppLocalizations.of(context).all_players,
loc.all_players,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
@@ -196,8 +193,8 @@ class _PlayerSelectionState extends State<PlayerSelection> {
visible: suggestedPlayers.isNotEmpty,
replacement: TopCenteredMessage(
icon: Icons.info,
title: 'Info',
message: _getInfoText(),
title: loc.info,
message: _getInfoText(context),
),
child: ListView.builder(
itemCount: suggestedPlayers.length,
@@ -234,6 +231,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
/// Shows a snackbar indicating success or failure.
/// [context] - BuildContext to show the snackbar.
void addNewPlayerFromSearch({required BuildContext context}) async {
final loc = AppLocalizations.of(context);
String playerName = _searchBarController.text.trim();
Player createdPlayer = Player(name: playerName);
bool success = await db.playerDao.addPlayer(player: createdPlayer);
@@ -267,7 +265,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
backgroundColor: CustomTheme.boxColor,
content: Center(
child: Text(
AppLocalizations.of(context).could_not_add_player(playerName),
loc.could_not_add_player(playerName),
style: const TextStyle(color: Colors.white),
),
),
@@ -278,18 +276,19 @@ class _PlayerSelectionState extends State<PlayerSelection> {
/// Determines the appropriate info text to display when no players
/// are available in the suggested players list.
String _getInfoText() {
String _getInfoText(BuildContext context) {
final loc = AppLocalizations.of(context);
if (allPlayers.isEmpty) {
// No players exist in the database
return AppLocalizations.of(context).no_players_created_yet;
return loc.no_players_created_yet;
} else if (selectedPlayers.length == allPlayers.length ||
widget.availablePlayers?.isEmpty == true) {
// All players have been selected or
// available players list is provided but empty
return AppLocalizations.of(context).all_players_selected;
return loc.all_players_selected;
} else {
// No players match the search query
return AppLocalizations.of(context).no_players_found_with_that_name;
return loc.no_players_found_with_that_name;
}
}
}

View File

@@ -21,6 +21,7 @@ class _MatchTileState extends State<MatchTile> {
final group = widget.match.group;
final winner = widget.match.winner;
final allPlayers = _getAllPlayers();
final loc = AppLocalizations.of(context);
return GestureDetector(
onTap: widget.onTap,
@@ -49,7 +50,7 @@ class _MatchTileState extends State<MatchTile> {
),
),
Text(
_formatDate(widget.match.createdAt),
_formatDate(widget.match.createdAt, context),
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
],
@@ -98,7 +99,7 @@ class _MatchTileState extends State<MatchTile> {
const SizedBox(width: 8),
Expanded(
child: Text(
AppLocalizations.of(context).winner(winner.name),
loc.winner(winner.name),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
@@ -115,7 +116,7 @@ class _MatchTileState extends State<MatchTile> {
if (allPlayers.isNotEmpty) ...[
Text(
AppLocalizations.of(context).players,
loc.players,
style: const TextStyle(
fontSize: 13,
color: Colors.grey,
@@ -137,9 +138,10 @@ class _MatchTileState extends State<MatchTile> {
);
}
String _formatDate(DateTime dateTime) {
String _formatDate(DateTime dateTime, BuildContext context) {
final now = DateTime.now();
final difference = now.difference(dateTime);
final loc = AppLocalizations.of(context);
if (difference.inDays == 0) {
return AppLocalizations.of(
@@ -150,7 +152,7 @@ class _MatchTileState extends State<MatchTile> {
context,
).yesterday_at(DateFormat('HH:mm').format(dateTime));
} else if (difference.inDays < 7) {
return AppLocalizations.of(context).days_ago(difference.inDays);
return loc.days_ago(difference.inDays);
} else {
return DateFormat('MMM d, yyyy').format(dateTime);
}

View File

@@ -25,6 +25,7 @@ class StatisticsTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
final maxBarWidth = MediaQuery.of(context).size.width * 0.65;
final loc = AppLocalizations.of(context);
return InfoTile(
width: width,
@@ -36,7 +37,7 @@ class StatisticsTile extends StatelessWidget {
visible: values.isNotEmpty,
replacement: Center(
heightFactor: 4,
child: Text(AppLocalizations.of(context).no_data_available),
child: Text(loc.no_data_available),
),
child: Column(
children: List.generate(min(values.length, itemCount), (index) {