now only able to select supported team counts
This commit is contained in:
@@ -14,7 +14,8 @@ class _CreateTournamentPageState extends State<CreateTournamentPage> {
|
|||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
final _nameController = TextEditingController();
|
final _nameController = TextEditingController();
|
||||||
final _descriptionController = TextEditingController();
|
final _descriptionController = TextEditingController();
|
||||||
final _maxTeamAmountController = TextEditingController();
|
|
||||||
|
int _maxTeamAmount = 2;
|
||||||
|
|
||||||
DateTime? _startDate;
|
DateTime? _startDate;
|
||||||
DateTime? _endDate;
|
DateTime? _endDate;
|
||||||
@@ -65,7 +66,7 @@ class _CreateTournamentPageState extends State<CreateTournamentPage> {
|
|||||||
await provider.createTournament(
|
await provider.createTournament(
|
||||||
_nameController.text,
|
_nameController.text,
|
||||||
_descriptionController.text,
|
_descriptionController.text,
|
||||||
int.parse(_maxTeamAmountController.text),
|
_maxTeamAmount,
|
||||||
_startDate!,
|
_startDate!,
|
||||||
_endDate!,
|
_endDate!,
|
||||||
);
|
);
|
||||||
@@ -85,7 +86,6 @@ class _CreateTournamentPageState extends State<CreateTournamentPage> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_nameController.dispose();
|
_nameController.dispose();
|
||||||
_descriptionController.dispose();
|
_descriptionController.dispose();
|
||||||
_maxTeamAmountController.dispose();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,16 +115,21 @@ class _CreateTournamentPageState extends State<CreateTournamentPage> {
|
|||||||
value == null || value.isEmpty ? 'Required' : null,
|
value == null || value.isEmpty ? 'Required' : null,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
TextFormField(
|
DropdownButtonFormField<int>(
|
||||||
controller: _maxTeamAmountController,
|
initialValue: _maxTeamAmount,
|
||||||
decoration: const InputDecoration(labelText: 'Max Teams'),
|
decoration: const InputDecoration(labelText: 'Max Teams'),
|
||||||
keyboardType: TextInputType.number,
|
items: [2, 4, 8].map((int value) {
|
||||||
validator: (value) {
|
return DropdownMenuItem<int>(
|
||||||
if (value == null || value.isEmpty) return 'Required';
|
value: value,
|
||||||
if (int.tryParse(value) == null || int.parse(value) <= 0) {
|
child: Text(value.toString()),
|
||||||
return 'Must be a positive integer';
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (int? newValue) {
|
||||||
|
if (newValue != null) {
|
||||||
|
setState(() {
|
||||||
|
_maxTeamAmount = newValue;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class HomePage extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
padding: EdgeInsets.fromLTRB(0, 12, 0, 24),
|
padding: EdgeInsets.fromLTRB(0, 12, 0, 36),
|
||||||
child: Column(children: [Spacer(), AvailableTournamentList()]),
|
child: Column(children: [Spacer(), AvailableTournamentList()]),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
|
|||||||
Reference in New Issue
Block a user