mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
格式化代码
This commit is contained in:
parent
a28547685b
commit
b3a9d76c78
24 changed files with 611 additions and 451 deletions
|
|
@ -77,9 +77,11 @@ class LibraryItemActions extends HookConsumerWidget {
|
|||
IconButton(
|
||||
onPressed: () {
|
||||
appLogger.fine('Sharing');
|
||||
var currentServerUrl = apiSettings.activeServer!.serverUrl;
|
||||
var currentServerUrl =
|
||||
apiSettings.activeServer!.serverUrl;
|
||||
if (!currentServerUrl.hasScheme) {
|
||||
currentServerUrl = Uri.https(currentServerUrl.toString());
|
||||
currentServerUrl =
|
||||
Uri.https(currentServerUrl.toString());
|
||||
}
|
||||
handleLaunchUrl(
|
||||
Uri.parse(
|
||||
|
|
@ -138,7 +140,8 @@ class LibraryItemActions extends HookConsumerWidget {
|
|||
FileDownloader()
|
||||
.database
|
||||
.deleteRecordWithId(
|
||||
record.task.taskId,
|
||||
record
|
||||
.task.taskId,
|
||||
);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
|
|
@ -157,7 +160,8 @@ class LibraryItemActions extends HookConsumerWidget {
|
|||
},
|
||||
onTap: () async {
|
||||
// open the file location
|
||||
final didOpen = await FileDownloader().openFile(
|
||||
final didOpen =
|
||||
await FileDownloader().openFile(
|
||||
task: record.task,
|
||||
);
|
||||
|
||||
|
|
@ -226,7 +230,9 @@ class LibItemDownloadButton extends HookConsumerWidget {
|
|||
onPressed: () {
|
||||
appLogger.fine('Pressed download button');
|
||||
|
||||
ref.read(downloadManagerProvider.notifier).queueAudioBookDownload(item);
|
||||
ref
|
||||
.read(downloadManagerProvider.notifier)
|
||||
.queueAudioBookDownload(item);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.download_rounded,
|
||||
|
|
@ -245,7 +251,10 @@ class ItemCurrentlyInDownloadQueue extends HookConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final progress = ref.watch(itemDownloadProgressProvider(item.id)).valueOrNull?.clamp(0.05, 1.0);
|
||||
final progress = ref
|
||||
.watch(itemDownloadProgressProvider(item.id))
|
||||
.valueOrNull
|
||||
?.clamp(0.05, 1.0);
|
||||
|
||||
if (progress == 1) {
|
||||
return AlreadyItemDownloadedButton(item: item);
|
||||
|
|
@ -333,7 +342,7 @@ class DownloadSheet extends HookConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final manager = ref.watch(downloadManagerProvider);
|
||||
// final manager = ref.watch(downloadManagerProvider);
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
@ -377,7 +386,9 @@ class DownloadSheet extends HookConsumerWidget {
|
|||
TextButton(
|
||||
onPressed: () {
|
||||
// delete the file
|
||||
ref.read(downloadManagerProvider.notifier).deleteDownloadedItem(
|
||||
ref
|
||||
.read(downloadManagerProvider.notifier)
|
||||
.deleteDownloadedItem(
|
||||
item,
|
||||
);
|
||||
GoRouter.of(context).pop(true);
|
||||
|
|
@ -396,7 +407,8 @@ class DownloadSheet extends HookConsumerWidget {
|
|||
);
|
||||
|
||||
if (wasDeleted ?? false) {
|
||||
appLogger.fine(S.of(context).deleted(item.media.metadata.title ?? ''));
|
||||
appLogger
|
||||
.fine(S.of(context).deleted(item.media.metadata.title ?? ''));
|
||||
GoRouter.of(context).pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
|
|
@ -520,7 +532,8 @@ Future<void> libraryItemPlayButtonOnPressed({
|
|||
appLogger.info('Setting the book ${book.libraryItemId}');
|
||||
appLogger.info('Initial position: ${userMediaProgress?.currentTime}');
|
||||
final downloadManager = ref.watch(simpleDownloadManagerProvider);
|
||||
final libItem = await ref.read(libraryItemProvider(book.libraryItemId).future);
|
||||
final libItem =
|
||||
await ref.read(libraryItemProvider(book.libraryItemId).future);
|
||||
final downloadedUris = await downloadManager.getDownloadedFilesUri(libItem);
|
||||
setSourceFuture = player.setSourceAudiobook(
|
||||
book,
|
||||
|
|
@ -536,23 +549,27 @@ Future<void> libraryItemPlayButtonOnPressed({
|
|||
}
|
||||
}
|
||||
// set the volume as this is the first time playing and dismissing causes the volume to go to 0
|
||||
var bookPlayerSettings = ref.read(bookSettingsProvider(book.libraryItemId)).playerSettings;
|
||||
var bookPlayerSettings =
|
||||
ref.read(bookSettingsProvider(book.libraryItemId)).playerSettings;
|
||||
var appPlayerSettings = ref.read(appSettingsProvider).playerSettings;
|
||||
|
||||
var configurePlayerForEveryBook = appPlayerSettings.configurePlayerForEveryBook;
|
||||
var configurePlayerForEveryBook =
|
||||
appPlayerSettings.configurePlayerForEveryBook;
|
||||
|
||||
await Future.wait([
|
||||
setSourceFuture ?? Future.value(),
|
||||
// set the volume
|
||||
player.setVolume(
|
||||
configurePlayerForEveryBook
|
||||
? bookPlayerSettings.preferredDefaultVolume ?? appPlayerSettings.preferredDefaultVolume
|
||||
? bookPlayerSettings.preferredDefaultVolume ??
|
||||
appPlayerSettings.preferredDefaultVolume
|
||||
: appPlayerSettings.preferredDefaultVolume,
|
||||
),
|
||||
// set the speed
|
||||
player.setSpeed(
|
||||
configurePlayerForEveryBook
|
||||
? bookPlayerSettings.preferredDefaultSpeed ?? appPlayerSettings.preferredDefaultSpeed
|
||||
? bookPlayerSettings.preferredDefaultSpeed ??
|
||||
appPlayerSettings.preferredDefaultSpeed
|
||||
: appPlayerSettings.preferredDefaultSpeed,
|
||||
),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -25,8 +25,9 @@ class LibraryItemMetadata extends HookConsumerWidget {
|
|||
if (book == null) {
|
||||
return null;
|
||||
}
|
||||
final duration =
|
||||
book.audioFiles.map((e) => e.duration).reduce((value, element) => value + element);
|
||||
final duration = book.audioFiles
|
||||
.map((e) => e.duration)
|
||||
.reduce((value, element) => value + element);
|
||||
final hours = duration.inHours;
|
||||
final minutes = duration.inMinutes.remainder(60);
|
||||
return '${hours}h ${minutes}m';
|
||||
|
|
@ -41,8 +42,9 @@ class LibraryItemMetadata extends HookConsumerWidget {
|
|||
if (book == null) {
|
||||
return null;
|
||||
}
|
||||
final size =
|
||||
book.audioFiles.map((e) => e.metadata.size).reduce((value, element) => value + element);
|
||||
final size = book.audioFiles
|
||||
.map((e) => e.metadata.size)
|
||||
.reduce((value, element) => value + element);
|
||||
if (size / 1024 / 1024 < 1024) {
|
||||
return '${(size / 1024 / 1024).toStringAsFixed(2)} MB';
|
||||
}
|
||||
|
|
@ -98,7 +100,10 @@ class LibraryItemMetadata extends HookConsumerWidget {
|
|||
return VerticalDivider(
|
||||
indent: 6,
|
||||
endIndent: 6,
|
||||
color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withValues(alpha: 0.6),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ class LibraryItemPage extends HookConsumerWidget {
|
|||
static const double _showFabThreshold = 300.0;
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final additionalItemData = extra is LibraryItemExtras ? extra as LibraryItemExtras : null;
|
||||
final additionalItemData =
|
||||
extra is LibraryItemExtras ? extra as LibraryItemExtras : null;
|
||||
final scrollController = useScrollController();
|
||||
final showFab = useState(false);
|
||||
|
||||
|
|
@ -151,7 +152,8 @@ class LibraryItemDescription extends HookConsumerWidget {
|
|||
}
|
||||
return ExpandableDescription(
|
||||
title: S.of(context).bookAbout,
|
||||
content: item.media.metadata.description ?? S.of(context).bookAboutDefault,
|
||||
content:
|
||||
item.media.metadata.description ?? S.of(context).bookAboutDefault,
|
||||
readMoreText: S.of(context).readMore,
|
||||
readLessText: S.of(context).readLess,
|
||||
);
|
||||
|
|
@ -168,8 +170,10 @@ double calculateWidth(
|
|||
/// height ratio of the cover image to the available height
|
||||
double maxHeightToUse = 0.25,
|
||||
}) {
|
||||
final availHeight = min(constraints.maxHeight, MediaQuery.of(context).size.height);
|
||||
final availWidth = min(constraints.maxWidth, MediaQuery.of(context).size.width);
|
||||
final availHeight =
|
||||
min(constraints.maxHeight, MediaQuery.of(context).size.height);
|
||||
final availWidth =
|
||||
min(constraints.maxWidth, MediaQuery.of(context).size.width);
|
||||
|
||||
// make the width widthRatio of the available width
|
||||
var width = availWidth * widthRatio;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue