Pop promotion dialog with context.pop()
This commit is contained in:
parent
abf322572d
commit
17ac437f5b
@ -1,5 +1,6 @@
|
|||||||
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';
|
||||||
|
|
||||||
@ -26,35 +27,31 @@ class PromotionDialog extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
pieceChosen(context, ChessPieceClass.queen);
|
||||||
pieceChosen(ChessPieceClass.queen);
|
|
||||||
},
|
},
|
||||||
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
|
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
|
||||||
pieceClass: ChessPieceClass.queen, color: sideColor)]!),
|
pieceClass: ChessPieceClass.queen, color: sideColor)]!),
|
||||||
iconSize: 200,
|
iconSize: iconSize,
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
pieceChosen(context, ChessPieceClass.rook);
|
||||||
pieceChosen(ChessPieceClass.rook);
|
|
||||||
},
|
},
|
||||||
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
|
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
|
||||||
pieceClass: ChessPieceClass.rook, color: sideColor)]!),
|
pieceClass: ChessPieceClass.rook, color: sideColor)]!),
|
||||||
iconSize: 100,
|
iconSize: iconSize,
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
pieceChosen(context, ChessPieceClass.knight);
|
||||||
pieceChosen(ChessPieceClass.knight);
|
|
||||||
},
|
},
|
||||||
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
|
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
|
||||||
pieceClass: ChessPieceClass.knight, color: sideColor)]!),
|
pieceClass: ChessPieceClass.knight, color: sideColor)]!),
|
||||||
iconSize: 10,
|
iconSize: iconSize,
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
pieceChosen(context, ChessPieceClass.bishop);
|
||||||
pieceChosen(ChessPieceClass.bishop);
|
|
||||||
},
|
},
|
||||||
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
|
icon: SvgPicture.asset(chessPiecesAssets[ChessPieceAssetKey(
|
||||||
pieceClass: ChessPieceClass.bishop, color: sideColor)]!),
|
pieceClass: ChessPieceClass.bishop, color: sideColor)]!),
|
||||||
@ -65,7 +62,8 @@ class PromotionDialog extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pieceChosen(ChessPieceClass pieceClass) {
|
void pieceChosen(BuildContext context, ChessPieceClass pieceClass) {
|
||||||
|
context.pop();
|
||||||
PromotionBloc.getInstance()
|
PromotionBloc.getInstance()
|
||||||
.add(PieceChosen(pieceClass: pieceClass, color: sideColor));
|
.add(PieceChosen(pieceClass: pieceClass, color: sideColor));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user