mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-17 06:49:34 +00:00
替换miniPlayer
This commit is contained in:
parent
eb9b8f3b94
commit
e67d045da6
34 changed files with 1777 additions and 1078 deletions
|
|
@ -1,155 +1,155 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:vaani/constants/sizes.dart';
|
||||
import 'package:vaani/features/player/providers/audiobook_player.dart';
|
||||
import 'package:vaani/features/player/providers/currently_playing_provider.dart';
|
||||
import 'package:vaani/features/player/view/audiobook_player.dart';
|
||||
import 'package:vaani/router/router.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
// import 'package:go_router/go_router.dart';
|
||||
// import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
// import 'package:vaani/constants/sizes.dart';
|
||||
// import 'package:vaani/features/player/providers/audiobook_player.dart';
|
||||
// import 'package:vaani/features/player/providers/currently_playing_provider.dart';
|
||||
// import 'package:vaani/features/player/view/audiobook_player.dart';
|
||||
// import 'package:vaani/router/router.dart';
|
||||
|
||||
class PlayerWhenMinimized extends HookConsumerWidget {
|
||||
const PlayerWhenMinimized({
|
||||
super.key,
|
||||
required this.availWidth,
|
||||
required this.maxImgSize,
|
||||
required this.imgWidget,
|
||||
required this.playPauseController,
|
||||
required this.percentageMiniplayer,
|
||||
});
|
||||
// class PlayerWhenMinimized extends HookConsumerWidget {
|
||||
// const PlayerWhenMinimized({
|
||||
// super.key,
|
||||
// required this.availWidth,
|
||||
// required this.maxImgSize,
|
||||
// required this.imgWidget,
|
||||
// required this.playPauseController,
|
||||
// required this.percentageMiniplayer,
|
||||
// });
|
||||
|
||||
final double availWidth;
|
||||
final double maxImgSize;
|
||||
final Widget imgWidget;
|
||||
final AnimationController playPauseController;
|
||||
// final double availWidth;
|
||||
// final double maxImgSize;
|
||||
// final Widget imgWidget;
|
||||
// final AnimationController playPauseController;
|
||||
|
||||
/// 0 - 1, from minimized to when switched to expanded player
|
||||
///
|
||||
/// by the time 1 is reached only image should be visible in the center of the widget
|
||||
final double percentageMiniplayer;
|
||||
// /// 0 - 1, from minimized to when switched to expanded player
|
||||
// ///
|
||||
// /// by the time 1 is reached only image should be visible in the center of the widget
|
||||
// final double percentageMiniplayer;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final player = ref.watch(audiobookPlayerProvider);
|
||||
final currentChapter = ref.watch(currentPlayingChapterProvider);
|
||||
// @override
|
||||
// Widget build(BuildContext context, WidgetRef ref) {
|
||||
// final player = ref.watch(audiobookPlayerProvider);
|
||||
// final currentChapter = ref.watch(currentPlayingChapterProvider);
|
||||
|
||||
final vanishingPercentage = 1 - percentageMiniplayer;
|
||||
// final progress =
|
||||
// useStream(player.slowPositionStreamInBook, initialData: Duration.zero);
|
||||
final progress =
|
||||
useStream(player.positionStream, initialData: Duration.zero);
|
||||
// final vanishingPercentage = 1 - percentageMiniplayer;
|
||||
// // final progress =
|
||||
// // useStream(player.slowPositionStreamInBook, initialData: Duration.zero);
|
||||
// final progress =
|
||||
// useStream(player.positionStream, initialData: Duration.zero);
|
||||
|
||||
final bookMetaExpanded = ref.watch(currentBookMetadataProvider);
|
||||
// final bookMetaExpanded = ref.watch(currentBookMetadataProvider);
|
||||
|
||||
var barHeight = vanishingPercentage * 3;
|
||||
// var barHeight = vanishingPercentage * 3;
|
||||
|
||||
return Stack(
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
// image
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: ((availWidth - maxImgSize) / 2) * percentageMiniplayer,
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// navigate to item page
|
||||
context.pushNamed(
|
||||
Routes.libraryItem.name,
|
||||
pathParameters: {
|
||||
Routes.libraryItem.pathParamName!:
|
||||
player.book!.libraryItemId,
|
||||
},
|
||||
);
|
||||
},
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: maxImgSize,
|
||||
),
|
||||
child: imgWidget,
|
||||
),
|
||||
),
|
||||
),
|
||||
// author and title of the book
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// AutoScrollText(
|
||||
Text(
|
||||
'${bookMetaExpanded?.title ?? ''} - ${currentChapter?.title ?? ''}',
|
||||
maxLines: 1, overflow: TextOverflow.ellipsis,
|
||||
// velocity:
|
||||
// const Velocity(pixelsPerSecond: Offset(16, 0)),
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
Text(
|
||||
bookMetaExpanded?.authorName ?? '',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withValues(alpha: 0.7),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.fullscreen),
|
||||
// onPressed: () {
|
||||
// controller.animateToHeight(state: PanelState.MAX);
|
||||
// },
|
||||
// ),
|
||||
// return Stack(
|
||||
// alignment: Alignment.topCenter,
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// // image
|
||||
// Padding(
|
||||
// padding: EdgeInsets.only(
|
||||
// left: ((availWidth - maxImgSize) / 2) * percentageMiniplayer,
|
||||
// ),
|
||||
// child: InkWell(
|
||||
// onTap: () {
|
||||
// // navigate to item page
|
||||
// context.pushNamed(
|
||||
// Routes.libraryItem.name,
|
||||
// pathParameters: {
|
||||
// Routes.libraryItem.pathParamName!:
|
||||
// player.book!.libraryItemId,
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// child: ConstrainedBox(
|
||||
// constraints: BoxConstraints(
|
||||
// maxWidth: maxImgSize,
|
||||
// ),
|
||||
// child: imgWidget,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// // author and title of the book
|
||||
// Expanded(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(left: 8),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// // AutoScrollText(
|
||||
// Text(
|
||||
// '${bookMetaExpanded?.title ?? ''} - ${currentChapter?.title ?? ''}',
|
||||
// maxLines: 1, overflow: TextOverflow.ellipsis,
|
||||
// // velocity:
|
||||
// // const Velocity(pixelsPerSecond: Offset(16, 0)),
|
||||
// style: Theme.of(context).textTheme.bodyLarge,
|
||||
// ),
|
||||
// Text(
|
||||
// bookMetaExpanded?.authorName ?? '',
|
||||
// maxLines: 1,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
// color: Theme.of(context)
|
||||
// .colorScheme
|
||||
// .onSurface
|
||||
// .withValues(alpha: 0.7),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// // IconButton(
|
||||
// // icon: const Icon(Icons.fullscreen),
|
||||
// // onPressed: () {
|
||||
// // controller.animateToHeight(state: PanelState.MAX);
|
||||
// // },
|
||||
// // ),
|
||||
|
||||
// rewind button
|
||||
Opacity(
|
||||
opacity: vanishingPercentage,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.replay_30,
|
||||
size: AppElementSizes.iconSizeSmall,
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
// // rewind button
|
||||
// Opacity(
|
||||
// opacity: vanishingPercentage,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(left: 8),
|
||||
// child: IconButton(
|
||||
// icon: const Icon(
|
||||
// Icons.replay_30,
|
||||
// size: AppElementSizes.iconSizeSmall,
|
||||
// ),
|
||||
// onPressed: () {},
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// play/pause button
|
||||
Opacity(
|
||||
opacity: vanishingPercentage,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: AudiobookPlayerPlayPauseButton(
|
||||
playPauseController: playPauseController,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: barHeight,
|
||||
child: LinearProgressIndicator(
|
||||
// value: (progress.data ?? Duration.zero).inSeconds /
|
||||
// player.book!.duration.inSeconds,
|
||||
value: (progress.data ?? Duration.zero).inSeconds /
|
||||
(player.duration?.inSeconds ?? 1),
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
// // play/pause button
|
||||
// Opacity(
|
||||
// opacity: vanishingPercentage,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(right: 8),
|
||||
// child: AudiobookPlayerPlayPauseButton(
|
||||
// playPauseController: playPauseController,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: barHeight,
|
||||
// child: LinearProgressIndicator(
|
||||
// // value: (progress.data ?? Duration.zero).inSeconds /
|
||||
// // player.book!.duration.inSeconds,
|
||||
// value: (progress.data ?? Duration.zero).inSeconds /
|
||||
// (player.duration?.inSeconds ?? 1),
|
||||
// color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
// backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue