From 0f13e90ee432cf24ba8b8027de5cd3ac0072e213 Mon Sep 17 00:00:00 2001 From: tom-anders <13141438+tom-anders@users.noreply.github.com> Date: Sun, 4 Aug 2024 22:16:28 +0200 Subject: [PATCH] fix: empty space in "Watch" tab in landscape orientation The previous code would hide the _BroadcastWidget widget by returning SizedBox.shrink(), but that would still create an empty grid space in landscape mode. To fix this, factor out the widget list into a getter (to avoid code duplication) and comment out the BroadcastWidget in that list for now. Fixes #829 --- lib/src/view/watch/watch_tab_screen.dart | 39 ++++++++---------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/lib/src/view/watch/watch_tab_screen.dart b/lib/src/view/watch/watch_tab_screen.dart index 025bf3fb63..92c839b361 100644 --- a/lib/src/view/watch/watch_tab_screen.dart +++ b/lib/src/view/watch/watch_tab_screen.dart @@ -87,6 +87,13 @@ class _WatchScreenState extends ConsumerState { ); } + List get watchTabWidgets => const [ + // TODO: show widget when broadcasts feature is ready + //_BroadcastWidget(), + _WatchTvWidget(), + _StreamerWidget(), + ]; + Widget _buildAndroid(BuildContext context, WidgetRef ref) { return PopScope( canPop: false, @@ -108,11 +115,7 @@ class _WatchScreenState extends ConsumerState { return orientation == Orientation.portrait ? ListView( controller: watchScrollController, - children: const [ - _BroadcastWidget(), - _WatchTvWidget(), - _StreamerWidget(), - ], + children: watchTabWidgets, ) : GridView( controller: watchScrollController, @@ -121,11 +124,7 @@ class _WatchScreenState extends ConsumerState { crossAxisCount: 2, childAspectRatio: 0.92, ), - children: const [ - _BroadcastWidget(), - _WatchTvWidget(), - _StreamerWidget(), - ], + children: watchTabWidgets, ); }, ), @@ -156,11 +155,7 @@ class _WatchScreenState extends ConsumerState { sliver: orientation == Orientation.portrait ? SliverList( delegate: SliverChildListDelegate( - const [ - _BroadcastWidget(), - _WatchTvWidget(), - _StreamerWidget(), - ], + watchTabWidgets, ), ) : SliverGrid( @@ -169,13 +164,7 @@ class _WatchScreenState extends ConsumerState { crossAxisCount: 2, childAspectRatio: 0.92, ), - delegate: SliverChildListDelegate( - const [ - _BroadcastWidget(), - _WatchTvWidget(), - _StreamerWidget(), - ], - ), + delegate: SliverChildListDelegate(watchTabWidgets), ), ), ], @@ -197,6 +186,8 @@ Future _refreshData(WidgetRef ref) { ]); } +// TODO remove this ignore comment when broadcasts feature is ready +// ignore: unused_element class _BroadcastWidget extends ConsumerWidget { const _BroadcastWidget(); @@ -204,10 +195,6 @@ class _BroadcastWidget extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - // TODO: show widget when broadcasts feature is ready - return const SizedBox.shrink(); - - // ignore: dead_code final broadcastList = ref.watch(broadcastsPaginatorProvider); return broadcastList.when(