mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
fix: 增加排序
This commit is contained in:
parent
eef72c6aa6
commit
03cec3f4b6
13 changed files with 1151 additions and 925 deletions
|
|
@ -2,6 +2,7 @@ import 'dart:math';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:vaani/constants/hero_tag_conventions.dart';
|
||||
import 'package:vaani/constants/sizes.dart';
|
||||
import 'package:vaani/features/player/providers/abs_provider.dart';
|
||||
import 'package:vaani/features/player/view/widgets/player_player_pause_button.dart';
|
||||
|
|
@ -52,7 +53,10 @@ class PlayerExpanded extends HookConsumerWidget {
|
|||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
// add a shadow to the image elevation hovering effect
|
||||
child: PlayerExpandedImage(imageSize),
|
||||
child: PlayerExpandedImage(
|
||||
imageSize,
|
||||
itemId: currentBook.libraryItemId,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
|
@ -169,8 +173,9 @@ class PlayerExpanded extends HookConsumerWidget {
|
|||
|
||||
class PlayerExpandedImage extends StatelessWidget {
|
||||
final double imageSize;
|
||||
final String? itemId;
|
||||
|
||||
const PlayerExpandedImage(this.imageSize, {super.key});
|
||||
const PlayerExpandedImage(this.imageSize, {super.key, this.itemId});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
|
@ -183,16 +188,11 @@ class PlayerExpandedImage extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
child: SizedBox(
|
||||
height: imageSize,
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppElementSizes.borderRadiusRegular,
|
||||
),
|
||||
child: BookCoverWidget(),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: Hero(
|
||||
tag: HeroTagPrefixes.bookCoverWith(itemId),
|
||||
child: BookCoverWidget(imageSize, itemId: itemId),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,19 +5,15 @@ import 'package:flutter/material.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shelfsdk/audiobookshelf_api.dart';
|
||||
import 'package:vaani/constants/hero_tag_conventions.dart';
|
||||
import 'package:vaani/constants/sizes.dart';
|
||||
import 'package:vaani/features/item_viewer/view/library_item_hero_section.dart';
|
||||
import 'package:vaani/features/player/providers/abs_provider.dart';
|
||||
import 'package:vaani/features/player/view/player_expanded.dart'
|
||||
show PlayerExpandedImage;
|
||||
import 'package:vaani/features/player/view/widgets/audiobook_player_seek_button.dart';
|
||||
import 'package:vaani/features/player/view/widgets/audiobook_player_seek_chapter_button.dart';
|
||||
import 'package:vaani/features/player/view/player_minimized.dart';
|
||||
import 'package:vaani/features/player/view/widgets/chapter_selection_button.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/player/view/widgets/player_speed_adjust_button.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/globals.dart';
|
||||
import 'package:vaani/shared/extensions/model_conversions.dart';
|
||||
|
||||
|
|
@ -30,9 +26,8 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// final textTheme = Theme.of(context).textTheme;
|
||||
final book = ref.watch(currentBookProvider);
|
||||
if (book == null) {
|
||||
final currentBook = ref.watch(currentBookProvider);
|
||||
if (currentBook == null) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +40,7 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
|
|||
final availWidth = MediaQuery.of(context).size.width;
|
||||
// the image width when the player is expanded
|
||||
final imageSize = min(playerMaxHeight * 0.5, availWidth * 0.9);
|
||||
final itemBookMetadata = book.metadata.asBookMetadataExpanded;
|
||||
final itemBookMetadata = currentBook.metadata.asBookMetadataExpanded;
|
||||
return Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
|
|
@ -65,7 +60,10 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
|
|||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
// add a shadow to the image elevation hovering effect
|
||||
child: PlayerExpandedImage(imageSize),
|
||||
child: PlayerExpandedImage(
|
||||
imageSize,
|
||||
itemId: currentBook.libraryItemId,
|
||||
),
|
||||
),
|
||||
_buildBookDetails(imageSize, itemBookMetadata),
|
||||
],
|
||||
|
|
@ -118,14 +116,17 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
|
|||
timeLabelLocation: TimeLabelLocation.sides,
|
||||
),
|
||||
),
|
||||
MouseRegion(
|
||||
cursor: SystemMouseCursors.click, // 桌面端显示手型光标
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
context.pop();
|
||||
},
|
||||
child: _buildBottom(),
|
||||
SizedBox(
|
||||
height: playerMinHeight,
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.click, // 桌面端显示手型光标
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
context.pop();
|
||||
},
|
||||
child: _buildBottom(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -143,27 +144,16 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
|
|||
child: Row(),
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const AudiobookPlayerSeekChapterButton(isForward: false),
|
||||
const AudiobookPlayerSeekButton(isForward: false),
|
||||
// play/pause button
|
||||
const AudiobookPlayerPlayPauseButton(),
|
||||
const AudiobookPlayerSeekButton(isForward: true),
|
||||
const AudiobookPlayerSeekChapterButton(isForward: true),
|
||||
],
|
||||
child: Hero(
|
||||
tag: HeroTagPrefixes.controlsCenter,
|
||||
child: const PlayerControlsDesktopCenter(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
const PlayerSpeedAdjustButton(),
|
||||
const SleepTimerButton(),
|
||||
SkipChapterStartEndButton(),
|
||||
],
|
||||
child: Hero(
|
||||
tag: HeroTagPrefixes.controlsRight,
|
||||
child: const PlayerControlsDesktopRight(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -171,7 +161,9 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
|
|||
}
|
||||
|
||||
Widget _buildBookDetails(
|
||||
double width, BookMetadataExpanded? itemBookMetadata) {
|
||||
double width,
|
||||
BookMetadataExpanded? itemBookMetadata,
|
||||
) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(AppElementSizes.paddingLarge),
|
||||
width: width,
|
||||
|
|
|
|||
|
|
@ -2,10 +2,15 @@ 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/hero_tag_conventions.dart';
|
||||
import 'package:vaani/constants/sizes.dart';
|
||||
import 'package:vaani/features/player/providers/abs_provider.dart';
|
||||
import 'package:vaani/features/player/view/widgets/audiobook_player_seek_button.dart';
|
||||
import 'package:vaani/features/player/view/widgets/audiobook_player_seek_chapter_button.dart';
|
||||
import 'package:vaani/features/player/view/widgets/player_player_pause_button.dart';
|
||||
import 'package:vaani/features/player/view/widgets/player_speed_adjust_button.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/globals.dart';
|
||||
import 'package:vaani/router/router.dart';
|
||||
import 'package:vaani/shared/extensions/chapter.dart';
|
||||
|
|
@ -75,11 +80,12 @@ class PlayerMinimizedControls extends HookConsumerWidget {
|
|||
);
|
||||
}
|
||||
},
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: playerMinHeight,
|
||||
child: Hero(
|
||||
tag: HeroTagPrefixes.bookCoverWith(currentBook?.libraryItemId),
|
||||
child: BookCoverWidget(
|
||||
playerMinHeight,
|
||||
itemId: currentBook?.libraryItemId,
|
||||
),
|
||||
child: BookCoverWidget(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -183,79 +189,130 @@ class PlayerMinimizedControlsDesktop extends HookConsumerWidget {
|
|||
},
|
||||
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: playerMinHeight,
|
||||
),
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 180,
|
||||
child: Row(
|
||||
children: [
|
||||
const AudiobookPlayerSeekChapterButton(isForward: false),
|
||||
// play/pause button
|
||||
const AudiobookPlayerPlayPauseButton(),
|
||||
const AudiobookPlayerSeekChapterButton(isForward: true),
|
||||
// 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: Hero(
|
||||
tag: HeroTagPrefixes.bookCoverWith(
|
||||
currentBook?.libraryItemId),
|
||||
child: BookCoverWidget(
|
||||
playerMinHeight,
|
||||
itemId: currentBook?.libraryItemId,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 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(
|
||||
currentChapter?.title ??
|
||||
currentBook?.metadata.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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Hero(
|
||||
tag: HeroTagPrefixes.controlsCenter,
|
||||
child: const PlayerControlsDesktopCenter(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Hero(
|
||||
tag: HeroTagPrefixes.controlsRight,
|
||||
child: const PlayerControlsDesktopRight(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerControlsDesktopCenter extends StatelessWidget {
|
||||
const PlayerControlsDesktopCenter({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const AudiobookPlayerSeekChapterButton(isForward: false),
|
||||
const AudiobookPlayerSeekButton(isForward: false),
|
||||
// play/pause button
|
||||
const AudiobookPlayerPlayPauseButton(),
|
||||
const AudiobookPlayerSeekButton(isForward: true),
|
||||
const AudiobookPlayerSeekChapterButton(isForward: true),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerControlsDesktopRight extends StatelessWidget {
|
||||
const PlayerControlsDesktopRight({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
const PlayerSpeedAdjustButton(),
|
||||
const SleepTimerButton(),
|
||||
const SkipChapterStartEndButton(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue