注释未使用包

This commit is contained in:
rang 2025-12-09 17:26:04 +08:00
parent 50a27fdf67
commit 20a3b95edc
48 changed files with 637 additions and 1472 deletions

View file

@ -22,105 +22,32 @@ class PlayerMinimized extends HookConsumerWidget {
if (currentBook == null) {
return SizedBox.shrink();
}
final currentChapter = ref.watch(currentChapterProvider);
return PlayerMinimizedFramework(
children: [
// image
Padding(
padding: EdgeInsets.all(AppElementSizes.paddingSmall),
child: GestureDetector(
onTap: () {
// navigate to item page
context.pushNamed(
Routes.libraryItem.name,
pathParameters: {
Routes.libraryItem.pathParamName!: currentBook.libraryItemId,
},
);
},
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: playerMinimizedHeight,
),
child: BookCoverWidget(),
),
),
return GestureDetector(
child: Container(
height: playerMinimizedHeight,
color: Theme.of(context).colorScheme.surface,
child: Stack(
alignment: Alignment.topCenter,
children: [
Hero(tag: 'player_hero', child: const PlayerMinimizedControls()),
PlayerMinimizedProgress(),
],
),
// author and title of the book
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: AppElementSizes.paddingRegular,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
// AutoScrollText(
Text(
'${currentBook.metadata.title ?? ''} - ${currentChapter?.title ?? ''}',
maxLines: 1, overflow: TextOverflow.ellipsis,
// velocity:
// const Velocity(pixelsPerSecond: Offset(16, 0)),
style: Theme.of(context).textTheme.bodyLarge,
),
Text(
currentBook.metadata.asBookMetadataExpanded.authorName ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface
.withValues(alpha: 0.7),
),
),
],
),
),
),
// rewind button
Padding(
padding: const EdgeInsets.only(left: 8),
child: IconButton(
icon: const Icon(
Icons.replay_30,
size: AppElementSizes.iconSizeSmall,
),
onPressed: () {},
),
),
// play/pause button
Padding(
padding: const EdgeInsets.only(right: 8),
child: AudiobookPlayerPlayPauseButton(),
),
],
),
);
}
}
class PlayerMinimizedFramework extends HookConsumerWidget {
final List<Widget> children;
const PlayerMinimizedFramework({super.key, required this.children});
class PlayerMinimizedControls extends HookConsumerWidget {
const PlayerMinimizedControls({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
// final player = ref.watch(playerProvider);
final currentBook = ref.watch(currentBookProvider);
final currentChapter = ref.watch(currentChapterProvider);
final progress =
// useStream(player.positionStreamInChapter, initialData: Duration.zero);
useStream(
ref.read(absAudioPlayerProvider).positionInChapterStream,
initialData: Duration.zero,
);
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (GoRouterState.of(context).topRoute?.name != Routes.player.name) {
context.pushNamed(Routes.player.name);
@ -128,26 +55,109 @@ class PlayerMinimizedFramework extends HookConsumerWidget {
context.pop();
}
},
child: Container(
height: playerMinimizedHeight,
color: Theme.of(context).colorScheme.surface,
child: Stack(
alignment: Alignment.topCenter,
children: [
Row(
children: children,
),
SizedBox(
height: AppElementSizes.barHeight,
child: LinearProgressIndicator(
value: (progress.data ?? Duration.zero).inSeconds /
(currentChapter?.duration.inSeconds ?? 1),
// color: Theme.of(context).colorScheme.onPrimaryContainer,
// backgroundColor: Theme.of(context).colorScheme.primaryContainer,
child: Row(
children: [
// image
Padding(
padding: EdgeInsets.all(AppElementSizes.paddingSmall),
child: GestureDetector(
onTap: () {
// navigate to item page
if (currentBook != null) {
context.pushNamed(
Routes.libraryItem.name,
pathParameters: {
Routes.libraryItem.pathParamName!:
currentBook.libraryItemId,
},
);
}
},
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: playerMinimizedHeight,
),
child: BookCoverWidget(),
),
),
],
),
),
// author and title of the book
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: AppElementSizes.paddingRegular,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
// AutoScrollText(
Text(
'${currentBook?.metadata.title ?? ''} - ${currentChapter?.title ?? ''}',
maxLines: 1, overflow: TextOverflow.ellipsis,
// velocity:
// const Velocity(pixelsPerSecond: Offset(16, 0)),
style: Theme.of(context).textTheme.bodyLarge,
),
Text(
currentBook?.metadata.asBookMetadataExpanded.authorName ??
'',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface
.withValues(alpha: 0.7),
),
),
],
),
),
),
// rewind button
Padding(
padding: const EdgeInsets.only(left: 8),
child: IconButton(
icon: const Icon(
Icons.replay_30,
size: AppElementSizes.iconSizeSmall,
),
onPressed: () {},
),
),
// play/pause button
Padding(
padding: const EdgeInsets.only(right: 8),
child: AudiobookPlayerPlayPauseButton(),
),
],
),
);
}
}
class PlayerMinimizedProgress extends HookConsumerWidget {
const PlayerMinimizedProgress({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final currentChapter = ref.watch(currentChapterProvider);
final progress = useStream(
ref.read(audioPlayerProvider).positionInChapterStream,
initialData: Duration.zero,
);
return SizedBox(
height: AppElementSizes.barHeight,
child: LinearProgressIndicator(
value: (progress.data ?? Duration.zero).inSeconds /
(currentChapter?.duration.inSeconds ?? 1),
// color: Theme.of(context).colorScheme.onPrimaryContainer,
// backgroundColor: Theme.of(context).colorScheme.primaryContainer,
),
);
}