fix: callbacks when game deletes matches
This commit is contained in:
@@ -177,6 +177,7 @@ class _ChooseGameViewState extends State<ChooseGameView> {
|
|||||||
if (result.delete) {
|
if (result.delete) {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.games.removeAt(originalIndex);
|
widget.games.removeAt(originalIndex);
|
||||||
|
widget.onGamesUpdated?.call();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@@ -28,10 +28,13 @@ class CreateMatchView extends StatefulWidget {
|
|||||||
this.onWinnerChanged,
|
this.onWinnerChanged,
|
||||||
this.matchToEdit,
|
this.matchToEdit,
|
||||||
this.onMatchUpdated,
|
this.onMatchUpdated,
|
||||||
|
this.onMatchesUpdated,
|
||||||
});
|
});
|
||||||
|
|
||||||
final VoidCallback? onWinnerChanged;
|
final VoidCallback? onWinnerChanged;
|
||||||
|
|
||||||
|
final VoidCallback? onMatchesUpdated;
|
||||||
|
|
||||||
final void Function(Match)? onMatchUpdated;
|
final void Function(Match)? onMatchUpdated;
|
||||||
|
|
||||||
/// An optional match to prefill the fields for editing.
|
/// An optional match to prefill the fields for editing.
|
||||||
@@ -138,6 +141,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
builder: (context) => ChooseGameView(
|
builder: (context) => ChooseGameView(
|
||||||
games: gamesList,
|
games: gamesList,
|
||||||
initialGameId: selectedGame?.id ?? '',
|
initialGameId: selectedGame?.id ?? '',
|
||||||
|
onGamesUpdated: widget.onMatchesUpdated,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -118,8 +118,10 @@ class _MatchViewState extends State<MatchView> {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
adaptivePageRoute(
|
adaptivePageRoute(
|
||||||
builder: (context) =>
|
builder: (context) => CreateMatchView(
|
||||||
CreateMatchView(onWinnerChanged: loadMatches),
|
onWinnerChanged: loadMatches,
|
||||||
|
onMatchesUpdated: loadMatches,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user