mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-17 23:09:36 +00:00
恢复
This commit is contained in:
parent
1ca8e4889a
commit
aad510ea45
31 changed files with 777 additions and 239 deletions
|
|
@ -3,12 +3,12 @@ import 'dart:math';
|
|||
import 'package:flutter/material.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/widgets/player_player_pause_button.dart';
|
||||
import 'package:vaani/features/player/view/widgets/player_progress_bar.dart';
|
||||
import 'package:vaani/features/skip_start_end/view/skip_start_end_button.dart';
|
||||
import 'package:vaani/features/sleep_timer/view/sleep_timer_button.dart';
|
||||
import 'package:vaani/shared/extensions/model_conversions.dart';
|
||||
import 'package:vaani/shared/widgets/shelves/book_shelf.dart';
|
||||
|
||||
import 'widgets/audiobook_player_seek_button.dart';
|
||||
|
|
@ -25,8 +25,8 @@ class PlayerExpanded extends HookConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final session = ref.watch(sessionProvider);
|
||||
if (session == null) {
|
||||
final currentBook = ref.watch(currentBookProvider);
|
||||
if (currentBook == null) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
|
||||
|
|
@ -77,8 +77,8 @@ class PlayerExpanded extends HookConsumerWidget {
|
|||
padding: EdgeInsets.only(bottom: AppElementSizes.paddingRegular),
|
||||
child: Text(
|
||||
[
|
||||
session.displayTitle,
|
||||
session.displayAuthor,
|
||||
currentBook.metadata.title ?? '',
|
||||
currentBook.metadata.asBookMetadataExpanded.authorName ?? '',
|
||||
].join(' - '),
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context)
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final session = ref.watch(sessionProvider);
|
||||
if (session == null) {
|
||||
final book = ref.watch(currentBookProvider);
|
||||
if (book == null) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
|
||||
|
|
@ -49,6 +49,7 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
|
|||
body: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: AppElementSizes.paddingLarge,
|
||||
right: AppElementSizes.paddingRegular,
|
||||
bottom: playerMinHeight + 40,
|
||||
),
|
||||
child: Row(
|
||||
|
|
@ -108,7 +109,18 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
|
|||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Expanded(
|
||||
child: ChapterSelection(),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: Theme.of(context).focusColor,
|
||||
width: 1.0,
|
||||
style: BorderStyle.solid, // 可以设置为 dashed 虚线
|
||||
),
|
||||
),
|
||||
),
|
||||
child: ChapterSelection(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ 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/widgets/player_player_pause_button.dart';
|
||||
import 'package:vaani/router/router.dart';
|
||||
import 'package:vaani/shared/extensions/model_conversions.dart';
|
||||
import 'package:vaani/shared/widgets/shelves/book_shelf.dart';
|
||||
|
||||
/// The height of the player when it is minimized
|
||||
|
|
@ -18,8 +19,8 @@ class PlayerMinimized extends HookConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final session = ref.watch(sessionProvider);
|
||||
if (session == null) {
|
||||
final currentBook = ref.watch(currentBookProvider);
|
||||
if (currentBook == null) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
final currentChapter = ref.watch(currentChapterProvider);
|
||||
|
|
@ -35,7 +36,7 @@ class PlayerMinimized extends HookConsumerWidget {
|
|||
context.pushNamed(
|
||||
Routes.libraryItem.name,
|
||||
pathParameters: {
|
||||
Routes.libraryItem.pathParamName!: session.libraryItemId,
|
||||
Routes.libraryItem.pathParamName!: currentBook.libraryItemId,
|
||||
},
|
||||
);
|
||||
},
|
||||
|
|
@ -60,14 +61,14 @@ class PlayerMinimized extends HookConsumerWidget {
|
|||
children: [
|
||||
// AutoScrollText(
|
||||
PlatformText(
|
||||
'${session.displayTitle} - ${currentChapter?.title ?? ''}',
|
||||
'${currentBook.metadata.title ?? ''} - ${currentChapter?.title ?? ''}',
|
||||
maxLines: 1, overflow: TextOverflow.ellipsis,
|
||||
// velocity:
|
||||
// const Velocity(pixelsPerSecond: Offset(16, 0)),
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
PlatformText(
|
||||
session.displayAuthor,
|
||||
currentBook.metadata.asBookMetadataExpanded.authorName ?? '',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
|
|
|
|||
|
|
@ -21,13 +21,12 @@ class AudiobookPlayerSeekChapterButton extends HookConsumerWidget {
|
|||
size: AppElementSizes.iconSizeSmall,
|
||||
),
|
||||
onPressed: () {
|
||||
if (player.session == null) {
|
||||
if (player.book == null) {
|
||||
return;
|
||||
}
|
||||
// if chapter does not exist, go to the start or end of the book
|
||||
if (player.currentChapter == null) {
|
||||
player
|
||||
.seekInBook(isForward ? player.session!.duration : Duration.zero);
|
||||
player.seekInBook(isForward ? player.book!.duration : Duration.zero);
|
||||
return;
|
||||
}
|
||||
if (isForward) {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class ChapterSelectionModal extends HookConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final session = ref.watch(sessionProvider);
|
||||
final session = ref.watch(currentBookProvider);
|
||||
final currentChapter = ref.watch(currentChapterProvider);
|
||||
|
||||
final currentChapterIndex = currentChapter?.id;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class AudiobookChapterProgressBar extends HookConsumerWidget {
|
|||
progress:
|
||||
currentChapterProgress ?? position.data ?? const Duration(seconds: 0),
|
||||
total: currentChapter == null
|
||||
? player.session?.duration ?? const Duration(seconds: 0)
|
||||
? player.book?.duration ?? const Duration(seconds: 0)
|
||||
: currentChapter.end - currentChapter.start,
|
||||
// ! TODO add onSeek
|
||||
onSeek: (duration) {
|
||||
|
|
@ -74,7 +74,7 @@ class AudiobookProgressBar extends HookConsumerWidget {
|
|||
height: AppElementSizes.barHeightLarge,
|
||||
child: LinearProgressIndicator(
|
||||
value: (position.data ?? const Duration(seconds: 0)).inSeconds /
|
||||
(player.session?.duration ?? const Duration(seconds: 0)).inSeconds,
|
||||
(player.book?.duration ?? const Duration(seconds: 0)).inSeconds,
|
||||
borderRadius: BorderRadiusGeometry.all(Radius.circular(10)),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class PlayerSpeedAdjustButton extends HookConsumerWidget {
|
|||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final player = ref.watch(playerProvider);
|
||||
final bookId = player.session?.libraryItemId ?? '_';
|
||||
final bookId = player.book?.libraryItemId ?? '_';
|
||||
final bookSettings = ref.watch(bookSettingsProvider(bookId));
|
||||
final appSettings = ref.watch(appSettingsProvider);
|
||||
return TextButton(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue