Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/widgets/chessboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:provider/provider.dart';

class Chessboard extends StatefulWidget {
final Board board;
final String? hintSquare;

Chessboard({
required String fen,
Expand All @@ -26,10 +27,11 @@ class Chessboard extends StatefulWidget {
BuildPiece? buildPiece,
BuildSquare? buildSquare,
BuildCustomPiece? buildCustomPiece,
String? hintSquare,
Color lastMoveHighlightColor = const Color.fromRGBO(128, 128, 128, .3),
Color selectionHighlightColor = const Color.fromRGBO(128, 128, 128, .3),
List<String> lastMove = const [],
}) : board = Board(
}) : board = Board(
fen: fen,
size: size,
orientation: orientation,
Expand All @@ -43,7 +45,8 @@ class Chessboard extends StatefulWidget {
lastMove: lastMove,
lastMoveHighlightColor: lastMoveHighlightColor,
selectionHighlightColor: selectionHighlightColor,
);
),
hintSquare = hintSquare;

@override
State<StatefulWidget> createState() => _ChessboardState();
Expand Down Expand Up @@ -76,6 +79,9 @@ class _ChessboardState extends State<Chessboard> {
}

Color? _getHighlight(Square square) {
if (square.name == widget.hintSquare) {
return const Color.fromARGB(100, 80, 124, 101);
}
return clickMove
.filter((t) => t.square == square.name)
.map((_) => widget.board.selectionHighlightColor)
Expand Down