From 527ffd194f5fc33f33733ddab23a0b010c202033 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Mon, 23 Feb 2026 21:34:29 +0100 Subject: [PATCH] Fixed PR problems --- .../main_menu/custom_navigation_bar.dart | 2 +- .../group_view/create_group_view.dart | 94 +++++++++++-------- .../group_view/group_detail_view.dart | 15 +-- .../main_menu/group_view/group_view.dart | 2 +- .../create_match/create_match_view.dart | 10 -- .../match_view/match_detail_view.dart | 32 ++++--- .../main_menu/match_view/match_view.dart | 2 +- 7 files changed, 85 insertions(+), 72 deletions(-) diff --git a/lib/presentation/views/main_menu/custom_navigation_bar.dart b/lib/presentation/views/main_menu/custom_navigation_bar.dart index 6d18091..cbea02a 100644 --- a/lib/presentation/views/main_menu/custom_navigation_bar.dart +++ b/lib/presentation/views/main_menu/custom_navigation_bar.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:tallee/core/adaptive_page_route.dart'; import 'package:tallee/core/custom_theme.dart'; import 'package:tallee/l10n/generated/app_localizations.dart'; -import 'package:tallee/presentation/views/main_menu/group_view/groups_view.dart'; +import 'package:tallee/presentation/views/main_menu/group_view/group_view.dart'; import 'package:tallee/presentation/views/main_menu/home_view.dart'; import 'package:tallee/presentation/views/main_menu/match_view/match_view.dart'; import 'package:tallee/presentation/views/main_menu/settings_view/settings_view.dart'; diff --git a/lib/presentation/views/main_menu/group_view/create_group_view.dart b/lib/presentation/views/main_menu/group_view/create_group_view.dart index 262a6e8..be4ed70 100644 --- a/lib/presentation/views/main_menu/group_view/create_group_view.dart +++ b/lib/presentation/views/main_menu/group_view/create_group_view.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:tallee/core/constants.dart'; import 'package:tallee/core/custom_theme.dart'; import 'package:tallee/core/enums.dart'; import 'package:tallee/data/db/database.dart'; @@ -40,7 +39,7 @@ class _CreateGroupViewState extends State { void initState() { super.initState(); db = Provider.of(context, listen: false); - if(widget.groupToEdit != null) { + if (widget.groupToEdit != null) { _groupNameController.text = widget.groupToEdit!.name; setState(() { initialSelectedPlayers = widget.groupToEdit!.members; @@ -66,38 +65,54 @@ class _CreateGroupViewState extends State { child: Scaffold( resizeToAvoidBottomInset: false, backgroundColor: CustomTheme.backgroundColor, - appBar: AppBar(title: Text(widget.groupToEdit == null ? loc.create_new_group : loc.edit_group), actions: widget.groupToEdit == null ? [] : [IconButton(icon: const Icon(Icons.delete), onPressed: () async { - if(widget.groupToEdit != null) { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text(loc.delete_group), - content: Text(loc.this_cannot_be_undone), - actions: [ - TextButton( - onPressed: () => Navigator.of(context).pop(false), - child: Text(loc.cancel), - ), - TextButton( - onPressed: () => Navigator.of(context).pop(true), - child: Text(loc.delete), + appBar: AppBar( + title: Text( + widget.groupToEdit == null ? loc.create_new_group : loc.edit_group, + ), + actions: widget.groupToEdit == null + ? [] + : [ + IconButton( + icon: const Icon(Icons.delete), + onPressed: () async { + if (widget.groupToEdit != null) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text(loc.delete_group), + content: Text(loc.this_cannot_be_undone), + actions: [ + TextButton( + onPressed: () => + Navigator.of(context).pop(false), + child: Text(loc.cancel), + ), + TextButton( + onPressed: () => + Navigator.of(context).pop(true), + child: Text(loc.delete), + ), + ], + ), + ).then((confirmed) async { + if (confirmed == true && context.mounted) { + bool success = await db.groupDao.deleteGroup( + groupId: widget.groupToEdit!.id, + ); + if (!context.mounted) return; + if (success) { + Navigator.pop(context); + } else { + if (!mounted) return; + showSnackbar(message: loc.error_deleting_group); + } + } + }); + } + }, ), ], - ), - ).then((confirmed) async { - if (confirmed == true && context.mounted) { - bool success = await db.groupDao.deleteGroup(groupId: widget.groupToEdit!.id); - if (!context.mounted) return; - if (success) { - Navigator.pop(context); - } else { - if (!mounted) return; - showSnackbar(message: loc.error_deleting_group); - } - } - }); - } - },)],), + ), body: SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -120,7 +135,9 @@ class _CreateGroupViewState extends State { ), ), CustomWidthButton( - text: widget.groupToEdit == null ? loc.create_group : loc.edit_group, + text: widget.groupToEdit == null + ? loc.create_group + : loc.edit_group, sizeRelativeToWidth: 0.95, buttonType: ButtonType.primary, onPressed: @@ -155,7 +172,11 @@ class _CreateGroupViewState extends State { if (success) { Navigator.pop(context, updatedGroup); } else { - showSnackbar(message: widget.groupToEdit == null ? loc.error_creating_group : loc.error_editing_group); + showSnackbar( + message: widget.groupToEdit == null + ? loc.error_creating_group + : loc.error_editing_group, + ); } }, ), @@ -166,12 +187,11 @@ class _CreateGroupViewState extends State { ), ); } + /// Displays a snackbar with the given message and optional action. /// /// [message] The message to display in the snackbar. - void showSnackbar({ - required String message, - }) { + void showSnackbar({required String message}) { final messenger = _scaffoldMessengerKey.currentState; if (messenger != null) { messenger.hideCurrentSnackBar(); diff --git a/lib/presentation/views/main_menu/group_view/group_detail_view.dart b/lib/presentation/views/main_menu/group_view/group_detail_view.dart index 802701a..ad88d66 100644 --- a/lib/presentation/views/main_menu/group_view/group_detail_view.dart +++ b/lib/presentation/views/main_menu/group_view/group_detail_view.dart @@ -1,12 +1,14 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; +import 'package:tallee/core/adaptive_page_route.dart'; import 'package:tallee/core/custom_theme.dart'; import 'package:tallee/data/db/database.dart'; import 'package:tallee/data/dto/group.dart'; import 'package:tallee/data/dto/match.dart'; import 'package:tallee/data/dto/player.dart'; import 'package:tallee/l10n/generated/app_localizations.dart'; +import 'package:tallee/presentation/views/main_menu/group_view/create_group_view.dart'; import 'package:tallee/presentation/widgets/app_skeleton.dart'; import 'package:tallee/presentation/widgets/buttons/animated_dialog_button.dart'; import 'package:tallee/presentation/widgets/buttons/main_menu_button.dart'; @@ -189,9 +191,7 @@ class _GroupDetailViewState extends State { context, adaptivePageRoute( builder: (context) { - return CreateGroupView( - groupToEdit: _group, - ); + return CreateGroupView(groupToEdit: _group); }, ), ); @@ -243,8 +243,9 @@ class _GroupDetailViewState extends State { /// Loads statistics for this group Future _loadStatistics() async { final matches = await db.matchDao.getAllMatches(); - final groupMatches = - matches.where((match) => match.group?.id == _group.id).toList(); + final groupMatches = matches + .where((match) => match.group?.id == _group.id) + .toList(); setState(() { totalMatches = groupMatches.length; @@ -262,7 +263,7 @@ class _GroupDetailViewState extends State { if (match.winner != null) { bestPlayerCounts.update( match.winner!, - (value) => value + 1, + (value) => value + 1, ifAbsent: () => 1, ); } @@ -277,4 +278,4 @@ class _GroupDetailViewState extends State { return bestPlayer; } -} \ No newline at end of file +} diff --git a/lib/presentation/views/main_menu/group_view/group_view.dart b/lib/presentation/views/main_menu/group_view/group_view.dart index 2c9a1fd..cf6f550 100644 --- a/lib/presentation/views/main_menu/group_view/group_view.dart +++ b/lib/presentation/views/main_menu/group_view/group_view.dart @@ -8,7 +8,7 @@ import 'package:tallee/data/dto/group.dart'; import 'package:tallee/data/dto/player.dart'; import 'package:tallee/l10n/generated/app_localizations.dart'; import 'package:tallee/presentation/views/main_menu/group_view/create_group_view.dart'; -import 'package:tallee/presentation/views/main_menu/group_view/group_profile_view.dart'; +import 'package:tallee/presentation/views/main_menu/group_view/group_detail_view.dart'; import 'package:tallee/presentation/widgets/app_skeleton.dart'; import 'package:tallee/presentation/widgets/buttons/main_menu_button.dart'; import 'package:tallee/presentation/widgets/tiles/group_tile.dart'; 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 3f46c8d..cf7ce86 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 @@ -266,14 +266,4 @@ class _CreateMatchViewState extends State { } } } - - /// Determines whether the "Create Match" button should be enabled. - /// - /// Returns `true` if: - /// - A ruleset is selected AND - /// - Either a group is selected OR at least 2 players are selected - bool _enableCreateGameButton() { - return (selectedGroup != null || - (selectedPlayers != null && selectedPlayers!.length > 1)); - } } diff --git a/lib/presentation/views/main_menu/match_view/match_detail_view.dart b/lib/presentation/views/main_menu/match_view/match_detail_view.dart index 05fb6c0..6336bd0 100644 --- a/lib/presentation/views/main_menu/match_view/match_detail_view.dart +++ b/lib/presentation/views/main_menu/match_view/match_detail_view.dart @@ -1,20 +1,20 @@ import 'package:flutter/material.dart'; -import 'package:game_tracker/core/adaptive_page_route.dart'; -import 'package:game_tracker/core/custom_theme.dart'; -import 'package:game_tracker/data/db/database.dart'; -import 'package:game_tracker/data/dto/match.dart'; -import 'package:game_tracker/data/dto/player.dart'; -import 'package:game_tracker/l10n/generated/app_localizations.dart'; -import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/create_match_view.dart'; -import 'package:game_tracker/presentation/views/main_menu/match_view/match_result_view.dart'; -import 'package:game_tracker/presentation/widgets/buttons/animated_dialog_button.dart'; -import 'package:game_tracker/presentation/widgets/buttons/main_menu_button.dart'; -import 'package:game_tracker/presentation/widgets/colored_icon_container.dart'; -import 'package:game_tracker/presentation/widgets/custom_alert_dialog.dart'; -import 'package:game_tracker/presentation/widgets/tiles/info_tile.dart'; -import 'package:game_tracker/presentation/widgets/tiles/text_icon_tile.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; +import 'package:tallee/core/adaptive_page_route.dart'; +import 'package:tallee/core/custom_theme.dart'; +import 'package:tallee/data/db/database.dart'; +import 'package:tallee/data/dto/match.dart'; +import 'package:tallee/data/dto/player.dart'; +import 'package:tallee/l10n/generated/app_localizations.dart'; +import 'package:tallee/presentation/views/main_menu/match_view/create_match/create_match_view.dart'; +import 'package:tallee/presentation/views/main_menu/match_view/match_result_view.dart'; +import 'package:tallee/presentation/widgets/buttons/animated_dialog_button.dart'; +import 'package:tallee/presentation/widgets/buttons/main_menu_button.dart'; +import 'package:tallee/presentation/widgets/colored_icon_container.dart'; +import 'package:tallee/presentation/widgets/custom_alert_dialog.dart'; +import 'package:tallee/presentation/widgets/tiles/info_tile.dart'; +import 'package:tallee/presentation/widgets/tiles/text_icon_tile.dart'; class MatchDetailView extends StatefulWidget { /// A view that displays the profile of a match @@ -81,7 +81,9 @@ class _MatchDetailViewState extends State { onPressed: () => Navigator.of(context).pop(true), child: Text( loc.delete, - style: TextStyle(color: CustomTheme.secondaryColor), + style: const TextStyle( + color: CustomTheme.secondaryColor, + ), ), ), ], diff --git a/lib/presentation/views/main_menu/match_view/match_view.dart b/lib/presentation/views/main_menu/match_view/match_view.dart index 4929f0c..c6abd2b 100644 --- a/lib/presentation/views/main_menu/match_view/match_view.dart +++ b/lib/presentation/views/main_menu/match_view/match_view.dart @@ -12,7 +12,7 @@ import 'package:tallee/data/dto/match.dart'; import 'package:tallee/data/dto/player.dart'; import 'package:tallee/l10n/generated/app_localizations.dart'; import 'package:tallee/presentation/views/main_menu/match_view/create_match/create_match_view.dart'; -import 'package:tallee/presentation/views/main_menu/match_view/match_result_view.dart'; +import 'package:tallee/presentation/views/main_menu/match_view/match_detail_view.dart'; import 'package:tallee/presentation/widgets/app_skeleton.dart'; import 'package:tallee/presentation/widgets/buttons/main_menu_button.dart'; import 'package:tallee/presentation/widgets/tiles/match_tile.dart';