mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
替换miniPlayer
This commit is contained in:
parent
eb9b8f3b94
commit
e67d045da6
34 changed files with 1777 additions and 1078 deletions
|
|
@ -1,292 +1,293 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:miniplayer/miniplayer.dart';
|
||||
import 'package:vaani/constants/sizes.dart';
|
||||
import 'package:vaani/features/player/providers/currently_playing_provider.dart';
|
||||
import 'package:vaani/features/player/providers/player_form.dart';
|
||||
import 'package:vaani/features/player/view/audiobook_player.dart';
|
||||
import 'package:vaani/features/skip_start_end/player_skip_chapter_start_end.dart';
|
||||
import 'package:vaani/features/sleep_timer/view/sleep_timer_button.dart';
|
||||
import 'package:vaani/shared/extensions/inverse_lerp.dart';
|
||||
import 'package:vaani/shared/widgets/not_implemented.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
// import 'package:miniplayer/miniplayer.dart';
|
||||
// import 'package:vaani/constants/sizes.dart';
|
||||
// import 'package:vaani/features/player/providers/currently_playing_provider.dart';
|
||||
// import 'package:vaani/features/player/providers/player_form.dart';
|
||||
// import 'package:vaani/features/player/view/audiobook_player.dart';
|
||||
// import 'package:vaani/features/player/view/widgets/player_progress_bar.dart';
|
||||
// import 'package:vaani/features/skip_start_end/player_skip_chapter_start_end.dart';
|
||||
// import 'package:vaani/features/sleep_timer/view/sleep_timer_button.dart';
|
||||
// import 'package:vaani/shared/extensions/inverse_lerp.dart';
|
||||
// import 'package:vaani/shared/widgets/not_implemented.dart';
|
||||
|
||||
import 'widgets/audiobook_player_seek_button.dart';
|
||||
import 'widgets/audiobook_player_seek_chapter_button.dart';
|
||||
import 'widgets/chapter_selection_button.dart';
|
||||
import 'widgets/player_speed_adjust_button.dart';
|
||||
// import 'widgets/audiobook_player_seek_button.dart';
|
||||
// import 'widgets/audiobook_player_seek_chapter_button.dart';
|
||||
// import 'widgets/chapter_selection_button.dart';
|
||||
// import 'widgets/player_speed_adjust_button.dart';
|
||||
|
||||
var pendingPlayerModals = 0;
|
||||
// var pendingPlayerModals = 0;
|
||||
|
||||
class PlayerWhenExpanded extends HookConsumerWidget {
|
||||
const PlayerWhenExpanded({
|
||||
super.key,
|
||||
required this.imageSize,
|
||||
required this.img,
|
||||
required this.percentageExpandedPlayer,
|
||||
required this.playPauseController,
|
||||
});
|
||||
// class PlayerWhenExpanded extends HookConsumerWidget {
|
||||
// const PlayerWhenExpanded({
|
||||
// super.key,
|
||||
// required this.imageSize,
|
||||
// required this.img,
|
||||
// required this.percentageExpandedPlayer,
|
||||
// required this.playPauseController,
|
||||
// });
|
||||
|
||||
/// padding values control the position of the image
|
||||
final double imageSize;
|
||||
final Widget img;
|
||||
final double percentageExpandedPlayer;
|
||||
final AnimationController playPauseController;
|
||||
// /// padding values control the position of the image
|
||||
// final double imageSize;
|
||||
// final Widget img;
|
||||
// final double percentageExpandedPlayer;
|
||||
// final AnimationController playPauseController;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
/// all the properties that help in building the widget are calculated from the [percentageExpandedPlayer]
|
||||
/// however, some properties need to start later than 0% and end before 100%
|
||||
const lateStart = 0.4;
|
||||
const earlyEnd = 1;
|
||||
final earlyPercentage = percentageExpandedPlayer
|
||||
.inverseLerp(
|
||||
lateStart,
|
||||
earlyEnd,
|
||||
)
|
||||
.clamp(0.0, 1.0);
|
||||
final currentChapter = ref.watch(currentPlayingChapterProvider);
|
||||
final currentBookMetadata = ref.watch(currentBookMetadataProvider);
|
||||
// @override
|
||||
// Widget build(BuildContext context, WidgetRef ref) {
|
||||
// /// all the properties that help in building the widget are calculated from the [percentageExpandedPlayer]
|
||||
// /// however, some properties need to start later than 0% and end before 100%
|
||||
// const lateStart = 0.4;
|
||||
// const earlyEnd = 1;
|
||||
// final earlyPercentage = percentageExpandedPlayer
|
||||
// .inverseLerp(
|
||||
// lateStart,
|
||||
// earlyEnd,
|
||||
// )
|
||||
// .clamp(0.0, 1.0);
|
||||
// final currentChapter = ref.watch(currentPlayingChapterProvider);
|
||||
// final currentBookMetadata = ref.watch(currentBookMetadataProvider);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// sized box for system status bar; not needed as not full screen
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).padding.top * earlyPercentage,
|
||||
),
|
||||
// return Column(
|
||||
// children: [
|
||||
// // sized box for system status bar; not needed as not full screen
|
||||
// SizedBox(
|
||||
// height: MediaQuery.of(context).padding.top * earlyPercentage,
|
||||
// ),
|
||||
|
||||
// a row with a down arrow to minimize the player, a pill shaped container to drag the player, and a cast button
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: 100 * earlyPercentage,
|
||||
),
|
||||
child: Opacity(
|
||||
opacity: earlyPercentage,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 8.0 * earlyPercentage),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// the down arrow
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(Icons.keyboard_arrow_down),
|
||||
onPressed: () {
|
||||
// minimize the player
|
||||
audioBookMiniplayerController.animateToHeight(
|
||||
state: PanelState.MIN,
|
||||
);
|
||||
},
|
||||
),
|
||||
// // a row with a down arrow to minimize the player, a pill shaped container to drag the player, and a cast button
|
||||
// ConstrainedBox(
|
||||
// constraints: BoxConstraints(
|
||||
// maxHeight: 100 * earlyPercentage,
|
||||
// ),
|
||||
// child: Opacity(
|
||||
// opacity: earlyPercentage,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(top: 8.0 * earlyPercentage),
|
||||
// child: Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// // the down arrow
|
||||
// IconButton(
|
||||
// iconSize: 30,
|
||||
// icon: const Icon(Icons.keyboard_arrow_down),
|
||||
// onPressed: () {
|
||||
// // minimize the player
|
||||
// audioBookMiniplayerController.animateToHeight(
|
||||
// state: PanelState.MIN,
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
|
||||
// the cast button
|
||||
IconButton(
|
||||
icon: const Icon(Icons.cast),
|
||||
onPressed: () {
|
||||
showNotImplementedToast(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// // the cast button
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.cast),
|
||||
// onPressed: () {
|
||||
// showNotImplementedToast(context);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// the image
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: AppElementSizes.paddingLarge * earlyPercentage,
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
// add a shadow to the image elevation hovering effect
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary
|
||||
.withValues(alpha: 0.1),
|
||||
blurRadius: 32 * earlyPercentage,
|
||||
spreadRadius: 8 * earlyPercentage,
|
||||
// offset: Offset(0, 16 * earlyPercentage),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SizedBox(
|
||||
height: imageSize,
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppElementSizes.borderRadiusRegular * earlyPercentage,
|
||||
),
|
||||
child: img,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// // the image
|
||||
// Padding(
|
||||
// padding: EdgeInsets.only(
|
||||
// top: AppElementSizes.paddingLarge * earlyPercentage,
|
||||
// ),
|
||||
// child: Align(
|
||||
// alignment: Alignment.center,
|
||||
// // add a shadow to the image elevation hovering effect
|
||||
// child: Container(
|
||||
// decoration: BoxDecoration(
|
||||
// boxShadow: [
|
||||
// BoxShadow(
|
||||
// color: Theme.of(context)
|
||||
// .colorScheme
|
||||
// .primary
|
||||
// .withValues(alpha: 0.1),
|
||||
// blurRadius: 32 * earlyPercentage,
|
||||
// spreadRadius: 8 * earlyPercentage,
|
||||
// // offset: Offset(0, 16 * earlyPercentage),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// child: SizedBox(
|
||||
// height: imageSize,
|
||||
// child: InkWell(
|
||||
// onTap: () {},
|
||||
// child: ClipRRect(
|
||||
// borderRadius: BorderRadius.circular(
|
||||
// AppElementSizes.borderRadiusRegular * earlyPercentage,
|
||||
// ),
|
||||
// child: img,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// the chapter title
|
||||
Expanded(
|
||||
child: Opacity(
|
||||
opacity: earlyPercentage,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// horizontal: 16.0,
|
||||
),
|
||||
// child: SizedBox(
|
||||
// same as the image width
|
||||
// width: imageSize,
|
||||
child: currentChapter == null
|
||||
? const SizedBox()
|
||||
: Text(
|
||||
currentChapter.title,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
),
|
||||
// // the chapter title
|
||||
// Expanded(
|
||||
// child: Opacity(
|
||||
// opacity: earlyPercentage,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(
|
||||
// top: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// // horizontal: 16.0,
|
||||
// ),
|
||||
// // child: SizedBox(
|
||||
// // same as the image width
|
||||
// // width: imageSize,
|
||||
// child: currentChapter == null
|
||||
// ? const SizedBox()
|
||||
// : Text(
|
||||
// currentChapter.title,
|
||||
// style: Theme.of(context).textTheme.titleLarge,
|
||||
// maxLines: 1,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// ),
|
||||
// // ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// the book name and author
|
||||
Expanded(
|
||||
child: Opacity(
|
||||
opacity: earlyPercentage,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// horizontal: 16.0,
|
||||
),
|
||||
// child: SizedBox(
|
||||
// same as the image width
|
||||
// width: imageSize,
|
||||
child: Text(
|
||||
[
|
||||
currentBookMetadata?.title ?? '',
|
||||
currentBookMetadata?.authorName ?? '',
|
||||
].join(' - '),
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withValues(alpha: 0.7),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
),
|
||||
// // the book name and author
|
||||
// Expanded(
|
||||
// child: Opacity(
|
||||
// opacity: earlyPercentage,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(
|
||||
// bottom: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// // horizontal: 16.0,
|
||||
// ),
|
||||
// // child: SizedBox(
|
||||
// // same as the image width
|
||||
// // width: imageSize,
|
||||
// child: Text(
|
||||
// [
|
||||
// currentBookMetadata?.title ?? '',
|
||||
// currentBookMetadata?.authorName ?? '',
|
||||
// ].join(' - '),
|
||||
// style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
// color: Theme.of(context)
|
||||
// .colorScheme
|
||||
// .onSurface
|
||||
// .withValues(alpha: 0.7),
|
||||
// ),
|
||||
// maxLines: 1,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// ),
|
||||
// // ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// the progress bar
|
||||
Expanded(
|
||||
child: Opacity(
|
||||
opacity: earlyPercentage,
|
||||
child: SizedBox(
|
||||
width: imageSize,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
// top: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
left: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
right: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
),
|
||||
child: const AudiobookChapterProgressBar(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// // the progress bar
|
||||
// Expanded(
|
||||
// child: Opacity(
|
||||
// opacity: earlyPercentage,
|
||||
// child: SizedBox(
|
||||
// width: imageSize,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(
|
||||
// // top: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// left: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// right: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// ),
|
||||
// child: const AudiobookChapterProgressBar(),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
Expanded(
|
||||
child: Opacity(
|
||||
opacity: earlyPercentage,
|
||||
child: SizedBox(
|
||||
width: imageSize,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
// top: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
left: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
right: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
),
|
||||
child: const AudiobookProgressBar(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Expanded(
|
||||
// child: Opacity(
|
||||
// opacity: earlyPercentage,
|
||||
// child: SizedBox(
|
||||
// width: imageSize,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(
|
||||
// // top: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// left: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// right: AppElementSizes.paddingRegular * earlyPercentage,
|
||||
// ),
|
||||
// child: const AudiobookProgressBar(),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// the chapter skip buttons, seek 30 seconds back and forward, and play/pause button
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Opacity(
|
||||
opacity: earlyPercentage,
|
||||
child: SizedBox(
|
||||
width: imageSize,
|
||||
height: AppElementSizes.iconSizeRegular,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// previous chapter
|
||||
const AudiobookPlayerSeekChapterButton(isForward: false),
|
||||
// buttonSkipBackwards
|
||||
const AudiobookPlayerSeekButton(isForward: false),
|
||||
AudiobookPlayerPlayPauseButton(
|
||||
playPauseController: playPauseController,
|
||||
),
|
||||
// buttonSkipForwards
|
||||
const AudiobookPlayerSeekButton(isForward: true),
|
||||
// next chapter
|
||||
const AudiobookPlayerSeekChapterButton(isForward: true),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// // the chapter skip buttons, seek 30 seconds back and forward, and play/pause button
|
||||
// Expanded(
|
||||
// flex: 2,
|
||||
// child: Opacity(
|
||||
// opacity: earlyPercentage,
|
||||
// child: SizedBox(
|
||||
// width: imageSize,
|
||||
// height: AppElementSizes.iconSizeRegular,
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// // previous chapter
|
||||
// const AudiobookPlayerSeekChapterButton(isForward: false),
|
||||
// // buttonSkipBackwards
|
||||
// const AudiobookPlayerSeekButton(isForward: false),
|
||||
// AudiobookPlayerPlayPauseButton(
|
||||
// playPauseController: playPauseController,
|
||||
// ),
|
||||
// // buttonSkipForwards
|
||||
// const AudiobookPlayerSeekButton(isForward: true),
|
||||
// // next chapter
|
||||
// const AudiobookPlayerSeekChapterButton(isForward: true),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// speed control, sleep timer, chapter list, and settings
|
||||
Expanded(
|
||||
child: Opacity(
|
||||
opacity: earlyPercentage,
|
||||
child: SizedBox(
|
||||
// padding: EdgeInsets.only(
|
||||
// bottom: AppElementSizes.paddingRegular * 4 * earlyPercentage,
|
||||
// ),
|
||||
width: imageSize,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
// speed control
|
||||
const PlayerSpeedAdjustButton(),
|
||||
const Spacer(),
|
||||
// sleep timer
|
||||
const SleepTimerButton(),
|
||||
const Spacer(),
|
||||
// chapter list
|
||||
const ChapterSelectionButton(),
|
||||
const Spacer(),
|
||||
// 跳过片头片尾
|
||||
SkipChapterStartEndButton(),
|
||||
// settings
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.more_horiz),
|
||||
// onPressed: () {
|
||||
// // show toast
|
||||
// showNotImplementedToast(context);
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
// // speed control, sleep timer, chapter list, and settings
|
||||
// Expanded(
|
||||
// child: Opacity(
|
||||
// opacity: earlyPercentage,
|
||||
// child: SizedBox(
|
||||
// // padding: EdgeInsets.only(
|
||||
// // bottom: AppElementSizes.paddingRegular * 4 * earlyPercentage,
|
||||
// // ),
|
||||
// width: imageSize,
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
// children: [
|
||||
// // speed control
|
||||
// const PlayerSpeedAdjustButton(),
|
||||
// const Spacer(),
|
||||
// // sleep timer
|
||||
// const SleepTimerButton(),
|
||||
// const Spacer(),
|
||||
// // chapter list
|
||||
// const ChapterSelectionButton(),
|
||||
// const Spacer(),
|
||||
// // 跳过片头片尾
|
||||
// SkipChapterStartEndButton(),
|
||||
// // settings
|
||||
// // IconButton(
|
||||
// // icon: const Icon(Icons.more_horiz),
|
||||
// // onPressed: () {
|
||||
// // // show toast
|
||||
// // showNotImplementedToast(context);
|
||||
// // },
|
||||
// // ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue