Updated match result view
This commit is contained in:
@@ -11,7 +11,7 @@ import 'package:tallee/data/models/player.dart';
|
|||||||
import 'package:tallee/data/models/score_entry.dart';
|
import 'package:tallee/data/models/score_entry.dart';
|
||||||
import 'package:tallee/data/models/team.dart';
|
import 'package:tallee/data/models/team.dart';
|
||||||
import 'package:tallee/l10n/generated/app_localizations.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/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_checkbox_list_tile.dart';
|
||||||
import 'package:tallee/presentation/widgets/tiles/match_result_view/custom_radio_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<MatchResultView> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
automaticallyImplyLeading: true,
|
||||||
leading: HapticIconButton(
|
leading: HapticIconButton(
|
||||||
icon: const Icon(Icons.close),
|
icon: isLiveEditMode
|
||||||
onPressed: () {
|
? const Icon(Icons.arrow_back_ios)
|
||||||
widget.onWinnerChanged?.call();
|
: const Icon(Icons.close),
|
||||||
Navigator.pop(context);
|
onPressed: isLiveEditMode
|
||||||
},
|
? () => setState(() {
|
||||||
|
isLiveEditMode = false;
|
||||||
|
})
|
||||||
|
: () => {widget.onWinnerChanged?.call(), Navigator.pop(context)},
|
||||||
),
|
),
|
||||||
title: Text(widget.match.name),
|
title: Text(widget.match.name),
|
||||||
),
|
),
|
||||||
body: SafeArea(
|
body: Column(
|
||||||
child: Column(
|
children: [
|
||||||
children: [
|
Expanded(
|
||||||
Expanded(
|
child: isLiveEditMode
|
||||||
child: isLiveEditMode
|
// Live Edit Mode
|
||||||
// Live Edit Mode
|
? buildLiveEditWidet(isTeamMatch)
|
||||||
? buildLiveEditWidet(isTeamMatch)
|
// Normal Container
|
||||||
// Normal Container
|
: Container(
|
||||||
: Container(
|
margin: const EdgeInsets.symmetric(
|
||||||
margin: const EdgeInsets.symmetric(
|
horizontal: 12,
|
||||||
horizontal: 12,
|
vertical: 10,
|
||||||
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)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
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())
|
// Show player selection
|
||||||
// Button to switch to live edit mode
|
if (rulesetSupportsPlayerSelection())
|
||||||
...[
|
if (ruleset == Ruleset.multipleWinners)
|
||||||
CustomWidthButton(
|
Expanded(
|
||||||
text: isLiveEditMode ? loc.exit_view : loc.live_edit_mode,
|
child: buildMultipleWinnerSelectionWidget(
|
||||||
sizeRelativeToWidth: 0.95,
|
isTeamMatch,
|
||||||
buttonType: ButtonType.secondary,
|
),
|
||||||
onPressed: () => setState(() {
|
)
|
||||||
isLiveEditMode = !isLiveEditMode;
|
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,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user