Implemented winner update

This commit is contained in:
2026-01-18 00:42:18 +01:00
parent 1450e9b958
commit a56e738064
2 changed files with 7 additions and 4 deletions

View File

@@ -38,6 +38,8 @@ class MatchProfileView extends StatefulWidget {
class _MatchProfileViewState extends State<MatchProfileView> { class _MatchProfileViewState extends State<MatchProfileView> {
late final AppDatabase db; late final AppDatabase db;
late Player? currentWinner;
/// All players who participated in the match /// All players who participated in the match
late final List<Player> allPlayers; late final List<Player> allPlayers;
@@ -46,6 +48,7 @@ class _MatchProfileViewState extends State<MatchProfileView> {
super.initState(); super.initState();
db = Provider.of<AppDatabase>(context, listen: false); db = Provider.of<AppDatabase>(context, listen: false);
allPlayers = _getAllPlayers(); allPlayers = _getAllPlayers();
currentWinner = widget.match.winner;
} }
@override @override
@@ -178,7 +181,7 @@ class _MatchProfileViewState extends State<MatchProfileView> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
/// TODO: Implement different ruleset results display /// TODO: Implement different ruleset results display
if (widget.match.winner != null) ...[ if (currentWinner != null) ...[
Text( Text(
loc.winner, loc.winner,
style: const TextStyle( style: const TextStyle(
@@ -187,7 +190,7 @@ class _MatchProfileViewState extends State<MatchProfileView> {
), ),
), ),
Text( Text(
widget.match.winner?.name ?? '-', currentWinner!.name,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -221,7 +224,7 @@ class _MatchProfileViewState extends State<MatchProfileView> {
text: loc.enter_results, text: loc.enter_results,
icon: Icons.note_add, icon: Icons.note_add,
onPressed: () async { onPressed: () async {
await Navigator.push( currentWinner = await Navigator.push(
context, context,
adaptivePageRoute( adaptivePageRoute(
fullscreenDialog: true, fullscreenDialog: true,

View File

@@ -54,7 +54,7 @@ class _MatchResultViewState extends State<MatchResultView> {
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
onPressed: () { onPressed: () {
widget.onWinnerChanged?.call(); widget.onWinnerChanged?.call();
Navigator.of(context).pop(); Navigator.of(context).pop(_selectedPlayer);
}, },
), ),
title: Text(widget.match.name), title: Text(widget.match.name),