Skip to content

Commit

Permalink
fix: content behind miniplayer not visible (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Blank authored Oct 6, 2024
1 parent e890308 commit 09eafb2
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/features/item_viewer/view/library_item_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:flutter_animate/flutter_animate.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:vaani/api/library_item_provider.dart';
import 'package:vaani/features/item_viewer/view/library_item_sliver_app_bar.dart';
import 'package:vaani/features/player/providers/player_form.dart';
import 'package:vaani/features/player/view/mini_player_bottom_padding.dart';
import 'package:vaani/router/models/library_item_extras.dart';
import 'package:vaani/shared/widgets/expandable_description.dart';

Expand Down Expand Up @@ -56,9 +56,7 @@ class LibraryItemPage extends HookConsumerWidget {
child: LibraryItemDescription(id: itemId),
),
// a padding at the bottom to make sure the last item is not hidden by mini player
const SliverToBoxAdapter(
child: SizedBox(height: playerMinHeight),
),
const SliverToBoxAdapter(child: MiniPlayerBottomPadding()),
],
),
),
Expand Down
18 changes: 18 additions & 0 deletions lib/features/player/providers/player_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/widgets.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:miniplayer/miniplayer.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:vaani/features/player/providers/audiobook_player.dart';

part 'player_form.g.dart';

Expand Down Expand Up @@ -60,3 +61,20 @@ double playerHeight(
}

final audioBookMiniplayerController = MiniplayerController();

@Riverpod(keepAlive: true)
bool isPlayerActive(
IsPlayerActiveRef ref,
) {
try {
final player = ref.watch(audiobookPlayerProvider);
if (player.book != null) {
return true;
} else {
final playerHeight = ref.watch(playerHeightProvider);
return playerHeight < playerMinHeight;
}
} catch (e) {
return false;
}
}
15 changes: 15 additions & 0 deletions lib/features/player/providers/player_form.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions lib/features/player/view/mini_player_bottom_padding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:vaani/features/player/providers/player_form.dart';

class MiniPlayerBottomPadding extends HookConsumerWidget {
const MiniPlayerBottomPadding({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return AnimatedSize(
duration: const Duration(milliseconds: 200),
child: ref.watch(isPlayerActiveProvider)
? const SizedBox(height: playerMinHeight + 8)
: const SizedBox.shrink(),
);
}
}
4 changes: 4 additions & 0 deletions lib/features/you/view/server_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:vaani/api/api_provider.dart';
import 'package:vaani/api/authenticated_user_provider.dart';
import 'package:vaani/api/server_provider.dart';
import 'package:vaani/features/player/view/mini_player_bottom_padding.dart';
import 'package:vaani/main.dart';
import 'package:vaani/models/error_response.dart';
import 'package:vaani/router/router.dart';
Expand Down Expand Up @@ -260,6 +261,9 @@ class ServerManagerPage extends HookConsumerWidget {
},
),
),

MiniPlayerBottomPadding(),

],
),
),
Expand Down
2 changes: 2 additions & 0 deletions lib/features/you/view/you_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:vaani/api/api_provider.dart';
import 'package:vaani/features/player/view/mini_player_bottom_padding.dart';
import 'package:vaani/router/router.dart';
import 'package:vaani/settings/constants.dart';
import 'package:vaani/shared/utils.dart';
Expand Down Expand Up @@ -136,6 +137,7 @@ class YouPage extends HookConsumerWidget {
),
),
),
SliverToBoxAdapter(child: MiniPlayerBottomPadding()),
],
),
);
Expand Down
2 changes: 2 additions & 0 deletions lib/settings/view/simple_settings_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_settings_ui/flutter_settings_ui.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:vaani/features/player/view/mini_player_bottom_padding.dart';

class SimpleSettingsPage extends HookConsumerWidget {
const SimpleSettingsPage({
Expand Down Expand Up @@ -48,6 +49,7 @@ class SimpleSettingsPage extends HookConsumerWidget {
),
// some padding at the bottom
const SliverPadding(padding: EdgeInsets.only(bottom: 20)),
SliverToBoxAdapter(child: MiniPlayerBottomPadding()),
],
),
);
Expand Down

0 comments on commit 09eafb2

Please sign in to comment.