From a66cf7603a3a10875f575b479140e76adea8687a Mon Sep 17 00:00:00 2001 From: tikaiz Date: Tue, 10 Mar 2026 17:03:10 +0100 Subject: [PATCH] now only able to select supported team counts --- .../lib/pages/create_tournament_page.dart | 27 +++++++++++-------- .../lib/pages/home_page.dart | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/frontend_splatournament_manager/lib/pages/create_tournament_page.dart b/frontend_splatournament_manager/lib/pages/create_tournament_page.dart index 18fc771..6581127 100644 --- a/frontend_splatournament_manager/lib/pages/create_tournament_page.dart +++ b/frontend_splatournament_manager/lib/pages/create_tournament_page.dart @@ -14,7 +14,8 @@ class _CreateTournamentPageState extends State { final _formKey = GlobalKey(); final _nameController = TextEditingController(); final _descriptionController = TextEditingController(); - final _maxTeamAmountController = TextEditingController(); + + int _maxTeamAmount = 2; DateTime? _startDate; DateTime? _endDate; @@ -65,7 +66,7 @@ class _CreateTournamentPageState extends State { await provider.createTournament( _nameController.text, _descriptionController.text, - int.parse(_maxTeamAmountController.text), + _maxTeamAmount, _startDate!, _endDate!, ); @@ -85,7 +86,6 @@ class _CreateTournamentPageState extends State { void dispose() { _nameController.dispose(); _descriptionController.dispose(); - _maxTeamAmountController.dispose(); super.dispose(); } @@ -115,16 +115,21 @@ class _CreateTournamentPageState extends State { value == null || value.isEmpty ? 'Required' : null, ), const SizedBox(height: 16), - TextFormField( - controller: _maxTeamAmountController, + DropdownButtonFormField( + initialValue: _maxTeamAmount, decoration: const InputDecoration(labelText: 'Max Teams'), - keyboardType: TextInputType.number, - validator: (value) { - if (value == null || value.isEmpty) return 'Required'; - if (int.tryParse(value) == null || int.parse(value) <= 0) { - return 'Must be a positive integer'; + items: [2, 4, 8].map((int value) { + return DropdownMenuItem( + value: value, + child: Text(value.toString()), + ); + }).toList(), + onChanged: (int? newValue) { + if (newValue != null) { + setState(() { + _maxTeamAmount = newValue; + }); } - return null; }, ), const SizedBox(height: 24), diff --git a/frontend_splatournament_manager/lib/pages/home_page.dart b/frontend_splatournament_manager/lib/pages/home_page.dart index 2bee6b2..8c315af 100644 --- a/frontend_splatournament_manager/lib/pages/home_page.dart +++ b/frontend_splatournament_manager/lib/pages/home_page.dart @@ -43,7 +43,7 @@ class HomePage extends StatelessWidget { ], ), body: Container( - padding: EdgeInsets.fromLTRB(0, 12, 0, 24), + padding: EdgeInsets.fromLTRB(0, 12, 0, 36), child: Column(children: [Spacer(), AvailableTournamentList()]), ), floatingActionButton: FloatingActionButton(