测试安卓修改app名称

This commit is contained in:
rang 2025-12-05 17:59:13 +08:00
parent 6b1edcb475
commit 6ceeb99d20
19 changed files with 1218 additions and 822 deletions

View file

@ -87,7 +87,11 @@ jobs:
run: flutter build apk --release
- name: Rename Universal APK
run: mv build/app/outputs/flutter-apk/{app-release,app-universal-release}.apk
run: |
APP_NAME=$(grep '^name:' pubspec.yaml | sed 's/name: //')
APP_VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //')
mv build/app/outputs/flutter-apk/{app-release,$APP_NAME-$APP_VERSION-app-universal}.apk
- name: Build App Bundle
run: flutter build appbundle --release

View file

@ -2,7 +2,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart' show Ref;
import 'package:logging/logging.dart' show Logger;
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shelfsdk/audiobookshelf_api.dart'
show GetLibrarysItemsReqParams, Library, LibraryItemMinified;
show GetLibrarysItemsReqParams, Library, LibraryItemMinified, LibraryItem;
import 'package:vaani/api/api_provider.dart' show authenticatedApiProvider;
import 'package:vaani/features/settings/api_settings_provider.dart'
show apiSettingsProvider;
@ -59,9 +59,21 @@ class Libraries extends _$Libraries {
}
}
@riverpod
class LibraryItemsParams extends _$LibraryItemsParams {
@override
GetLibrarysItemsReqParams build() {
return const GetLibrarysItemsReqParams(
limit: 18,
page: 0,
minified: true,
);
}
}
//
@riverpod
Future<List<LibraryItemMinified>> currentLibraryItems(Ref ref) async {
Future<List<LibraryItem>> currentLibraryItems(Ref ref) async {
final api = ref.watch(authenticatedApiProvider);
final libraryId =
ref.watch(apiSettingsProvider.select((s) => s.activeLibraryId));
@ -73,12 +85,12 @@ Future<List<LibraryItemMinified>> currentLibraryItems(Ref ref) async {
libraryId: libraryId,
parameters: const GetLibrarysItemsReqParams(
limit: 18,
page: 1,
page: 0,
minified: true,
),
);
if (items == null) {
return [];
}
return items.results.map((v) => v.asMinified).toList();
return items.results;
}

View file

@ -174,12 +174,12 @@ final currentLibraryProvider = AutoDisposeFutureProvider<Library?>.internal(
// ignore: unused_element
typedef CurrentLibraryRef = AutoDisposeFutureProviderRef<Library?>;
String _$currentLibraryItemsHash() =>
r'2e2ce270c46bedf0b779399772df89a23803fe50';
r'b0d0dcca86e760ee08f327c06b5ad5deaf7852e1';
/// See also [currentLibraryItems].
@ProviderFor(currentLibraryItems)
final currentLibraryItemsProvider =
AutoDisposeFutureProvider<List<LibraryItemMinified>>.internal(
AutoDisposeFutureProvider<List<LibraryItem>>.internal(
currentLibraryItems,
name: r'currentLibraryItemsProvider',
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
@ -192,7 +192,7 @@ final currentLibraryItemsProvider =
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
typedef CurrentLibraryItemsRef
= AutoDisposeFutureProviderRef<List<LibraryItemMinified>>;
= AutoDisposeFutureProviderRef<List<LibraryItem>>;
String _$librariesHash() => r'95ebd4d1ac0cc2acf7617dc22895eff0ca30600f';
/// See also [Libraries].
@ -208,5 +208,22 @@ final librariesProvider =
);
typedef _$Libraries = AutoDisposeAsyncNotifier<List<Library>>;
String _$libraryItemsParamsHash() =>
r'9e7f11ab185eb99e926ae87e06466fc12aee7f72';
/// See also [LibraryItemsParams].
@ProviderFor(LibraryItemsParams)
final libraryItemsParamsProvider = AutoDisposeNotifierProvider<
LibraryItemsParams, GetLibrarysItemsReqParams>.internal(
LibraryItemsParams.new,
name: r'libraryItemsParamsProvider',
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
? null
: _$libraryItemsParamsHash,
dependencies: null,
allTransitiveDependencies: null,
);
typedef _$LibraryItemsParams = AutoDisposeNotifier<GetLibrarysItemsReqParams>;
// ignore_for_file: type=lint
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

View file

@ -0,0 +1,39 @@
import 'package:audio_service/audio_service.dart';
import 'package:just_audio/just_audio.dart';
class AbsAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandler {
final AudioPlayer player;
AbsAudioHandler(this.player);
//
@override
Future<void> play() async {
await player.play();
}
@override
Future<void> pause() async {
await player.pause();
}
@override
Future<void> skipToNext() async {
await player.seekToNext();
}
@override
Future<void> skipToPrevious() async {
await player.seekToPrevious();
}
@override
Future<void> seek(Duration position) async {
await player.seek(position);
}
@override
Future<void> setSpeed(double speed) async {
await player.setSpeed(speed);
}
}

View file

@ -0,0 +1,5 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:just_audio/just_audio.dart';
import 'package:shelfsdk/audiobookshelf_api.dart';
class AbsAudioPlayer extends AudioPlayer {}

View file

@ -32,6 +32,7 @@ class AbsAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandler {
final _currentChapterObject = BehaviorSubject<BookChapter?>.seeded(null);
AbsAudioHandler(this.ref) {
notificationSettings = ref.read(appSettingsProvider).notificationSettings;
ref.listen(appSettingsProvider, (a, b) {
if (a?.notificationSettings != b.notificationSettings) {
notificationSettings = b.notificationSettings;
@ -52,12 +53,12 @@ class AbsAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandler {
final chapter = _book?.findChapterAtTime(positionInBook);
if (chapter != currentChapter) {
if (mediaItem.hasValue && chapter != null) {
updateMediaItem(
mediaItem.value!.copyWith(
duration: chapter.duration,
displayTitle: chapter.title,
),
);
// updateMediaItem(
// mediaItem.value!.copyWith(
// duration: chapter.duration,
// displayTitle: chapter.title,
// ),
// );
}
_currentChapterObject.sink.add(chapter);
}

View file

@ -0,0 +1,56 @@
import 'package:audio_service/audio_service.dart';
import 'package:audio_session/audio_session.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:just_audio_media_kit/just_audio_media_kit.dart';
import 'package:logging/logging.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shelfsdk/audiobookshelf_api.dart';
import 'package:vaani/features/player/core/abs_audio_handler.dart' as core;
import 'package:vaani/features/player/core/abs_audio_player.dart' as core;
part 'abs_provider.g.dart';
final _logger = Logger('AbsPlayerProvider');
@Riverpod(keepAlive: true)
Future<core.AbsAudioHandler> absAudioHandler(Ref ref) async {
// for playing audio on windows, linux
JustAudioMediaKit.ensureInitialized();
// for configuring how this app will interact with other audio apps
final session = await AudioSession.instance;
await session.configure(const AudioSessionConfiguration.speech());
final player = ref.read(absAudioPlayerProvider);
final audioService = await AudioService.init(
builder: () => core.AbsAudioHandler(player),
config: const AudioServiceConfig(
androidNotificationChannelId: 'dr.blank.vaani.channel.audio',
androidNotificationChannelName: 'ABSPlayback',
androidNotificationChannelDescription:
'Needed to control audio from lock screen',
androidNotificationOngoing: false,
androidStopForegroundOnPause: false,
androidNotificationIcon: 'drawable/ic_stat_logo',
preloadArtwork: true,
// fastForwardInterval: Duration(seconds: 20),
// rewindInterval: Duration(seconds: 20),
),
);
return audioService;
}
@Riverpod(keepAlive: true)
class AbsAudioPlayer extends _$AbsAudioPlayer {
@override
core.AbsAudioPlayer build() {
final player = core.AbsAudioPlayer();
ref.onDispose(player.dispose);
_logger.finer('created simple player');
return player;
}
}

View file

@ -0,0 +1,43 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'abs_provider.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
String _$absAudioHandlerHash() => r'f4ef20cc3e244d5d37354ef38a1e0fdbd89412f4';
/// See also [absAudioHandler].
@ProviderFor(absAudioHandler)
final absAudioHandlerProvider = FutureProvider<core.AbsAudioHandler>.internal(
absAudioHandler,
name: r'absAudioHandlerProvider',
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
? null
: _$absAudioHandlerHash,
dependencies: null,
allTransitiveDependencies: null,
);
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
typedef AbsAudioHandlerRef = FutureProviderRef<core.AbsAudioHandler>;
String _$absAudioPlayerHash() => r'68a56d45a9f165d257c23f81d9bf7d0930425464';
/// See also [AbsAudioPlayer].
@ProviderFor(AbsAudioPlayer)
final absAudioPlayerProvider =
NotifierProvider<AbsAudioPlayer, core.AbsAudioPlayer>.internal(
AbsAudioPlayer.new,
name: r'absAudioPlayerProvider',
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
? null
: _$absAudioPlayerHash,
dependencies: null,
allTransitiveDependencies: null,
);
typedef _$AbsAudioPlayer = Notifier<core.AbsAudioPlayer>;
// ignore_for_file: type=lint
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

View file

@ -99,6 +99,7 @@ List<core.BookChapter> currentChapters(Ref ref) {
}
final index = book.chapters.indexOf(currentChapter);
final total = book.chapters.length;
return book.chapters
.sublist(index - 3, (total - 3) <= (index + 17) ? total : index + 17);
final start = index - 3 >= 0 ? index - 3 : 0;
final end = start + 20 <= total ? start + 20 : total;
return book.chapters.sublist(start, end);
}

View file

@ -6,7 +6,7 @@ part of 'currently_playing_provider.dart';
// RiverpodGenerator
// **************************************************************************
String _$currentChaptersHash() => r'a25733d8085a2ce7dbc16fa2bf14f00ab8e2a623';
String _$currentChaptersHash() => r'6574b3f4ee0af8006f233aaf76cc507d188c6305';
/// See also [currentChapters].
@ProviderFor(currentChapters)

View file

@ -1,7 +1,9 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shelfsdk/audiobookshelf_api.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';
@ -137,22 +139,45 @@ class PlayerExpandedDesktop extends HookConsumerWidget {
class ChapterSelection extends HookConsumerWidget {
const ChapterSelection({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final currentChapter = ref.watch(currentChapterProvider);
if (currentChapter == null) {
return SizedBox.shrink();
}
final chapters = useState(<BookChapter>[]);
final scrollController = useScrollController();
useEffect(
() {
int page = 0;
void load(page) {
chapters.value.addAll(ref.watch(currentChaptersProvider));
}
final currentChapters = ref.watch(currentChaptersProvider);
final currentChapterIndex = currentChapters.indexOf(currentChapter);
load(page);
void listener() {
if (scrollController.position.pixels /
scrollController.position.maxScrollExtent >
0.8) {
print('滚动到底部');
}
}
scrollController.addListener(listener);
return () => scrollController.removeListener(listener);
},
[scrollController],
);
final currentChapterIndex = chapters.value.indexOf(currentChapter);
final theme = Theme.of(context);
return Scrollbar(
controller: scrollController,
child: ListView.builder(
itemCount: currentChapters.length,
controller: scrollController,
itemCount: chapters.value.length,
itemBuilder: (context, index) {
final chapter = currentChapters[index];
final chapter = chapters.value[index];
final isCurrent = currentChapterIndex == index;
final isPlayed = index < currentChapterIndex;
return ListTile(

View file

@ -54,8 +54,10 @@ class MessageLookup extends MessageLookupByLibrary {
"accountDeleteServer": MessageLookupByLibrary.simpleMessage(
"Delete Server",
),
"accountInvalidURL": MessageLookupByLibrary.simpleMessage("Invalid URL"),
"accountManage": MessageLookupByLibrary.simpleMessage("Manage Accounts"),
"accountInvalidURL":
MessageLookupByLibrary.simpleMessage("Invalid URL"),
"accountManage":
MessageLookupByLibrary.simpleMessage("Manage Accounts"),
"accountRegisteredServers": MessageLookupByLibrary.simpleMessage(
"Registered Servers",
),
@ -94,7 +96,8 @@ class MessageLookup extends MessageLookupByLibrary {
"autoTurnOnTimerAlways": MessageLookupByLibrary.simpleMessage(
"Always Auto Turn On Timer",
),
"autoTurnOnTimerAlwaysDescription": MessageLookupByLibrary.simpleMessage(
"autoTurnOnTimerAlwaysDescription":
MessageLookupByLibrary.simpleMessage(
"Always turn on the sleep timer, no matter what",
),
"autoTurnOnTimerDescription": MessageLookupByLibrary.simpleMessage(
@ -122,9 +125,11 @@ class MessageLookup extends MessageLookupByLibrary {
"bookAuthors": MessageLookupByLibrary.simpleMessage("Authors"),
"bookDownloads": MessageLookupByLibrary.simpleMessage("Downloads"),
"bookGenres": MessageLookupByLibrary.simpleMessage("Genres"),
"bookMetadataAbridged": MessageLookupByLibrary.simpleMessage("Abridged"),
"bookMetadataAbridged":
MessageLookupByLibrary.simpleMessage("Abridged"),
"bookMetadataLength": MessageLookupByLibrary.simpleMessage("Length"),
"bookMetadataPublished": MessageLookupByLibrary.simpleMessage("Published"),
"bookMetadataPublished":
MessageLookupByLibrary.simpleMessage("Published"),
"bookMetadataUnabridged": MessageLookupByLibrary.simpleMessage(
"Unabridged",
),
@ -178,11 +183,13 @@ class MessageLookup extends MessageLookupByLibrary {
"homeBookContinueSeries": MessageLookupByLibrary.simpleMessage(
"Continue Series",
),
"homeBookContinueSeriesDescription": MessageLookupByLibrary.simpleMessage(
"homeBookContinueSeriesDescription":
MessageLookupByLibrary.simpleMessage(
"Show play button for books in continue series shelf",
),
"homeBookDiscover": MessageLookupByLibrary.simpleMessage("Discover"),
"homeBookListenAgain": MessageLookupByLibrary.simpleMessage("Listen Again"),
"homeBookListenAgain":
MessageLookupByLibrary.simpleMessage("Listen Again"),
"homeBookListenAgainDescription": MessageLookupByLibrary.simpleMessage(
"Show play button for all books in listen again shelf",
),
@ -192,7 +199,8 @@ class MessageLookup extends MessageLookupByLibrary {
"homeBookRecentlyAdded": MessageLookupByLibrary.simpleMessage(
"Recently Added",
),
"homeBookRecommended": MessageLookupByLibrary.simpleMessage("Recommended"),
"homeBookRecommended":
MessageLookupByLibrary.simpleMessage("Recommended"),
"homeContinueListening": MessageLookupByLibrary.simpleMessage(
"Continue Listening",
),
@ -265,7 +273,8 @@ class MessageLookup extends MessageLookupByLibrary {
"nmpSettingsMediaControls": MessageLookupByLibrary.simpleMessage(
"Media Controls",
),
"nmpSettingsMediaControlsDescription": MessageLookupByLibrary.simpleMessage(
"nmpSettingsMediaControlsDescription":
MessageLookupByLibrary.simpleMessage(
"Select the media controls to display",
),
"nmpSettingsSelectOne": MessageLookupByLibrary.simpleMessage(
@ -284,27 +293,32 @@ class MessageLookup extends MessageLookupByLibrary {
"nmpSettingsSubTitleDescription": MessageLookupByLibrary.simpleMessage(
"The subtitle of the notification\n",
),
"nmpSettingsTitle": MessageLookupByLibrary.simpleMessage("Primary Title"),
"nmpSettingsTitle":
MessageLookupByLibrary.simpleMessage("Primary Title"),
"nmpSettingsTitleDescription": MessageLookupByLibrary.simpleMessage(
"The title of the notification\n",
),
"no": MessageLookupByLibrary.simpleMessage("No"),
"notImplemented": MessageLookupByLibrary.simpleMessage("Not implemented"),
"notImplemented":
MessageLookupByLibrary.simpleMessage("Not implemented"),
"notificationMediaPlayer": MessageLookupByLibrary.simpleMessage(
"Notification Media Player",
),
"notificationMediaPlayerDescription": MessageLookupByLibrary.simpleMessage(
"notificationMediaPlayerDescription":
MessageLookupByLibrary.simpleMessage(
"Customize the media player in notifications",
),
"ok": MessageLookupByLibrary.simpleMessage("OK"),
"pause": MessageLookupByLibrary.simpleMessage("Pause"),
"play": MessageLookupByLibrary.simpleMessage("Play"),
"playerSettings": MessageLookupByLibrary.simpleMessage("Player Settings"),
"playerSettings":
MessageLookupByLibrary.simpleMessage("Player Settings"),
"playerSettingsCompleteTime": MessageLookupByLibrary.simpleMessage(
"Mark Complete When Time Left",
),
"playerSettingsCompleteTimeDescriptionHead":
MessageLookupByLibrary.simpleMessage("Mark complete when less than "),
MessageLookupByLibrary.simpleMessage(
"Mark complete when less than "),
"playerSettingsCompleteTimeDescriptionTail":
MessageLookupByLibrary.simpleMessage(" left in the book"),
"playerSettingsDescription": MessageLookupByLibrary.simpleMessage(
@ -319,7 +333,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage(
"Show the progress of the current chapter in the player",
),
"playerSettingsDisplayTotalProgress": MessageLookupByLibrary.simpleMessage(
"playerSettingsDisplayTotalProgress":
MessageLookupByLibrary.simpleMessage(
"Show Total Progress",
),
"playerSettingsDisplayTotalProgressDescription":
@ -348,7 +363,8 @@ class MessageLookup extends MessageLookupByLibrary {
),
"playerSettingsPlaybackReportingMinimumDescriptionTail":
MessageLookupByLibrary.simpleMessage("of the book"),
"playerSettingsRememberForEveryBook": MessageLookupByLibrary.simpleMessage(
"playerSettingsRememberForEveryBook":
MessageLookupByLibrary.simpleMessage(
"Remember Player Settings for Every Book",
),
"playerSettingsRememberForEveryBookDescription":
@ -362,14 +378,17 @@ class MessageLookup extends MessageLookupByLibrary {
"playerSettingsSpeedOptions": MessageLookupByLibrary.simpleMessage(
"Speed Options",
),
"playerSettingsSpeedOptionsSelect": MessageLookupByLibrary.simpleMessage(
"playerSettingsSpeedOptionsSelect":
MessageLookupByLibrary.simpleMessage(
"Select Speed Options",
),
"playerSettingsSpeedOptionsSelectAdd": MessageLookupByLibrary.simpleMessage(
"playerSettingsSpeedOptionsSelectAdd":
MessageLookupByLibrary.simpleMessage(
"Add Speed Option",
),
"playerSettingsSpeedOptionsSelectAddHelper":
MessageLookupByLibrary.simpleMessage("Enter a new speed option to add"),
MessageLookupByLibrary.simpleMessage(
"Enter a new speed option to add"),
"playerSettingsSpeedSelect": MessageLookupByLibrary.simpleMessage(
"Select Speed",
),
@ -417,7 +436,8 @@ class MessageLookup extends MessageLookupByLibrary {
"shakeActivationThreshold": MessageLookupByLibrary.simpleMessage(
"Shake Activation Threshold",
),
"shakeActivationThresholdDescription": MessageLookupByLibrary.simpleMessage(
"shakeActivationThresholdDescription":
MessageLookupByLibrary.simpleMessage(
"The higher the threshold, the harder you need to shake",
),
"shakeDetector": MessageLookupByLibrary.simpleMessage("Shake Detector"),
@ -455,7 +475,8 @@ class MessageLookup extends MessageLookupByLibrary {
"themeModeHighContrast": MessageLookupByLibrary.simpleMessage(
"High Contrast Mode",
),
"themeModeHighContrastDescription": MessageLookupByLibrary.simpleMessage(
"themeModeHighContrastDescription":
MessageLookupByLibrary.simpleMessage(
"Increase the contrast between the background and the text",
),
"themeModeLight": MessageLookupByLibrary.simpleMessage("Light"),
@ -470,7 +491,8 @@ class MessageLookup extends MessageLookupByLibrary {
"themeSettingsColorsBook": MessageLookupByLibrary.simpleMessage(
"Adaptive Theme on Item Page",
),
"themeSettingsColorsBookDescription": MessageLookupByLibrary.simpleMessage(
"themeSettingsColorsBookDescription":
MessageLookupByLibrary.simpleMessage(
"Get fancy with the colors on the item page at the cost of some performance",
),
"themeSettingsColorsCurrent": MessageLookupByLibrary.simpleMessage(

View file

@ -50,7 +50,8 @@ class MessageLookup extends MessageLookupByLibrary {
"accountDeleteServer": MessageLookupByLibrary.simpleMessage("删除服务器"),
"accountInvalidURL": MessageLookupByLibrary.simpleMessage("无效网址"),
"accountManage": MessageLookupByLibrary.simpleMessage("帐户管理"),
"accountRegisteredServers": MessageLookupByLibrary.simpleMessage("已注册服务器"),
"accountRegisteredServers":
MessageLookupByLibrary.simpleMessage("已注册服务器"),
"accountRemoveServerAndUsers": MessageLookupByLibrary.simpleMessage(
"删除服务器和用户",
),
@ -60,7 +61,8 @@ class MessageLookup extends MessageLookupByLibrary {
"accountRemoveServerAndUsersTail": MessageLookupByLibrary.simpleMessage(
" 以及该应用程序中所有用户的登录信息。",
),
"accountRemoveUserLogin": MessageLookupByLibrary.simpleMessage("删除用户登录"),
"accountRemoveUserLogin":
MessageLookupByLibrary.simpleMessage("删除用户登录"),
"accountRemoveUserLoginHead": MessageLookupByLibrary.simpleMessage(
"这将删除用户 ",
),
@ -72,11 +74,15 @@ class MessageLookup extends MessageLookupByLibrary {
"accountUsersCount": m1,
"appSettings": MessageLookupByLibrary.simpleMessage("应用设置"),
"appearance": MessageLookupByLibrary.simpleMessage("外观"),
"autoSleepTimerSettings": MessageLookupByLibrary.simpleMessage("自动睡眠定时器设置"),
"autoTurnOnSleepTimer": MessageLookupByLibrary.simpleMessage("自动开启睡眠定时器"),
"autoSleepTimerSettings":
MessageLookupByLibrary.simpleMessage("自动睡眠定时器设置"),
"autoTurnOnSleepTimer":
MessageLookupByLibrary.simpleMessage("自动开启睡眠定时器"),
"autoTurnOnTimer": MessageLookupByLibrary.simpleMessage("自动开启定时器"),
"autoTurnOnTimerAlways": MessageLookupByLibrary.simpleMessage("始终自动开启定时器"),
"autoTurnOnTimerAlwaysDescription": MessageLookupByLibrary.simpleMessage(
"autoTurnOnTimerAlways":
MessageLookupByLibrary.simpleMessage("始终自动开启定时器"),
"autoTurnOnTimerAlwaysDescription":
MessageLookupByLibrary.simpleMessage(
"总是打开睡眠定时器",
),
"autoTurnOnTimerDescription": MessageLookupByLibrary.simpleMessage(
@ -118,7 +124,8 @@ class MessageLookup extends MessageLookupByLibrary {
"copyToClipboardDescription": MessageLookupByLibrary.simpleMessage(
"将应用程序设置复制到剪贴板",
),
"copyToClipboardToast": MessageLookupByLibrary.simpleMessage("设置已复制到剪贴板"),
"copyToClipboardToast":
MessageLookupByLibrary.simpleMessage("设置已复制到剪贴板"),
"delete": MessageLookupByLibrary.simpleMessage("删除"),
"deleteDialog": m2,
"deleted": m3,
@ -128,11 +135,13 @@ class MessageLookup extends MessageLookupByLibrary {
"general": MessageLookupByLibrary.simpleMessage("通用"),
"help": MessageLookupByLibrary.simpleMessage("Help"),
"home": MessageLookupByLibrary.simpleMessage("首页"),
"homeBookContinueListening": MessageLookupByLibrary.simpleMessage("继续收听"),
"homeBookContinueListening":
MessageLookupByLibrary.simpleMessage("继续收听"),
"homeBookContinueListeningDescription":
MessageLookupByLibrary.simpleMessage("继续收听书架上显示播放按钮"),
"homeBookContinueSeries": MessageLookupByLibrary.simpleMessage("继续系列"),
"homeBookContinueSeriesDescription": MessageLookupByLibrary.simpleMessage(
"homeBookContinueSeriesDescription":
MessageLookupByLibrary.simpleMessage(
"继续系列书架上显示播放按钮",
),
"homeBookDiscover": MessageLookupByLibrary.simpleMessage("发现"),
@ -154,7 +163,8 @@ class MessageLookup extends MessageLookupByLibrary {
),
"homePageSettingsOtherShelvesDescription":
MessageLookupByLibrary.simpleMessage("显示所有剩余书架上所有书籍的播放按钮"),
"homePageSettingsQuickPlay": MessageLookupByLibrary.simpleMessage("继续播放"),
"homePageSettingsQuickPlay":
MessageLookupByLibrary.simpleMessage("继续播放"),
"homeStartListening": MessageLookupByLibrary.simpleMessage("开始收听"),
"language": MessageLookupByLibrary.simpleMessage("语言"),
"languageDescription": MessageLookupByLibrary.simpleMessage("语言切换"),
@ -171,7 +181,8 @@ class MessageLookup extends MessageLookupByLibrary {
"loginOpenID": MessageLookupByLibrary.simpleMessage("OpenID"),
"loginPassword": MessageLookupByLibrary.simpleMessage("密码"),
"loginServerClick": MessageLookupByLibrary.simpleMessage("单击此处"),
"loginServerConnected": MessageLookupByLibrary.simpleMessage("服务器已连接,请登录"),
"loginServerConnected":
MessageLookupByLibrary.simpleMessage("服务器已连接,请登录"),
"loginServerNo": MessageLookupByLibrary.simpleMessage("没有服务器? "),
"loginServerNoConnected": MessageLookupByLibrary.simpleMessage(
"请输入您的AudiobookShelf服务器的URL",
@ -184,8 +195,10 @@ class MessageLookup extends MessageLookupByLibrary {
"logs": MessageLookupByLibrary.simpleMessage("日志"),
"nmpSettingsBackward": MessageLookupByLibrary.simpleMessage("快退间隔"),
"nmpSettingsForward": MessageLookupByLibrary.simpleMessage("快进间隔"),
"nmpSettingsMediaControls": MessageLookupByLibrary.simpleMessage("媒体控制"),
"nmpSettingsMediaControlsDescription": MessageLookupByLibrary.simpleMessage(
"nmpSettingsMediaControls":
MessageLookupByLibrary.simpleMessage("媒体控制"),
"nmpSettingsMediaControlsDescription":
MessageLookupByLibrary.simpleMessage(
"选择要显示的媒体控件",
),
"nmpSettingsSelectOne": MessageLookupByLibrary.simpleMessage(
@ -206,8 +219,10 @@ class MessageLookup extends MessageLookupByLibrary {
),
"no": MessageLookupByLibrary.simpleMessage(""),
"notImplemented": MessageLookupByLibrary.simpleMessage("未实现"),
"notificationMediaPlayer": MessageLookupByLibrary.simpleMessage("通知媒体播放器"),
"notificationMediaPlayerDescription": MessageLookupByLibrary.simpleMessage(
"notificationMediaPlayer":
MessageLookupByLibrary.simpleMessage("通知媒体播放器"),
"notificationMediaPlayerDescription":
MessageLookupByLibrary.simpleMessage(
"在通知中自定义媒体播放器",
),
"ok": MessageLookupByLibrary.simpleMessage("确定"),
@ -229,7 +244,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("显示章节进度"),
"playerSettingsDisplayChapterProgressDescription":
MessageLookupByLibrary.simpleMessage("在播放器中显示当前章节的进度"),
"playerSettingsDisplayTotalProgress": MessageLookupByLibrary.simpleMessage(
"playerSettingsDisplayTotalProgress":
MessageLookupByLibrary.simpleMessage(
"显示总进度",
),
"playerSettingsDisplayTotalProgressDescription":
@ -252,7 +268,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("不要报告本书前 "),
"playerSettingsPlaybackReportingMinimumDescriptionTail":
MessageLookupByLibrary.simpleMessage(" 的播放"),
"playerSettingsRememberForEveryBook": MessageLookupByLibrary.simpleMessage(
"playerSettingsRememberForEveryBook":
MessageLookupByLibrary.simpleMessage(
"记住每本书的播放器设置",
),
"playerSettingsRememberForEveryBookDescription":
@ -264,15 +281,18 @@ class MessageLookup extends MessageLookupByLibrary {
"playerSettingsSpeedOptions": MessageLookupByLibrary.simpleMessage(
"播放速度选项",
),
"playerSettingsSpeedOptionsSelect": MessageLookupByLibrary.simpleMessage(
"playerSettingsSpeedOptionsSelect":
MessageLookupByLibrary.simpleMessage(
"播放速度选项",
),
"playerSettingsSpeedOptionsSelectAdd": MessageLookupByLibrary.simpleMessage(
"playerSettingsSpeedOptionsSelectAdd":
MessageLookupByLibrary.simpleMessage(
"添加一个速度选项",
),
"playerSettingsSpeedOptionsSelectAddHelper":
MessageLookupByLibrary.simpleMessage("输入一个新的速度选项"),
"playerSettingsSpeedSelect": MessageLookupByLibrary.simpleMessage("选择播放速度"),
"playerSettingsSpeedSelect":
MessageLookupByLibrary.simpleMessage("选择播放速度"),
"playerSettingsSpeedSelectHelper": MessageLookupByLibrary.simpleMessage(
"输入默认的播放速度",
),
@ -293,8 +313,10 @@ class MessageLookup extends MessageLookupByLibrary {
"restoreBackupHint": MessageLookupByLibrary.simpleMessage("将备份粘贴到此处"),
"restoreBackupInvalid": MessageLookupByLibrary.simpleMessage("无效备份"),
"restoreBackupSuccess": MessageLookupByLibrary.simpleMessage("设置已恢复"),
"restoreBackupValidator": MessageLookupByLibrary.simpleMessage("请将备份粘贴到此处"),
"restoreDescription": MessageLookupByLibrary.simpleMessage("从备份中还原应用程序设置"),
"restoreBackupValidator":
MessageLookupByLibrary.simpleMessage("请将备份粘贴到此处"),
"restoreDescription":
MessageLookupByLibrary.simpleMessage("从备份中还原应用程序设置"),
"resume": MessageLookupByLibrary.simpleMessage("继续"),
"retry": MessageLookupByLibrary.simpleMessage("重试"),
"settings": MessageLookupByLibrary.simpleMessage("设置"),
@ -302,8 +324,10 @@ class MessageLookup extends MessageLookupByLibrary {
"shakeActionDescription": MessageLookupByLibrary.simpleMessage(
"检测到抖动时要执行的操作",
),
"shakeActivationThreshold": MessageLookupByLibrary.simpleMessage("抖动激活阈值"),
"shakeActivationThresholdDescription": MessageLookupByLibrary.simpleMessage(
"shakeActivationThreshold":
MessageLookupByLibrary.simpleMessage("抖动激活阈值"),
"shakeActivationThresholdDescription":
MessageLookupByLibrary.simpleMessage(
"门槛越高,你就越难摇晃",
),
"shakeDetector": MessageLookupByLibrary.simpleMessage("抖动检测器"),
@ -314,7 +338,8 @@ class MessageLookup extends MessageLookupByLibrary {
"shakeDetectorEnableDescription": MessageLookupByLibrary.simpleMessage(
"启用抖动检测以执行各种操作",
),
"shakeDetectorSettings": MessageLookupByLibrary.simpleMessage("抖动检测器设置"),
"shakeDetectorSettings":
MessageLookupByLibrary.simpleMessage("抖动检测器设置"),
"shakeFeedback": MessageLookupByLibrary.simpleMessage("抖动反馈"),
"shakeFeedbackDescription": MessageLookupByLibrary.simpleMessage(
"检测到抖动时给出的反馈",
@ -329,18 +354,21 @@ class MessageLookup extends MessageLookupByLibrary {
"themeMode": MessageLookupByLibrary.simpleMessage("主题模式"),
"themeModeDark": MessageLookupByLibrary.simpleMessage("深色"),
"themeModeHighContrast": MessageLookupByLibrary.simpleMessage("高对比度模式"),
"themeModeHighContrastDescription": MessageLookupByLibrary.simpleMessage(
"themeModeHighContrastDescription":
MessageLookupByLibrary.simpleMessage(
"增加背景和文本之间的对比度",
),
"themeModeLight": MessageLookupByLibrary.simpleMessage("浅色"),
"themeModeSystem": MessageLookupByLibrary.simpleMessage("跟随系统"),
"themeSettings": MessageLookupByLibrary.simpleMessage("主题设置"),
"themeSettingsColors": MessageLookupByLibrary.simpleMessage("主题色"),
"themeSettingsColorsAndroid": MessageLookupByLibrary.simpleMessage("主题色"),
"themeSettingsColorsAndroid":
MessageLookupByLibrary.simpleMessage("主题色"),
"themeSettingsColorsBook": MessageLookupByLibrary.simpleMessage(
"书籍详情页自适应主题",
),
"themeSettingsColorsBookDescription": MessageLookupByLibrary.simpleMessage(
"themeSettingsColorsBookDescription":
MessageLookupByLibrary.simpleMessage(
"以牺牲一些性能为代价,对书籍详情页的颜色进行美化",
),
"themeSettingsColorsCurrent": MessageLookupByLibrary.simpleMessage(
@ -351,7 +379,8 @@ class MessageLookup extends MessageLookupByLibrary {
"themeSettingsColorsDescription": MessageLookupByLibrary.simpleMessage(
"使用应用程序的系统主题色",
),
"themeSettingsDescription": MessageLookupByLibrary.simpleMessage("自定义应用主题"),
"themeSettingsDescription":
MessageLookupByLibrary.simpleMessage("自定义应用主题"),
"timeSecond": m7,
"unknown": MessageLookupByLibrary.simpleMessage("未知"),
"webVersion": MessageLookupByLibrary.simpleMessage("Web版本"),

View file

@ -160,7 +160,6 @@ class AbsApp extends ConsumerWidget {
);
try {
return MaterialApp.router(
// debugShowCheckedModeBanner: false,
locale: Locale(appSettings.language),
localizationsDelegates: [
//
@ -175,6 +174,7 @@ class AbsApp extends ConsumerWidget {
themeMode: themeSettings.themeMode,
routerConfig: routerConfig,
themeAnimationCurve: Curves.easeInOut,
debugShowCheckedModeBanner: false,
);
} catch (e) {
debugPrintStack(stackTrace: StackTrace.current, label: e.toString());

View file

@ -1,12 +1,20 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shelfsdk/audiobookshelf_api.dart';
import 'package:vaani/api/api_provider.dart';
import 'package:vaani/globals.dart';
import 'package:vaani/features/settings/api_settings_provider.dart';
import '../shared/widgets/drawer.dart';
import '../shared/widgets/shelves/home_shelf.dart';
import 'package:vaani/api/image_provider.dart';
import 'package:vaani/api/library_provider.dart';
import 'package:vaani/features/you/view/widgets/library_switch_chip.dart';
import 'package:vaani/generated/l10n.dart';
import 'package:vaani/router/router.dart';
import 'package:vaani/shared/extensions/model_conversions.dart';
import 'package:vaani/shared/icons/abs_icons.dart';
import 'package:vaani/shared/widgets/shelves/book_shelf.dart';
// TODO: implement the library page
class LibraryPage extends HookConsumerWidget {
@ -15,20 +23,28 @@ class LibraryPage extends HookConsumerWidget {
final String? libraryId;
@override
Widget build(BuildContext context, WidgetRef ref) {
// set the library id as the active library
if (libraryId != null) {
ref.read(apiSettingsProvider.notifier).updateState(
ref.watch(apiSettingsProvider).copyWith(activeLibraryId: libraryId),
);
}
final currentLibrary = ref.watch(currentLibraryProvider).valueOrNull;
final views = ref.watch(personalizedViewProvider);
// Determine the icon to use, with a fallback
final IconData libraryIconData =
AbsIcons.getIconByName(currentLibrary?.icon) ?? Icons.library_books;
// Determine the title text
final String appBarTitle = currentLibrary?.name ?? S.of(context).library;
// set the library id as the active library
// if (libraryId != null) {
// ref.read(apiSettingsProvider.notifier).updateState(
// ref.watch(apiSettingsProvider).copyWith(activeLibraryId: libraryId),
// );
// }
final views = ref.watch(currentLibraryItemsProvider);
final scrollController = useScrollController();
return Scaffold(
appBar: AppBar(
title: GestureDetector(
child: const Text('Vaani'),
child: Text(appBarTitle),
onTap: () {
// scroll to the top of the page
scrollController.animateTo(
@ -40,34 +56,57 @@ class LibraryPage extends HookConsumerWidget {
ref.invalidate(personalizedViewProvider);
},
),
leading: IconButton(
icon: Icon(libraryIconData),
tooltip:
S.of(context).librarySwitchTooltip, // Helpful tooltip for users
onPressed: () {
showLibrarySwitcher(context, ref);
},
),
drawer: const MyDrawer(),
body: Container(
actions: [
IconButton(
icon: Icon(Icons.refresh),
tooltip: '刷新', // Helpful tooltip for users
onPressed: () {
return ref.refresh(currentLibraryItemsProvider);
},
),
IconButton(
icon: Icon(Icons.download),
tooltip: S.of(context).bookDownloads, // Helpful tooltip for users
onPressed: () {
GoRouter.of(context).pushNamed(Routes.downloads.name);
},
),
],
),
// drawer: const MyDrawer(),
body: RefreshIndicator(
onRefresh: () async {
return ref.refresh(currentLibraryItemsProvider);
},
child: views.when(
data: (data) {
final shelvesToDisplay = data
// .where((element) => !element.id.contains('discover'))
.map((shelf) {
appLogger.fine('building shelf ${shelf.label}');
return HomeShelf(
title: shelf.label,
shelf: shelf,
);
}).toList();
return RefreshIndicator(
onRefresh: () async {
return ref.refresh(personalizedViewProvider);
},
child: ListView.separated(
itemBuilder: (context, index) => shelvesToDisplay[index],
separatorBuilder: (context, index) => Divider(
color: Theme.of(context).dividerColor.withValues(alpha: 0.1),
indent: 16,
endIndent: 16,
),
itemCount: shelvesToDisplay.length,
return LayoutBuilder(
builder: (context, constraints) {
final height = getDefaultHeight(context);
// final height = min(constraints.maxHeight, 500.0);
final width = height * 0.75;
return AlignedGridView.count(
crossAxisCount: constraints.maxWidth ~/ width,
mainAxisSpacing: 12,
crossAxisSpacing: 12,
padding: EdgeInsets.only(top: 0, left: 8, right: 8),
itemCount: data.length,
controller: scrollController,
),
itemBuilder: (context, index) {
return LibraryPageItem(
item: data[index],
);
},
);
},
);
},
loading: () => const LibraryPageSkeleton(),
@ -78,8 +117,27 @@ class LibraryPage extends HookConsumerWidget {
),
);
}
double getDefaultHeight(
BuildContext context, {
bool ignoreWidth = false,
atMin = 150.0,
perCent = 0.3,
}) {
double referenceSide;
if (ignoreWidth) {
referenceSide = MediaQuery.of(context).size.height;
} else {
referenceSide = min(
MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height,
);
}
return max(atMin, referenceSide * perCent);
}
}
//
class LibraryPageSkeleton extends StatelessWidget {
const LibraryPageSkeleton({super.key});
@ -92,3 +150,72 @@ class LibraryPageSkeleton extends StatelessWidget {
);
}
}
class LibraryPageItem extends HookConsumerWidget {
const LibraryPageItem({
super.key,
required this.item,
});
final LibraryItem item;
@override
Widget build(BuildContext context, WidgetRef ref) {
final book = item.media.asBookMinified;
final metadata = book.metadata.asBookMetadataMinified;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BookCoverWidget(itemId: item.id),
const SizedBox(height: 3),
Text(
metadata.title ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyLarge,
),
const SizedBox(height: 3),
Text(
metadata.authorName ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall,
),
],
);
}
}
class BookCoverWidget extends HookConsumerWidget {
const BookCoverWidget({
super.key,
required this.itemId,
});
final String itemId;
@override
Widget build(BuildContext context, WidgetRef ref) {
final coverImage = ref.watch(coverImageProvider(itemId));
return coverImage.when(
data: (image) {
// return const BookCoverSkeleton();
if (image.isEmpty) {
return const Icon(Icons.error);
}
return Image.memory(
image,
fit: BoxFit.cover,
);
},
loading: () {
return const Center(
child: BookCoverSkeleton(),
);
},
error: (error, stack) {
return const Center(child: Icon(Icons.error));
},
);
}
}

View file

@ -13,7 +13,7 @@ class Routes {
);
static const library = _SimpleRoute(
pathName: 'library',
pathParamName: 'libraryId',
// pathParamName: 'libraryId',
name: 'library',
);
static const libraryItem = _SimpleRoute(

View file

@ -19,6 +19,7 @@ import 'package:vaani/features/you/view/server_manager.dart';
import 'package:vaani/features/you/view/you_page.dart';
import 'package:vaani/globals.dart';
import 'package:vaani/pages/home_page.dart';
import 'package:vaani/pages/library_page.dart';
import 'package:vaani/pages/player_page.dart';
import 'scaffold_with_nav_bar.dart';
@ -118,10 +119,15 @@ class MyAppRouter {
// Library page
StatefulShellBranch(
routes: <RouteBase>[
// GoRoute(
// path: Routes.libraryBrowser.localPath,
// name: Routes.libraryBrowser.name,
// pageBuilder: defaultPageBuilder(const LibraryBrowserPage()),
// ),
GoRoute(
path: Routes.libraryBrowser.localPath,
name: Routes.libraryBrowser.name,
pageBuilder: defaultPageBuilder(const LibraryBrowserPage()),
path: Routes.library.localPath,
name: Routes.library.name,
pageBuilder: defaultPageBuilder(const LibraryPage()),
),
],
),

View file

@ -568,6 +568,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.3"
flutter_staggered_grid_view:
dependency: "direct main"
description:
name: flutter_staggered_grid_view
sha256: "19e7abb550c96fbfeb546b23f3ff356ee7c59a019a651f8f102a4ba9b7349395"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
flutter_svg:
dependency: transitive
description:

View file

@ -44,6 +44,7 @@ dependencies:
collection: ^1.18.0
cupertino_icons: ^1.0.6
flutter_platform_widgets: ^9.0.0
flutter_staggered_grid_view: ^0.7.0
device_info_plus: ^11.3.3
duration_picker: ^1.2.0
dynamic_color: ^1.7.0