promotionDialog function
Show dialog when pawn reaches last square
Implementation
Future<String?> promotionDialog(
BuildContext context, chessjs.Color turn) async {
return showDialog<String>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
final color = turn;
return AlertDialog(
title: Text('Choose promotion'),
content: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
InkWell(
child: color == chessjs.WHITE ? WhiteQueen() : BlackQueen(),
onTap: () {
Navigator.of(context).pop("q");
},
),
InkWell(
child: color == chessjs.WHITE ? WhiteRook() : BlackRook(),
onTap: () {
Navigator.of(context).pop("r");
},
),
InkWell(
child: color == chessjs.WHITE ? WhiteBishop() : BlackBishop(),
onTap: () {
Navigator.of(context).pop("b");
},
),
InkWell(
child: color == chessjs.WHITE ? WhiteKnight() : BlackKnight(),
onTap: () {
Navigator.of(context).pop("n");
},
),
],
),
);
},
).then((value) {
return value;
});
}