From a497ae872b17150361446aa813bf9f9ed90193cc Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Thu, 21 May 2026 18:44:30 +0200 Subject: [PATCH] Updated match result view --- .../match_view/match_result_view.dart | 205 ++++++++++-------- 1 file changed, 110 insertions(+), 95 deletions(-) diff --git a/lib/presentation/views/main_menu/match_view/match_result_view.dart b/lib/presentation/views/main_menu/match_view/match_result_view.dart index 39cfef8..37386b4 100644 --- a/lib/presentation/views/main_menu/match_view/match_result_view.dart +++ b/lib/presentation/views/main_menu/match_view/match_result_view.dart @@ -11,7 +11,7 @@ import 'package:tallee/data/models/player.dart'; import 'package:tallee/data/models/score_entry.dart'; import 'package:tallee/data/models/team.dart'; import 'package:tallee/l10n/generated/app_localizations.dart'; -import 'package:tallee/presentation/widgets/buttons/custom_width_button.dart'; +import 'package:tallee/presentation/widgets/buttons/animated_dialog_button.dart'; import 'package:tallee/presentation/widgets/buttons/haptic_icon_button.dart'; import 'package:tallee/presentation/widgets/tiles/match_result_view/custom_checkbox_list_tile.dart'; import 'package:tallee/presentation/widgets/tiles/match_result_view/custom_radio_list_tile.dart'; @@ -90,109 +90,124 @@ class _MatchResultViewState extends State { return Scaffold( backgroundColor: CustomTheme.backgroundColor, appBar: AppBar( + automaticallyImplyLeading: true, leading: HapticIconButton( - icon: const Icon(Icons.close), - onPressed: () { - widget.onWinnerChanged?.call(); - Navigator.pop(context); - }, + icon: isLiveEditMode + ? const Icon(Icons.arrow_back_ios) + : const Icon(Icons.close), + onPressed: isLiveEditMode + ? () => setState(() { + isLiveEditMode = false; + }) + : () => {widget.onWinnerChanged?.call(), Navigator.pop(context)}, ), title: Text(widget.match.name), ), - body: SafeArea( - child: Column( - children: [ - Expanded( - child: isLiveEditMode - // Live Edit Mode - ? buildLiveEditWidet(isTeamMatch) - // Normal Container - : Container( - margin: const EdgeInsets.symmetric( - horizontal: 12, - vertical: 10, - ), - padding: const EdgeInsets.symmetric( - vertical: 10, - horizontal: 10, - ), - decoration: BoxDecoration( - color: CustomTheme.boxColor, - border: Border.all(color: CustomTheme.boxBorderColor), - borderRadius: BorderRadius.circular(12), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - getTitleForRuleset(loc), - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 10), - - // Show player selection - if (rulesetSupportsPlayerSelection()) - if (ruleset == Ruleset.multipleWinners) - // TODO: Implement view for teams - Expanded( - child: buildMultipleWinnerSelectionWidget( - isTeamMatch, - ), - ) - else - Expanded( - child: buildPlayerSelectionWidget(isTeamMatch), - ), - - // Show score entry - if (rulesetSupportsScoreEntry()) - Expanded(child: buildScoreEntryWidget(isTeamMatch)), - - // Show draggable placement list - if (rulesetSupportsDragBehaviour()) - Expanded(child: buildPlacementWidget(isTeamMatch)), - ], - ), + body: Column( + children: [ + Expanded( + child: isLiveEditMode + // Live Edit Mode + ? buildLiveEditWidet(isTeamMatch) + // Normal Container + : Container( + margin: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 10, ), - ), + padding: const EdgeInsets.symmetric( + vertical: 10, + horizontal: 10, + ), + decoration: BoxDecoration( + color: CustomTheme.boxColor, + border: Border.all(color: CustomTheme.boxBorderColor), + borderRadius: BorderRadius.circular(12), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + getTitleForRuleset(loc), + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 10), - if (rulesetSupportsScoreEntry()) - // Button to switch to live edit mode - ...[ - CustomWidthButton( - text: isLiveEditMode ? loc.exit_view : loc.live_edit_mode, - sizeRelativeToWidth: 0.95, - buttonType: ButtonType.secondary, - onPressed: () => setState(() { - isLiveEditMode = !isLiveEditMode; - }), + // Show player selection + if (rulesetSupportsPlayerSelection()) + if (ruleset == Ruleset.multipleWinners) + Expanded( + child: buildMultipleWinnerSelectionWidget( + isTeamMatch, + ), + ) + else + Expanded( + child: buildPlayerSelectionWidget(isTeamMatch), + ), + + // Show score entry + if (rulesetSupportsScoreEntry()) + Expanded(child: buildScoreEntryWidget(isTeamMatch)), + + // Show draggable placement list + if (rulesetSupportsDragBehaviour()) + Expanded(child: buildPlacementWidget(isTeamMatch)), + ], + ), + ), + ), + + if (!isLiveEditMode) ...[ + Padding( + padding: const EdgeInsets.fromLTRB(12, 0, 12, 20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (rulesetSupportsScoreEntry()) ...[ + // Button to switch to live edit mode + AnimatedDialogButton( + buttonConstraints: const BoxConstraints( + minWidth: double.infinity, + minHeight: 50, + ), + buttonText: loc.live_edit_mode, + buttonType: ButtonType.secondary, + onPressed: () => setState(() { + isLiveEditMode = !isLiveEditMode; + }), + ), + ], + + // Save Changes Button + AnimatedDialogButton( + buttonConstraints: const BoxConstraints( + minWidth: double.infinity, + minHeight: 50, + ), + buttonText: loc.save_changes, + onPressed: canSave + ? () async { + final ending = DateTime.now(); + await db.matchDao.updateMatchEndedAt( + matchId: widget.match.id, + endedAt: ending, + ); + await _handleSaving(); + if (!context.mounted) return; + Navigator.pop(context); + } + : null, + ), + ], ), - const SizedBox(height: 10), - ], - - // Save Changes Button - CustomWidthButton( - text: loc.save_changes, - sizeRelativeToWidth: 0.95, - onPressed: canSave - ? () async { - final ending = DateTime.now(); - await db.matchDao.updateMatchEndedAt( - matchId: widget.match.id, - endedAt: ending, - ); - await _handleSaving(); - if (!context.mounted) return; - Navigator.pop(context); - } - : null, ), ], - ), + ], ), ); }