diff --git a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart index f3b4d79..f2f86be 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart @@ -31,6 +31,8 @@ class _CreateMatchViewState extends State { /// Controller for the match name input field final TextEditingController _matchNameController = TextEditingController(); + String hintText = "Match Name"; + /// List of all groups from the database List groupsList = []; @@ -132,7 +134,7 @@ class _CreateMatchViewState extends State { margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 5), child: TextInputField( controller: _matchNameController, - hintText: 'Match name', + hintText: hintText, ), ), ChooseTile( @@ -151,11 +153,13 @@ class _CreateMatchViewState extends State { ); setState(() { if (selectedGameIndex != -1) { + hintText = games[selectedGameIndex].$1; selectedRuleset = games[selectedGameIndex].$3; selectedRulesetIndex = rulesets.indexWhere( (r) => r.$1 == selectedRuleset, ); } else { + hintText = "Match Name"; selectedRuleset = null; } }); @@ -228,7 +232,9 @@ class _CreateMatchViewState extends State { onPressed: _enableCreateGameButton() ? () async { Match match = Match( - name: _matchNameController.text.trim(), + name: _matchNameController.text.isEmpty + ? hintText.trim() + : _matchNameController.text.trim(), createdAt: DateTime.now(), group: selectedGroup, players: selectedPlayers, @@ -258,9 +264,8 @@ class _CreateMatchViewState extends State { /// Determines whether the "Create Game" button should be enabled based on /// the current state of the input fields. bool _enableCreateGameButton() { - return _matchNameController.text.isNotEmpty && - (selectedGroup != null || - (selectedPlayers != null && selectedPlayers!.length > 1)) && - selectedRuleset != null; + return selectedGroup != null || + (selectedPlayers != null && selectedPlayers!.length > 1) && + selectedRuleset != null; } }