diff --git a/lib/presentation/views/main_menu/create_game/create_game_view.dart b/lib/presentation/views/main_menu/create_game/create_game_view.dart index 2df52ec..ef7e267 100644 --- a/lib/presentation/views/main_menu/create_game/create_game_view.dart +++ b/lib/presentation/views/main_menu/create_game/create_game_view.dart @@ -7,7 +7,7 @@ import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/presentation/views/main_menu/create_game/choose_group_view.dart'; import 'package:game_tracker/presentation/views/main_menu/create_game/choose_ruleset_view.dart'; import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart'; -import 'package:game_tracker/presentation/widgets/text_input_field.dart'; +import 'package:game_tracker/presentation/widgets/text_input/custom_text_input_field.dart'; import 'package:provider/provider.dart'; import 'package:skeletonizer/skeletonizer.dart'; @@ -19,19 +19,31 @@ class CreateGameView extends StatefulWidget { } class _CreateGameViewState extends State { - final TextEditingController _gameNameController = TextEditingController(); late final AppDatabase db; late Future> _allGroupsFuture; + final TextEditingController _gameNameController = TextEditingController(); + /// List of all groups from the database late final List groupsList; + /// The currently selected group Group? selectedGroup; + + /// The index of the currently selected group in [groupsList] to mark it in + /// the [ChooseGroupView] int selectedGroupIndex = -1; + + /// The currently selected ruleset Ruleset? selectedRuleset; + + /// The index of the currently selected ruleset in [rulesets] to mark it in + /// the [ChooseRulesetView] int selectedRulesetIndex = -1; bool isLoading = true; + /// List of available rulesets with their display names and descriptions + /// as tuples of (Ruleset, String, String) List<(Ruleset, String, String)> rulesets = [ ( Ruleset.singleWinner, @@ -106,18 +118,12 @@ class _CreateGameViewState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Container( - margin: const EdgeInsets.symmetric( - horizontal: 12, - vertical: 10, - ), - child: TextInputField( - controller: _gameNameController, - hintText: 'Game name', - onChanged: (value) { - setState(() {}); - }, - ), + CustomTextInputField( + controller: _gameNameController, + hintText: 'Game name', + onChanged: (value) { + setState(() {}); + }, ), GestureDetector( onTap: () async { diff --git a/lib/presentation/widgets/text_input/custom_text_input_field.dart b/lib/presentation/widgets/text_input/custom_text_input_field.dart new file mode 100644 index 0000000..2b6efd5 --- /dev/null +++ b/lib/presentation/widgets/text_input/custom_text_input_field.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; +import 'package:game_tracker/presentation/widgets/text_input_field.dart'; + +class CustomTextInputField extends StatefulWidget { + final TextEditingController controller; + final String hintText; + final void Function(String)? onChanged; + + const CustomTextInputField({ + super.key, + required this.controller, + required this.hintText, + this.onChanged, + }); + + @override + State createState() => _CustomTextInputFieldState(); +} + +class _CustomTextInputFieldState extends State { + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + child: TextInputField( + controller: widget.controller, + hintText: widget.hintText, + onChanged: widget.onChanged, + ), + ); + } +}