Change behavior of promotion dialog.

This commit is contained in:
Marco 2023-07-06 00:06:03 +02:00
parent fea24c8274
commit 95fba78d0c

View File

@ -1,6 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:mchess/chess_bloc/promotion_bloc.dart'; import 'package:mchess/chess_bloc/promotion_bloc.dart';
import 'package:mchess/utils/chess_utils.dart'; import 'package:mchess/utils/chess_utils.dart';
@ -27,8 +26,8 @@ class PromotionDialog extends StatelessWidget {
children: [ children: [
IconButton( IconButton(
onPressed: () { onPressed: () {
Navigator.pop(context);
pieceChosen(ChessPieceClass.queen); pieceChosen(ChessPieceClass.queen);
context.pop();
}, },
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey( icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
pieceClass: ChessPieceClass.queen, color: sideColor)]!), pieceClass: ChessPieceClass.queen, color: sideColor)]!),
@ -36,8 +35,8 @@ class PromotionDialog extends StatelessWidget {
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
Navigator.pop(context);
pieceChosen(ChessPieceClass.rook); pieceChosen(ChessPieceClass.rook);
context.pop();
}, },
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey( icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
pieceClass: ChessPieceClass.rook, color: sideColor)]!), pieceClass: ChessPieceClass.rook, color: sideColor)]!),
@ -45,8 +44,8 @@ class PromotionDialog extends StatelessWidget {
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
Navigator.pop(context);
pieceChosen(ChessPieceClass.knight); pieceChosen(ChessPieceClass.knight);
context.pop();
}, },
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey( icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
pieceClass: ChessPieceClass.knight, color: sideColor)]!), pieceClass: ChessPieceClass.knight, color: sideColor)]!),
@ -54,8 +53,8 @@ class PromotionDialog extends StatelessWidget {
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
Navigator.pop(context);
pieceChosen(ChessPieceClass.bishop); pieceChosen(ChessPieceClass.bishop);
context.pop();
}, },
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey( icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
pieceClass: ChessPieceClass.bishop, color: sideColor)]!), pieceClass: ChessPieceClass.bishop, color: sideColor)]!),