From a82eca5bef182ffb71928bf435310c7ee007aa14 Mon Sep 17 00:00:00 2001 From: Vincent Velociter Date: Fri, 6 Oct 2023 16:47:59 +0200 Subject: [PATCH] Fix TV route observer --- lib/src/app.dart | 2 -- lib/src/view/watch/live_tv_channels_screen.dart | 1 - lib/src/view/watch/tv_screen.dart | 7 ++----- lib/src/view/watch/watch_tab_screen.dart | 1 - lib/src/widgets/board_table.dart | 11 +++++++++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/src/app.dart b/lib/src/app.dart index 07cbab6cf2..516e27b54b 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -15,7 +15,6 @@ import 'package:lichess_mobile/src/model/settings/board_preferences.dart'; import 'package:lichess_mobile/src/utils/immersive_mode.dart'; import 'package:lichess_mobile/src/utils/wakelock.dart'; import 'package:lichess_mobile/src/utils/layout.dart'; -import 'package:lichess_mobile/src/view/watch/tv_screen.dart'; class App extends ConsumerStatefulWidget { const App({super.key}); @@ -91,7 +90,6 @@ class _AppState extends ConsumerState { navigatorObservers: [ immersiveModeRouteObserver, wakelockRouteObserver, - tvRouteObserver, ], ); } diff --git a/lib/src/view/watch/live_tv_channels_screen.dart b/lib/src/view/watch/live_tv_channels_screen.dart index 1f0d0b5d54..f5f8afe8fe 100644 --- a/lib/src/view/watch/live_tv_channels_screen.dart +++ b/lib/src/view/watch/live_tv_channels_screen.dart @@ -127,7 +127,6 @@ class _Body extends ConsumerWidget { channel: game.channel, initialGame: (game.id, game.orientation), ), - rootNavigator: true, ); }, orientation: game.orientation.cg, diff --git a/lib/src/view/watch/tv_screen.dart b/lib/src/view/watch/tv_screen.dart index 685dcfa223..6589a56c4e 100644 --- a/lib/src/view/watch/tv_screen.dart +++ b/lib/src/view/watch/tv_screen.dart @@ -17,9 +17,6 @@ import 'package:lichess_mobile/src/model/tv/tv_controller.dart'; import 'package:lichess_mobile/src/view/game/game_player.dart'; import 'package:lichess_mobile/src/view/settings/toggle_sound_button.dart'; -final RouteObserver> tvRouteObserver = - RouteObserver>(); - class TvScreen extends ConsumerStatefulWidget { const TvScreen({required this.channel, this.initialGame, super.key}); @@ -90,14 +87,14 @@ class _TvScreenState extends ConsumerState super.didChangeDependencies(); final route = ModalRoute.of(context); if (route != null && route is PageRoute) { - tvRouteObserver.subscribe(this, route); + watchTabRouteObserver.subscribe(this, route); } } @override void dispose() { WidgetsBinding.instance.removeObserver(this); - tvRouteObserver.unsubscribe(this); + watchTabRouteObserver.unsubscribe(this); super.dispose(); } diff --git a/lib/src/view/watch/watch_tab_screen.dart b/lib/src/view/watch/watch_tab_screen.dart index 19914c23d4..5b286823b3 100644 --- a/lib/src/view/watch/watch_tab_screen.dart +++ b/lib/src/view/watch/watch_tab_screen.dart @@ -209,7 +209,6 @@ class _WatchTvWidget extends ConsumerWidget { onTap: () => pushPlatformRoute( context, builder: (context) => TvScreen(channel: snapshot.channel), - rootNavigator: true, ).then((_) => _refreshData(ref)), ); }).toList(growable: false), diff --git a/lib/src/widgets/board_table.dart b/lib/src/widgets/board_table.dart index 1c21c48596..a9daba9fbc 100644 --- a/lib/src/widgets/board_table.dart +++ b/lib/src/widgets/board_table.dart @@ -94,6 +94,11 @@ class BoardTable extends ConsumerWidget { ? defaultBoardSize - kTabletBoardTableSidePadding * 2 : defaultBoardSize; + // vertical space left on portrait mode to check if we can display the + // move list + final verticalSpaceLeftBoardOnPortrait = + constraints.biggest.height - boardSize; + final error = errorMessage != null ? SizedBox.square( dimension: boardSize, @@ -238,14 +243,16 @@ class BoardTable extends ConsumerWidget { mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ - if (slicedMoves != null) + if (slicedMoves != null && + verticalSpaceLeftBoardOnPortrait >= 130) MoveList( type: MoveListType.inline, slicedMoves: slicedMoves, currentMoveIndex: currentMoveIndex ?? 0, onSelectMove: onSelectMove, ) - else if (showMoveListPlaceholder) + else if (showMoveListPlaceholder && + verticalSpaceLeftBoardOnPortrait >= 130) const SizedBox(height: 40), Expanded( child: Padding(