From e59935658ac3d1a3d82c1a1f0730841b67fb65f2 Mon Sep 17 00:00:00 2001 From: Julien <120588494+julien4215@users.noreply.github.com> Date: Fri, 29 Nov 2024 09:48:51 +0100 Subject: [PATCH] attempt to fix overflow in landscape orientation on broadcast game screen --- lib/src/view/analysis/analysis_layout.dart | 3 +++ lib/src/view/analysis/analysis_screen.dart | 3 ++- lib/src/view/broadcast/broadcast_game_screen.dart | 15 ++++++++++++--- lib/src/view/study/study_screen.dart | 6 ++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/src/view/analysis/analysis_layout.dart b/lib/src/view/analysis/analysis_layout.dart index b89ee0a878..5d920c3791 100644 --- a/lib/src/view/analysis/analysis_layout.dart +++ b/lib/src/view/analysis/analysis_layout.dart @@ -13,6 +13,7 @@ typedef BoardBuilder = Widget Function( BuildContext context, double boardSize, BorderRadius? boardRadius, + Orientation orientation, ); typedef EngineGaugeBuilder = Widget Function( @@ -177,6 +178,7 @@ class AnalysisLayout extends StatelessWidget { context, boardSize, isTablet ? tabletBoardRadius : null, + Orientation.landscape, ), if (engineGaugeBuilder != null) ...[ const SizedBox(width: 4.0), @@ -259,6 +261,7 @@ class AnalysisLayout extends StatelessWidget { context, boardSize, isTablet ? tabletBoardRadius : null, + Orientation.portrait, ), ), Expanded( diff --git a/lib/src/view/analysis/analysis_screen.dart b/lib/src/view/analysis/analysis_screen.dart index 201ac14a49..6a6e233f75 100644 --- a/lib/src/view/analysis/analysis_screen.dart +++ b/lib/src/view/analysis/analysis_screen.dart @@ -182,7 +182,8 @@ class _Body extends ConsumerWidget { return AnalysisLayout( tabController: controller, - boardBuilder: (context, boardSize, borderRadius) => AnalysisBoard( + boardBuilder: (context, boardSize, borderRadius, orientation) => + AnalysisBoard( options, boardSize, borderRadius: borderRadius, diff --git a/lib/src/view/broadcast/broadcast_game_screen.dart b/lib/src/view/broadcast/broadcast_game_screen.dart index f450060954..45694046cc 100644 --- a/lib/src/view/broadcast/broadcast_game_screen.dart +++ b/lib/src/view/broadcast/broadcast_game_screen.dart @@ -101,12 +101,13 @@ class _Body extends ConsumerWidget { return DefaultTabController( length: 1, child: AnalysisLayout( - boardBuilder: (context, boardSize, borderRadius) => + boardBuilder: (context, boardSize, borderRadius, orientation) => _BroadcastBoardWithHeaders( roundId, gameId, boardSize, borderRadius, + orientation, ), engineGaugeBuilder: isLocalEvaluationEnabled && showEvaluationGauge ? (context, orientation) { @@ -150,12 +151,14 @@ class _BroadcastBoardWithHeaders extends ConsumerWidget { final BroadcastGameId gameId; final double size; final BorderRadius? borderRadius; + final Orientation orientation; const _BroadcastBoardWithHeaders( this.roundId, this.gameId, this.size, this.borderRadius, + this.orientation, ); @override @@ -172,7 +175,8 @@ class _BroadcastBoardWithHeaders extends ConsumerWidget { bottomRight: Radius.zero, ), ), - _BroadcastBoard(roundId, gameId, size, borderRadius != null), + _BroadcastBoard( + roundId, gameId, size, borderRadius != null, orientation), _PlayerWidget( roundId: roundId, gameId: gameId, @@ -194,12 +198,14 @@ class _BroadcastBoard extends ConsumerStatefulWidget { this.gameId, this.boardSize, this.hasShadow, + this.orientation, ); final BroadcastRoundId roundId; final BroadcastGameId gameId; final double boardSize; final bool hasShadow; + final Orientation orientation; @override ConsumerState<_BroadcastBoard> createState() => _BroadcastBoardState(); @@ -238,7 +244,10 @@ class _BroadcastBoardState extends ConsumerState<_BroadcastBoard> { : ISet(); return Chessboard( - size: widget.boardSize, + size: switch (widget.orientation) { + Orientation.portrait => widget.boardSize, + Orientation.landscape => widget.boardSize - 2 * 30, + }, fen: broadcastAnalysisState.position.fen, lastMove: broadcastAnalysisState.lastMove as NormalMove?, orientation: broadcastAnalysisState.pov, diff --git a/lib/src/view/study/study_screen.dart b/lib/src/view/study/study_screen.dart index d86c1a48a7..248c1bfc0c 100644 --- a/lib/src/view/study/study_screen.dart +++ b/lib/src/view/study/study_screen.dart @@ -221,7 +221,8 @@ class _Body extends ConsumerWidget { return DefaultTabController( length: 1, child: AnalysisLayout( - boardBuilder: (context, boardSize, borderRadius) => SizedBox.square( + boardBuilder: (context, boardSize, borderRadius, orientation) => + SizedBox.square( dimension: boardSize, child: Center( child: Text( @@ -249,7 +250,8 @@ class _Body extends ConsumerWidget { return DefaultTabController( length: 1, child: AnalysisLayout( - boardBuilder: (context, boardSize, borderRadius) => _StudyBoard( + boardBuilder: (context, boardSize, borderRadius, orientation) => + _StudyBoard( id: id, boardSize: boardSize, borderRadius: borderRadius,