mirror of
https://github.com/lichess-org/mobile.git
synced 2026-05-26 13:50:52 +00:00
refactor: rename BoardTable to GameLayout
This commit is contained in:
@@ -20,9 +20,9 @@ import 'package:lichess_mobile/src/view/analysis/analysis_screen.dart';
|
||||
import 'package:lichess_mobile/src/view/game/correspondence_clock_widget.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_player.dart';
|
||||
import 'package:lichess_mobile/src/widgets/adaptive_action_sheet.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
|
||||
import 'package:lichess_mobile/src/widgets/buttons.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
|
||||
class OfflineCorrespondenceGameScreen extends StatefulWidget {
|
||||
const OfflineCorrespondenceGameScreen({required this.initialGame, super.key});
|
||||
@@ -186,7 +186,7 @@ class _BodyState extends ConsumerState<_Body> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
orientation: isBoardTurned ? youAre!.opposite : youAre!,
|
||||
lastMove: game.moveAt(stepCursor) as NormalMove?,
|
||||
interactiveBoardParams: (
|
||||
|
||||
@@ -21,10 +21,10 @@ import 'package:lichess_mobile/src/view/game/game_player.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_result_dialog.dart';
|
||||
import 'package:lichess_mobile/src/view/settings/toggle_sound_button.dart';
|
||||
import 'package:lichess_mobile/src/widgets/adaptive_action_sheet.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
|
||||
import 'package:lichess_mobile/src/widgets/buttons.dart';
|
||||
import 'package:lichess_mobile/src/widgets/clock.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
import 'package:lichess_mobile/src/widgets/platform.dart';
|
||||
import 'package:lichess_mobile/src/widgets/platform_context_menu_button.dart';
|
||||
|
||||
@@ -291,7 +291,7 @@ class _BoardBody extends ConsumerWidget {
|
||||
final gameData = archivedGameData;
|
||||
|
||||
if (gameData == null) {
|
||||
return BoardTable.empty(moves: const [], errorMessage: error?.toString());
|
||||
return GameLayout.empty(moves: const [], errorMessage: error?.toString());
|
||||
}
|
||||
|
||||
if (initialCursor != null) {
|
||||
@@ -304,7 +304,7 @@ class _BoardBody extends ConsumerWidget {
|
||||
|
||||
final isBoardTurned = ref.watch(isBoardTurnedProvider);
|
||||
final gameCursor = ref.watch(gameCursorProvider(gameData.id));
|
||||
final loadingBoard = BoardTable(
|
||||
final loadingBoard = GameLayout(
|
||||
orientation: (isBoardTurned ? orientation.opposite : orientation),
|
||||
fen: initialCursor == null ? gameData.lastFen ?? kEmptyBoardFEN : kEmptyBoardFEN,
|
||||
moves: const [],
|
||||
@@ -339,7 +339,7 @@ class _BoardBody extends ConsumerWidget {
|
||||
|
||||
final position = game.positionAt(cursor);
|
||||
|
||||
return BoardTable(
|
||||
return GameLayout(
|
||||
orientation: (isBoardTurned ? orientation.opposite : orientation),
|
||||
fen: position.fen,
|
||||
lastMove: game.moveAt(cursor) as NormalMove?,
|
||||
|
||||
@@ -27,10 +27,10 @@ import 'package:lichess_mobile/src/view/game/game_result_dialog.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_screen_providers.dart';
|
||||
import 'package:lichess_mobile/src/view/tournament/tournament_screen.dart';
|
||||
import 'package:lichess_mobile/src/widgets/adaptive_action_sheet.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
|
||||
import 'package:lichess_mobile/src/widgets/buttons.dart';
|
||||
import 'package:lichess_mobile/src/widgets/clock.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
import 'package:lichess_mobile/src/widgets/platform_alert_dialog.dart';
|
||||
import 'package:lichess_mobile/src/widgets/yes_no_dialog.dart';
|
||||
|
||||
@@ -229,7 +229,7 @@ class GameBody extends ConsumerWidget {
|
||||
child: PopScope(
|
||||
canPop: gameState.game.meta.speed == Speed.correspondence || !gameState.game.playable,
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
key: boardKey,
|
||||
boardSettingsOverrides: BoardSettingsOverrides(
|
||||
animationDuration: animationDuration,
|
||||
|
||||
@@ -7,9 +7,9 @@ import 'package:lichess_mobile/src/model/challenge/challenge.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/game_seek.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/lobby_numbers.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
|
||||
import 'package:lichess_mobile/src/widgets/feedback.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
import 'package:lichess_mobile/src/widgets/shimmer.dart';
|
||||
import 'package:lichess_mobile/src/widgets/user_full_name.dart';
|
||||
|
||||
@@ -32,7 +32,7 @@ class _LobbyScreenLoadingContentState extends State<LobbyScreenLoadingContent> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
orientation: Side.white,
|
||||
fen: kEmptyFen,
|
||||
topTable: const SizedBox.shrink(),
|
||||
@@ -140,7 +140,7 @@ class _ChallengeLoadingContentState extends State<ChallengeLoadingContent> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
orientation: Side.white,
|
||||
fen: kEmptyFen,
|
||||
topTable: const SizedBox.shrink(),
|
||||
@@ -235,7 +235,7 @@ class StandaloneGameLoadingBoard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Shimmer(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
orientation: orientation ?? Side.white,
|
||||
fen: fen ?? kEmptyFen,
|
||||
lastMove: lastMove as NormalMove?,
|
||||
@@ -304,7 +304,7 @@ class LoadGameError extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
orientation: Side.white,
|
||||
fen: kEmptyFen,
|
||||
topTable: const SizedBox.shrink(),
|
||||
@@ -344,7 +344,7 @@ class ChallengeDeclinedBoard extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
orientation: Side.white,
|
||||
fen: kEmptyFen,
|
||||
topTable: const SizedBox.shrink(),
|
||||
|
||||
@@ -20,10 +20,10 @@ import 'package:lichess_mobile/src/view/game/game_player.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_result_dialog.dart';
|
||||
import 'package:lichess_mobile/src/view/over_the_board/configure_over_the_board_game.dart';
|
||||
import 'package:lichess_mobile/src/widgets/adaptive_action_sheet.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
|
||||
import 'package:lichess_mobile/src/widgets/buttons.dart';
|
||||
import 'package:lichess_mobile/src/widgets/clock.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
import 'package:lichess_mobile/src/widgets/yes_no_dialog.dart';
|
||||
|
||||
class OverTheBoardScreen extends StatelessWidget {
|
||||
@@ -131,7 +131,7 @@ class _BodyState extends ConsumerState<_Body> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
key: _boardKey,
|
||||
topTable: _Player(
|
||||
side: orientation.opposite,
|
||||
|
||||
@@ -40,9 +40,9 @@ import 'package:lichess_mobile/src/view/settings/toggle_sound_button.dart';
|
||||
import 'package:lichess_mobile/src/widgets/adaptive_action_sheet.dart';
|
||||
import 'package:lichess_mobile/src/widgets/adaptive_bottom_sheet.dart';
|
||||
import 'package:lichess_mobile/src/widgets/adaptive_choice_picker.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
|
||||
import 'package:lichess_mobile/src/widgets/buttons.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
import 'package:lichess_mobile/src/widgets/list.dart';
|
||||
import 'package:lichess_mobile/src/widgets/pgn.dart';
|
||||
import 'package:lichess_mobile/src/widgets/settings.dart';
|
||||
@@ -140,7 +140,7 @@ class _LoadNextPuzzle extends ConsumerWidget {
|
||||
angle: angle,
|
||||
initialPuzzleContext: null,
|
||||
body: const Center(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
fen: kEmptyFen,
|
||||
orientation: Side.white,
|
||||
errorMessage: 'No more puzzles. Go online to get more.',
|
||||
@@ -167,7 +167,7 @@ class _LoadNextPuzzle extends ConsumerWidget {
|
||||
angle: angle,
|
||||
initialPuzzleContext: null,
|
||||
body: Center(
|
||||
child: BoardTable(fen: kEmptyFen, orientation: Side.white, errorMessage: e.toString()),
|
||||
child: GameLayout(fen: kEmptyFen, orientation: Side.white, errorMessage: e.toString()),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -206,7 +206,7 @@ class _LoadPuzzleFromId extends ConsumerWidget {
|
||||
body: const Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SafeArea(child: BoardTable.empty(showEngineGaugePlaceholder: true)),
|
||||
child: SafeArea(child: GameLayout.empty(showEngineGaugePlaceholder: true)),
|
||||
),
|
||||
BottomBar.empty(),
|
||||
],
|
||||
@@ -221,7 +221,7 @@ class _LoadPuzzleFromId extends ConsumerWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
fen: kEmptyFen,
|
||||
orientation: Side.white,
|
||||
errorMessage: e.toString(),
|
||||
@@ -281,7 +281,7 @@ class _Body extends ConsumerWidget {
|
||||
return SafeArea(
|
||||
child: OrientationBuilder(
|
||||
builder: (context, orientation) {
|
||||
return BoardTable(
|
||||
return GameLayout(
|
||||
orientation: puzzleState.pov,
|
||||
lastMove: puzzleState.lastMove as NormalMove?,
|
||||
interactiveBoardParams: (
|
||||
|
||||
@@ -22,10 +22,10 @@ import 'package:lichess_mobile/src/view/puzzle/puzzle_history_screen.dart';
|
||||
import 'package:lichess_mobile/src/view/puzzle/storm_clock.dart';
|
||||
import 'package:lichess_mobile/src/view/puzzle/storm_dashboard.dart';
|
||||
import 'package:lichess_mobile/src/view/settings/toggle_sound_button.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
|
||||
import 'package:lichess_mobile/src/widgets/buttons.dart';
|
||||
import 'package:lichess_mobile/src/widgets/feedback.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
import 'package:lichess_mobile/src/widgets/list.dart';
|
||||
import 'package:lichess_mobile/src/widgets/platform_alert_dialog.dart';
|
||||
import 'package:lichess_mobile/src/widgets/yes_no_dialog.dart';
|
||||
@@ -74,7 +74,7 @@ class _Load extends ConsumerWidget {
|
||||
error: (e, s) {
|
||||
debugPrint('SEVERE: [PuzzleStormScreen] could not load streak; $e\n$s');
|
||||
return Center(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
topTable: kEmptyWidget,
|
||||
bottomTable: kEmptyWidget,
|
||||
fen: kEmptyFen,
|
||||
@@ -142,7 +142,7 @@ class _Body extends ConsumerWidget {
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
boardKey: boardKey,
|
||||
orientation: stormState.pov,
|
||||
lastMove: stormState.lastMove as NormalMove?,
|
||||
|
||||
@@ -21,8 +21,8 @@ import 'package:lichess_mobile/src/utils/share.dart';
|
||||
import 'package:lichess_mobile/src/view/analysis/analysis_screen.dart';
|
||||
import 'package:lichess_mobile/src/view/puzzle/puzzle_feedback_widget.dart';
|
||||
import 'package:lichess_mobile/src/view/settings/toggle_sound_button.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
import 'package:lichess_mobile/src/widgets/platform_alert_dialog.dart';
|
||||
import 'package:lichess_mobile/src/widgets/yes_no_dialog.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
@@ -57,7 +57,7 @@ class _Load extends ConsumerWidget {
|
||||
case AsyncValue(:final error?, :final stackTrace):
|
||||
debugPrint('SEVERE: [StreakScreen] could not load streak; $error\n$stackTrace');
|
||||
return Center(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
topTable: kEmptyWidget,
|
||||
bottomTable: kEmptyWidget,
|
||||
fen: kEmptyFen,
|
||||
@@ -104,7 +104,7 @@ class _Body extends ConsumerWidget {
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: SafeArea(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
orientation: puzzleState.pov,
|
||||
lastMove: puzzleState.lastMove as NormalMove?,
|
||||
interactiveBoardParams: (
|
||||
|
||||
@@ -13,10 +13,10 @@ import 'package:lichess_mobile/src/utils/navigation.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_loading_board.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_player.dart';
|
||||
import 'package:lichess_mobile/src/view/settings/toggle_sound_button.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
|
||||
import 'package:lichess_mobile/src/widgets/buttons.dart';
|
||||
import 'package:lichess_mobile/src/widgets/clock.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
import 'package:lichess_mobile/src/widgets/shimmer.dart';
|
||||
import 'package:lichess_mobile/src/widgets/user_full_name.dart';
|
||||
|
||||
@@ -141,7 +141,7 @@ class _TvScreenState extends ConsumerState<TvScreen> {
|
||||
materialDiff: game.lastMaterialDiffAt(Side.white),
|
||||
);
|
||||
|
||||
return BoardTable(
|
||||
return GameLayout(
|
||||
orientation: gameState.orientation,
|
||||
fen: position.fen,
|
||||
boardSettingsOverrides: const BoardSettingsOverrides(
|
||||
@@ -203,7 +203,7 @@ class _TvScreenState extends ConsumerState<TvScreen> {
|
||||
},
|
||||
loading:
|
||||
() => const Shimmer(
|
||||
child: BoardTable(
|
||||
child: GameLayout(
|
||||
topTable: LoadingPlayerWidget(),
|
||||
bottomTable: LoadingPlayerWidget(),
|
||||
orientation: Side.white,
|
||||
@@ -213,7 +213,7 @@ class _TvScreenState extends ConsumerState<TvScreen> {
|
||||
),
|
||||
error: (err, stackTrace) {
|
||||
debugPrint('SEVERE: [TvScreen] could not load stream; $err\n$stackTrace');
|
||||
return const BoardTable(
|
||||
return const GameLayout(
|
||||
topTable: kEmptyWidget,
|
||||
bottomTable: kEmptyWidget,
|
||||
orientation: Side.white,
|
||||
|
||||
@@ -33,9 +33,9 @@ typedef InteractiveBoardParams =
|
||||
/// An optional move list can be displayed above the top table space.
|
||||
///
|
||||
/// An optional overlay or error message can be displayed on top of the board.
|
||||
class BoardTable extends ConsumerStatefulWidget {
|
||||
class GameLayout extends ConsumerStatefulWidget {
|
||||
/// Creates a board table with the given values.
|
||||
const BoardTable({
|
||||
const GameLayout({
|
||||
required this.orientation,
|
||||
this.fen,
|
||||
this.interactiveBoardParams,
|
||||
@@ -62,7 +62,7 @@ class BoardTable extends ConsumerStatefulWidget {
|
||||
);
|
||||
|
||||
/// Creates an empty board table (useful for loading).
|
||||
const BoardTable.empty({this.moves, this.showEngineGaugePlaceholder = false, this.errorMessage})
|
||||
const GameLayout.empty({this.moves, this.showEngineGaugePlaceholder = false, this.errorMessage})
|
||||
: orientation = Side.white,
|
||||
fen = kEmptyFen,
|
||||
interactiveBoardParams = null,
|
||||
@@ -137,10 +137,10 @@ class BoardTable extends ConsumerStatefulWidget {
|
||||
final Widget? userActionsBar;
|
||||
|
||||
@override
|
||||
ConsumerState<BoardTable> createState() => _BoardTableState();
|
||||
ConsumerState<GameLayout> createState() => _GameLayoutState();
|
||||
}
|
||||
|
||||
class _BoardTableState extends ConsumerState<BoardTable> {
|
||||
class _GameLayoutState extends ConsumerState<GameLayout> {
|
||||
ISet<Shape> userShapes = ISet();
|
||||
|
||||
@override
|
||||
@@ -5,7 +5,7 @@ import 'package:dartchess/dartchess.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/widgets/board_table.dart';
|
||||
import 'package:lichess_mobile/src/widgets/game_layout.dart';
|
||||
|
||||
import '../test_helpers.dart';
|
||||
import '../test_provider_scope.dart';
|
||||
@@ -19,7 +19,7 @@ void main() {
|
||||
key: ValueKey(surface),
|
||||
tester,
|
||||
child: const MaterialApp(
|
||||
home: BoardTable(
|
||||
home: GameLayout(
|
||||
orientation: Side.white,
|
||||
fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR',
|
||||
topTable: Row(
|
||||
@@ -66,7 +66,7 @@ void main() {
|
||||
key: ValueKey(surface),
|
||||
tester,
|
||||
child: const MaterialApp(
|
||||
home: BoardTable(
|
||||
home: GameLayout(
|
||||
orientation: Side.white,
|
||||
fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR',
|
||||
topTable: Row(
|
||||
Reference in New Issue
Block a user