Skip to content

Commit

Permalink
fix: empty space in "Watch" tab in landscape orientation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tom-anders committed Aug 4, 2024
1 parent 80be3e0 commit 0f13e90
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions lib/src/view/watch/watch_tab_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ class _WatchScreenState extends ConsumerState<WatchTabScreen> {
);
}

List<Widget> get watchTabWidgets => const [
// TODO: show widget when broadcasts feature is ready
//_BroadcastWidget(),
_WatchTvWidget(),
_StreamerWidget(),
];

Widget _buildAndroid(BuildContext context, WidgetRef ref) {
return PopScope(
canPop: false,
Expand All @@ -108,11 +115,7 @@ class _WatchScreenState extends ConsumerState<WatchTabScreen> {
return orientation == Orientation.portrait
? ListView(
controller: watchScrollController,
children: const [
_BroadcastWidget(),
_WatchTvWidget(),
_StreamerWidget(),
],
children: watchTabWidgets,
)
: GridView(
controller: watchScrollController,
Expand All @@ -121,11 +124,7 @@ class _WatchScreenState extends ConsumerState<WatchTabScreen> {
crossAxisCount: 2,
childAspectRatio: 0.92,
),
children: const [
_BroadcastWidget(),
_WatchTvWidget(),
_StreamerWidget(),
],
children: watchTabWidgets,
);
},
),
Expand Down Expand Up @@ -156,11 +155,7 @@ class _WatchScreenState extends ConsumerState<WatchTabScreen> {
sliver: orientation == Orientation.portrait
? SliverList(
delegate: SliverChildListDelegate(
const [
_BroadcastWidget(),
_WatchTvWidget(),
_StreamerWidget(),
],
watchTabWidgets,
),
)
: SliverGrid(
Expand All @@ -169,13 +164,7 @@ class _WatchScreenState extends ConsumerState<WatchTabScreen> {
crossAxisCount: 2,
childAspectRatio: 0.92,
),
delegate: SliverChildListDelegate(
const [
_BroadcastWidget(),
_WatchTvWidget(),
_StreamerWidget(),
],
),
delegate: SliverChildListDelegate(watchTabWidgets),
),
),
],
Expand All @@ -197,17 +186,15 @@ Future<void> _refreshData(WidgetRef ref) {
]);
}

// TODO remove this ignore comment when broadcasts feature is ready
// ignore: unused_element
class _BroadcastWidget extends ConsumerWidget {
const _BroadcastWidget();

static const int numberOfItems = 5;

@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(
Expand Down

0 comments on commit 0f13e90

Please sign in to comment.