Implementierung der Games #203

Merged
flixcoo merged 34 commits from feature/119-implementierung-der-games-2 into development 2026-05-09 17:13:46 +00:00
6 changed files with 107 additions and 55 deletions
Showing only changes of commit f9eafa5b3d - Show all commits

View File

@@ -80,6 +80,7 @@
"members": "Mitglieder", "members": "Mitglieder",
"most_points": "Höchste Punkte", "most_points": "Höchste Punkte",
"no_data_available": "Keine Daten verfügbar", "no_data_available": "Keine Daten verfügbar",
"no_games_created_yet": "Noch keine Spielvorlagen erstellt",
"no_groups_created_yet": "Noch keine Gruppen erstellt", "no_groups_created_yet": "Noch keine Gruppen erstellt",
"no_licenses_found": "Keine Lizenzen gefunden", "no_licenses_found": "Keine Lizenzen gefunden",
"no_license_text_available": "Kein Lizenztext verfügbar", "no_license_text_available": "Kein Lizenztext verfügbar",
@@ -125,6 +126,7 @@
"statistics": "Statistiken", "statistics": "Statistiken",
"stats": "Statistiken", "stats": "Statistiken",
"successfully_added_player": "Spieler:in {playerName} erfolgreich hinzugefügt", "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", "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.", "this_cannot_be_undone": "Dies kann nicht rückgängig gemacht werden.",
"tie": "Unentschieden", "tie": "Unentschieden",

View File

@@ -81,6 +81,7 @@
"members": "Members", "members": "Members",
"most_points": "Most Points", "most_points": "Most Points",
"no_data_available": "No data available", "no_data_available": "No data available",
"no_games_created_yet": "No games created yet",
"no_groups_created_yet": "No groups created yet", "no_groups_created_yet": "No groups created yet",
"no_licenses_found": "No licenses found", "no_licenses_found": "No licenses found",
"no_license_text_available": "No license text available", "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", "there_is_no_group_matching_your_search": "There is no group matching your search",
"this_cannot_be_undone": "This can't be undone.", "this_cannot_be_undone": "This can't be undone.",
"tie": "Tie", "tie": "Tie",

View File

@@ -536,6 +536,12 @@ abstract class AppLocalizations {
/// **'No data available'** /// **'No data available'**
String get 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. /// No description provided for @no_groups_created_yet.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
@@ -800,6 +806,12 @@ abstract class AppLocalizations {
/// **'Successfully added player {playerName}'** /// **'Successfully added player {playerName}'**
String successfully_added_player(String 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. /// No description provided for @there_is_no_group_matching_your_search.
/// ///
/// In en, this message translates to: /// In en, this message translates to:

View File

@@ -243,6 +243,9 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get no_data_available => 'Keine Daten verfügbar'; String get no_data_available => 'Keine Daten verfügbar';
@override
String get no_games_created_yet => 'Noch keine Spielvorlagen erstellt';
@override @override
String get no_groups_created_yet => 'Noch keine Gruppen erstellt'; 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'; 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 @override
String get there_is_no_group_matching_your_search => String get there_is_no_group_matching_your_search =>
'Es gibt keine Gruppe, die deiner Suche entspricht'; 'Es gibt keine Gruppe, die deiner Suche entspricht';

View File

@@ -243,6 +243,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get no_data_available => 'No data available'; String get no_data_available => 'No data available';
@override
String get no_games_created_yet => 'No games created yet';
@override @override
String get no_groups_created_yet => 'No groups created yet'; String get no_groups_created_yet => 'No groups created yet';
@@ -382,6 +385,10 @@ class AppLocalizationsEn extends AppLocalizations {
return 'Successfully added player $playerName'; return 'Successfully added player $playerName';
} }
@override
String get there_are_no_games_matching_your_search =>
'There are no games matching your search';
@override @override
String get there_is_no_group_matching_your_search => String get there_is_no_group_matching_your_search =>
'There is no group matching your search'; 'There is no group matching your search';

View File

@@ -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/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/text_input/custom_search_bar.dart';
import 'package:tallee/presentation/widgets/tiles/game_tile.dart'; import 'package:tallee/presentation/widgets/tiles/game_tile.dart';
import 'package:tallee/presentation/widgets/top_centered_message.dart';
class ChooseGameView extends StatefulWidget { class ChooseGameView extends StatefulWidget {
/// A view that allows the user to choose a game from a list of available games /// A view that allows the user to choose a game from a list of available games
@@ -134,65 +135,86 @@ class _ChooseGameViewState extends State<ChooseGameView> {
// Game list // Game list
Expanded( Expanded(
child: ListView.builder( child: Visibility(
itemCount: filteredGames.length, visible: filteredGames.isNotEmpty,
itemBuilder: (BuildContext context, int index) { replacement: Visibility(
final game = filteredGames[index]; visible: widget.games.isNotEmpty,
return GameTile( replacement: TopCenteredMessage(
title: game.name, icon: Icons.info,
description: game.description, title: loc.info,
badgeText: translateRulesetToString(game.ruleset, context), message: loc.no_games_created_yet,
badgeColor: getColorFromGameColor(game.color), ),
isHighlighted: selectedGameId == game.id, child: TopCenteredMessage(
onTap: () async { icon: Icons.info,
setState(() { title: loc.info,
if (selectedGameId == game.id) { message: AppLocalizations.of(
selectedGameId = ''; context,
} else { ).there_are_no_games_matching_your_search,
selectedGameId = game.id; ),
} ),
}); child: ListView.builder(
}, itemCount: filteredGames.length,
onLongPress: () async { itemBuilder: (BuildContext context, int index) {
final result = await Navigator.push( final game = filteredGames[index];
return GameTile(
title: game.name,
description: game.description,
badgeText: translateRulesetToString(
game.ruleset,
context, context,
adaptivePageRoute( ),
builder: (context) => CreateGameView( badgeColor: getColorFromGameColor(game.color),
gameToEdit: game, isHighlighted: selectedGameId == game.id,
matchCount: getMatchCount(game), onTap: () async {
onGameChanged: () { setState(() {
widget.onGamesUpdated?.call(); 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) { if (result != null && result.game != null) {
return; // 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();
}
},
);
},
), ),
), ),
], ],