Updated game title process

This commit is contained in:
2026-01-07 14:34:37 +01:00
parent cd2770be26
commit fdd0e7579a

View File

@@ -32,7 +32,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
final TextEditingController _matchNameController = TextEditingController(); final TextEditingController _matchNameController = TextEditingController();
/// Hint text for the match name input field /// Hint text for the match name input field
String hintText = 'Match Name'; String? hintText;
/// List of all groups from the database /// List of all groups from the database
List<Group> groupsList = []; List<Group> groupsList = [];
@@ -101,6 +101,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
final loc = AppLocalizations.of(context); final loc = AppLocalizations.of(context);
hintText ??= loc.match_name;
_rulesets = [ _rulesets = [
(Ruleset.singleWinner, loc.ruleset_single_winner), (Ruleset.singleWinner, loc.ruleset_single_winner),
(Ruleset.singleLoser, loc.ruleset_single_loser), (Ruleset.singleLoser, loc.ruleset_single_loser),
@@ -137,7 +138,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 5), margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
child: TextInputField( child: TextInputField(
controller: _matchNameController, controller: _matchNameController,
hintText: hintText, hintText: hintText ?? '',
), ),
), ),
ChooseTile( ChooseTile(
@@ -162,7 +163,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
(r) => r.$1 == selectedRuleset, (r) => r.$1 == selectedRuleset,
); );
} else { } else {
hintText = 'Match Name'; hintText = AppLocalizations.of(context).match_name;
selectedRuleset = null; selectedRuleset = null;
} }
}); });
@@ -237,7 +238,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
? () async { ? () async {
Match match = Match( Match match = Match(
name: _matchNameController.text.isEmpty name: _matchNameController.text.isEmpty
? hintText ? (hintText ?? '')
: _matchNameController.text.trim(), : _matchNameController.text.trim(),
createdAt: DateTime.now(), createdAt: DateTime.now(),
group: selectedGroup, group: selectedGroup,
@@ -265,8 +266,11 @@ class _CreateMatchViewState extends State<CreateMatchView> {
); );
} }
/// Determines whether the "Create Game" button should be enabled based on /// Determines whether the "Create Match" button should be enabled.
/// the current state of the input fields. ///
/// Returns `true` if:
/// - A ruleset is selected AND
/// - Either a group is selected OR at least 2 players are selected
bool _enableCreateGameButton() { bool _enableCreateGameButton() {
return (selectedGroup != null || return (selectedGroup != null ||
(selectedPlayers != null && selectedPlayers!.length > 1)) && (selectedPlayers != null && selectedPlayers!.length > 1)) &&