From f9eafa5b3d06d389b4f2eb7b33d938b568971686 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sat, 9 May 2026 15:01:21 +0200 Subject: [PATCH] add: empty game list messages --- lib/l10n/arb/app_de.arb | 2 + lib/l10n/arb/app_en.arb | 2 + lib/l10n/generated/app_localizations.dart | 12 ++ lib/l10n/generated/app_localizations_de.dart | 7 + lib/l10n/generated/app_localizations_en.dart | 7 + .../create_match/choose_game_view.dart | 132 ++++++++++-------- 6 files changed, 107 insertions(+), 55 deletions(-) diff --git a/lib/l10n/arb/app_de.arb b/lib/l10n/arb/app_de.arb index ab8166a..dd8c744 100644 --- a/lib/l10n/arb/app_de.arb +++ b/lib/l10n/arb/app_de.arb @@ -80,6 +80,7 @@ "members": "Mitglieder", "most_points": "Höchste Punkte", "no_data_available": "Keine Daten verfügbar", + "no_games_created_yet": "Noch keine Spielvorlagen erstellt", "no_groups_created_yet": "Noch keine Gruppen erstellt", "no_licenses_found": "Keine Lizenzen gefunden", "no_license_text_available": "Kein Lizenztext verfügbar", @@ -125,6 +126,7 @@ "statistics": "Statistiken", "stats": "Statistiken", "successfully_added_player": "Spieler:in {playerName} erfolgreich hinzugefügt", + "there_are_no_games_matching_your_search": "Es gibt keine Spielvorlagen, die deiner Suche entspricht", "there_is_no_group_matching_your_search": "Es gibt keine Gruppe, die deiner Suche entspricht", "this_cannot_be_undone": "Dies kann nicht rückgängig gemacht werden.", "tie": "Unentschieden", diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arb index e41bb83..11a908e 100644 --- a/lib/l10n/arb/app_en.arb +++ b/lib/l10n/arb/app_en.arb @@ -81,6 +81,7 @@ "members": "Members", "most_points": "Most Points", "no_data_available": "No data available", + "no_games_created_yet": "No games created yet", "no_groups_created_yet": "No groups created yet", "no_licenses_found": "No licenses found", "no_license_text_available": "No license text available", @@ -134,6 +135,7 @@ } } }, + "there_are_no_games_matching_your_search": "There are no games matching your search", "there_is_no_group_matching_your_search": "There is no group matching your search", "this_cannot_be_undone": "This can't be undone.", "tie": "Tie", diff --git a/lib/l10n/generated/app_localizations.dart b/lib/l10n/generated/app_localizations.dart index dd8f9cb..1f6abff 100644 --- a/lib/l10n/generated/app_localizations.dart +++ b/lib/l10n/generated/app_localizations.dart @@ -536,6 +536,12 @@ abstract class AppLocalizations { /// **'No data available'** String get no_data_available; + /// No description provided for @no_games_created_yet. + /// + /// In en, this message translates to: + /// **'No games created yet'** + String get no_games_created_yet; + /// No description provided for @no_groups_created_yet. /// /// In en, this message translates to: @@ -800,6 +806,12 @@ abstract class AppLocalizations { /// **'Successfully added player {playerName}'** String successfully_added_player(String playerName); + /// No description provided for @there_are_no_games_matching_your_search. + /// + /// In en, this message translates to: + /// **'There are no games matching your search'** + String get there_are_no_games_matching_your_search; + /// No description provided for @there_is_no_group_matching_your_search. /// /// In en, this message translates to: diff --git a/lib/l10n/generated/app_localizations_de.dart b/lib/l10n/generated/app_localizations_de.dart index fe846c3..bff60d0 100644 --- a/lib/l10n/generated/app_localizations_de.dart +++ b/lib/l10n/generated/app_localizations_de.dart @@ -243,6 +243,9 @@ class AppLocalizationsDe extends AppLocalizations { @override String get no_data_available => 'Keine Daten verfügbar'; + @override + String get no_games_created_yet => 'Noch keine Spielvorlagen erstellt'; + @override String get no_groups_created_yet => 'Noch keine Gruppen erstellt'; @@ -382,6 +385,10 @@ class AppLocalizationsDe extends AppLocalizations { return 'Spieler:in $playerName erfolgreich hinzugefügt'; } + @override + String get there_are_no_games_matching_your_search => + 'Es gibt keine Spielvorlagen, die deiner Suche entspricht'; + @override String get there_is_no_group_matching_your_search => 'Es gibt keine Gruppe, die deiner Suche entspricht'; diff --git a/lib/l10n/generated/app_localizations_en.dart b/lib/l10n/generated/app_localizations_en.dart index 899e3a5..ae7d813 100644 --- a/lib/l10n/generated/app_localizations_en.dart +++ b/lib/l10n/generated/app_localizations_en.dart @@ -243,6 +243,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get no_data_available => 'No data available'; + @override + String get no_games_created_yet => 'No games created yet'; + @override String get no_groups_created_yet => 'No groups created yet'; @@ -382,6 +385,10 @@ class AppLocalizationsEn extends AppLocalizations { return 'Successfully added player $playerName'; } + @override + String get there_are_no_games_matching_your_search => + 'There are no games matching your search'; + @override String get there_is_no_group_matching_your_search => 'There is no group matching your search'; diff --git a/lib/presentation/views/main_menu/match_view/create_match/choose_game_view.dart b/lib/presentation/views/main_menu/match_view/create_match/choose_game_view.dart index 78a10f1..c019213 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/choose_game_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/choose_game_view.dart @@ -9,6 +9,7 @@ import 'package:tallee/l10n/generated/app_localizations.dart'; import 'package:tallee/presentation/views/main_menu/match_view/create_match/create_game_view.dart'; import 'package:tallee/presentation/widgets/text_input/custom_search_bar.dart'; import 'package:tallee/presentation/widgets/tiles/game_tile.dart'; +import 'package:tallee/presentation/widgets/top_centered_message.dart'; class ChooseGameView extends StatefulWidget { /// A view that allows the user to choose a game from a list of available games @@ -134,65 +135,86 @@ class _ChooseGameViewState extends State { // Game list Expanded( - child: ListView.builder( - itemCount: filteredGames.length, - itemBuilder: (BuildContext context, int index) { - final game = filteredGames[index]; - return GameTile( - title: game.name, - description: game.description, - badgeText: translateRulesetToString(game.ruleset, context), - badgeColor: getColorFromGameColor(game.color), - isHighlighted: selectedGameId == game.id, - onTap: () async { - setState(() { - if (selectedGameId == game.id) { - selectedGameId = ''; - } else { - selectedGameId = game.id; - } - }); - }, - onLongPress: () async { - final result = await Navigator.push( + child: Visibility( + visible: filteredGames.isNotEmpty, + replacement: Visibility( + visible: widget.games.isNotEmpty, + replacement: TopCenteredMessage( + icon: Icons.info, + title: loc.info, + message: loc.no_games_created_yet, + ), + child: TopCenteredMessage( + icon: Icons.info, + title: loc.info, + message: AppLocalizations.of( + context, + ).there_are_no_games_matching_your_search, + ), + ), + child: ListView.builder( + itemCount: filteredGames.length, + itemBuilder: (BuildContext context, int index) { + final game = filteredGames[index]; + return GameTile( + title: game.name, + description: game.description, + badgeText: translateRulesetToString( + game.ruleset, context, - adaptivePageRoute( - builder: (context) => CreateGameView( - gameToEdit: game, - matchCount: getMatchCount(game), - onGameChanged: () { - widget.onGamesUpdated?.call(); - }, + ), + badgeColor: getColorFromGameColor(game.color), + isHighlighted: selectedGameId == game.id, + onTap: () async { + setState(() { + if (selectedGameId == game.id) { + selectedGameId = ''; + } else { + selectedGameId = game.id; + } + }); + }, + onLongPress: () async { + final result = await Navigator.push( + context, + adaptivePageRoute( + builder: (context) => CreateGameView( + gameToEdit: game, + matchCount: getMatchCount(game), + onGameChanged: () { + widget.onGamesUpdated?.call(); + }, + ), ), - ), - ); - if (result != null && result.game != null) { - // Find the index in the original list to mutate - final originalIndex = widget.games.indexWhere( - (g) => g.id == game.id, ); - if (originalIndex == -1) { - return; + if (result != null && result.game != null) { + // Find the index in the original list to mutate + final originalIndex = widget.games.indexWhere( + (g) => g.id == game.id, + ); + if (originalIndex == -1) { + return; + } + if (result.delete) { + setState(() { + // deselect the game + if (selectedGameId == game.id) { + selectedGameId = ''; + } + widget.games.removeAt(originalIndex); + widget.onGamesUpdated?.call(); + }); + } else { + setState(() { + widget.games[originalIndex] = result.game; + }); + } + _refreshFromSource(); } - if (result.delete) { - setState(() { - // deselect the game - if (selectedGameId == game.id) { - selectedGameId = ''; - } - widget.games.removeAt(originalIndex); - widget.onGamesUpdated?.call(); - }); - } else { - setState(() { - widget.games[originalIndex] = result.game; - }); - } - _refreshFromSource(); - } - }, - ); - }, + }, + ); + }, + ), ), ), ],