Skip to content

Commit

Permalink
Update chessground
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Jan 12, 2025
1 parent d7fe4e5 commit bbe6faa
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 61 deletions.
16 changes: 7 additions & 9 deletions lib/src/widgets/board_carousel_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,18 @@ class BoardCarouselItem extends ConsumerWidget {
},
child: SizedBox(
height: boardSize,
child: Chessboard.fixed(
child: StaticChessboard(
size: boardSize,
fen: fen,
orientation: orientation,
lastMove: lastMove,
settings: ChessboardSettings(
enableCoordinates: false,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10.0),
topRight: Radius.circular(10.0),
),
pieceAssets: boardPrefs.pieceSet.assets,
colorScheme: boardPrefs.boardTheme.colors,
enableCoordinates: false,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10.0),
topRight: Radius.circular(10.0),
),
pieceAssets: boardPrefs.pieceSet.assets,
colorScheme: boardPrefs.boardTheme.colors,
),
),
),
Expand Down
20 changes: 9 additions & 11 deletions lib/src/widgets/board_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,19 @@ class _SmallBoardPreviewState extends ConsumerState<SmallBoardPreview> {
),
)
else
Chessboard.fixed(
StaticChessboard(
size: boardSize,
fen: widget.fen,
orientation: widget.orientation,
lastMove: widget.lastMove as NormalMove?,
settings: ChessboardSettings(
pieceAssets: boardPrefs.pieceSet.assets,
colorScheme: boardPrefs.boardTheme.colors,
brightness: boardPrefs.brightness,
hue: boardPrefs.hue,
enableCoordinates: false,
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
boxShadow: boardShadows,
animationDuration: const Duration(milliseconds: 150),
),
pieceAssets: boardPrefs.pieceSet.assets,
colorScheme: boardPrefs.boardTheme.colors,
brightness: boardPrefs.brightness,
hue: boardPrefs.hue,
enableCoordinates: false,
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
boxShadow: boardShadows,
animationDuration: const Duration(milliseconds: 150),
),
const SizedBox(width: 10.0),
if (widget._showLoadingPlaceholder)
Expand Down
55 changes: 19 additions & 36 deletions lib/src/widgets/board_thumbnail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class BoardThumbnail extends ConsumerStatefulWidget {
this.footer,
this.lastMove,
this.onTap,
this.animationDuration,
this.animationDuration = const Duration(milliseconds: 200),
});

const BoardThumbnail.loading({required this.size, this.header, this.footer})
: orientation = Side.white,
fen = kInitialFEN,
lastMove = null,
onTap = null,
animationDuration = null;
animationDuration = const Duration(milliseconds: 200),
onTap = null;

/// Size of the board.
final double size;
Expand All @@ -45,8 +45,8 @@ class BoardThumbnail extends ConsumerStatefulWidget {

final GestureTapCallback? onTap;

/// Optionally animate changes to the board by the specified duration.
final Duration? animationDuration;
/// Animate changes to the board by the specified duration.
final Duration animationDuration;

@override
_BoardThumbnailState createState() => _BoardThumbnailState();
Expand All @@ -69,37 +69,20 @@ class _BoardThumbnailState extends ConsumerState<BoardThumbnail> {
Widget build(BuildContext context) {
final boardPrefs = ref.watch(boardPreferencesProvider);

final board =
widget.animationDuration != null
? Chessboard.fixed(
size: widget.size,
fen: widget.fen,
orientation: widget.orientation,
lastMove: widget.lastMove as NormalMove?,
settings: ChessboardSettings(
enableCoordinates: false,
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
boxShadow: boardShadows,
animationDuration: widget.animationDuration!,
pieceAssets: boardPrefs.pieceSet.assets,
colorScheme: boardPrefs.boardTheme.colors,
hue: boardPrefs.hue,
brightness: boardPrefs.brightness,
),
)
: StaticChessboard(
size: widget.size,
fen: widget.fen,
orientation: widget.orientation,
lastMove: widget.lastMove as NormalMove?,
enableCoordinates: false,
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
boxShadow: boardShadows,
pieceAssets: boardPrefs.pieceSet.assets,
colorScheme: boardPrefs.boardTheme.colors,
hue: boardPrefs.hue,
brightness: boardPrefs.brightness,
);
final board = StaticChessboard(
size: widget.size,
fen: widget.fen,
orientation: widget.orientation,
lastMove: widget.lastMove as NormalMove?,
enableCoordinates: false,
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
boxShadow: boardShadows,
pieceAssets: boardPrefs.pieceSet.assets,
colorScheme: boardPrefs.boardTheme.colors,
animationDuration: widget.animationDuration,
hue: boardPrefs.hue,
brightness: boardPrefs.brightness,
);

final maybeTappableBoard =
widget.onTap != null
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ packages:
dependency: "direct main"
description:
name: chessground
sha256: "5cf1a5bcd95c2c043ebfb1c88775b3d05b3332908ae4bbd528f32a8003129850"
sha256: "40330af2661f8fb58877b8e6e97130f494a628b114840668994ee5d426880ee4"
url: "https://pub.dev"
source: hosted
version: "6.2.3"
version: "6.3.0"
ci:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
async: ^2.10.0
auto_size_text: ^3.0.0
cached_network_image: ^3.2.2
chessground: ^6.2.3
chessground: ^6.3.0
clock: ^1.1.1
collection: ^1.17.0
connectivity_plus: ^6.0.2
Expand Down
4 changes: 2 additions & 2 deletions test/view/puzzle/puzzle_tab_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ void main() {
find
.descendant(
of: find.byType(PuzzleAnglePreview),
matching: find.byType(Chessboard),
matching: find.byType(StaticChessboard),
)
.evaluate()
.first
.widget
as Chessboard;
as StaticChessboard;

expect(chessboard.fen, equals('4k2r/Q5pp/3bp3/4n3/1r5q/8/PP2B1PP/R1B2R1K b k - 0 21'));
});
Expand Down

0 comments on commit bbe6faa

Please sign in to comment.