A cross platform Audiobookshelf client for Android and iOS
Dart
Fix desktop playback times and clean up the book editor layout
Barnabasdd55c4173486
diff --git a/lib/screens/book_edit_screen.dart b/lib/screens/book_edit_screen.dartindex a6b5ca32..3d564bab 100644--- a/lib/screens/book_edit_screen.dart+++ b/lib/screens/book_edit_screen.dart@@ -1,5 +1,6 @@import 'package:flutter/material.dart';import '../l10n/app_localizations.dart';+import '../widgets/desktop_page_body.dart';import '../widgets/edit_metadata_sheet.dart';/// Full-screen unified per-book editor. Thin wrapper that hosts@@ -49,17 +50,20 @@ class BookEditScreen extends StatelessWidget {],),),- body: MetadataEditView(- itemId: itemId,- bookTitle: bookTitle,- metadata: metadata,- tags: tags,- audioFiles: audioFiles,- libraryFiles: libraryFiles,- relPath: relPath,- isEbookOnly: isEbookOnly,- isAdmin: isAdmin,- libraryId: libraryId,+ body: DesktopPageBody(+ maxWidth: 960,+ child: MetadataEditView(+ itemId: itemId,+ bookTitle: bookTitle,+ metadata: metadata,+ tags: tags,+ audioFiles: audioFiles,+ libraryFiles: libraryFiles,+ relPath: relPath,+ isEbookOnly: isEbookOnly,+ isAdmin: isAdmin,+ libraryId: libraryId,+ ),),);}diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dartindex a56caf09..2aed0a20 100644--- a/lib/widgets/absorbing_card.dart+++ b/lib/widgets/absorbing_card.dart@@ -1479,6 +1479,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCliiconsOnly: _iconsOnly,moreInline: _moreInline,buttonOrder: _buttonOrder,+ showChaptersAction: widget.presentation != AbsorbingCardPresentation.desktop,removeFromAbsorbing: _removeFromAbsorbing,onReorder: (newOrder, newCount) {setState(() { _buttonOrder = newOrder; _buttonVisibleCount = newCount; });diff --git a/lib/widgets/card_buttons.dart b/lib/widgets/card_buttons.dartindex b5c51711..ec0e7fd1 100644--- a/lib/widgets/card_buttons.dart+++ b/lib/widgets/card_buttons.dart@@ -1384,6 +1384,7 @@ class CardActionDelegate {final bool iconsOnly;final bool moreInline;final List<String> buttonOrder;+ final bool showChaptersAction;final VoidCallback removeFromAbsorbing;final VoidCallback? onRemoveExtra;final void Function(List<String>, int) onReorder;@@ -1413,6 +1414,7 @@ class CardActionDelegate {this.iconsOnly = false,this.moreInline = false,required this.buttonOrder,+ this.showChaptersAction = true,required this.removeFromAbsorbing,this.onRemoveExtra,required this.onReorder,@@ -1437,7 +1439,10 @@ class CardActionDelegate {List<Widget> buildButtonGrid(Color accent, TextTheme tt) {final count = visibleButtonCount;- final ids = buttonOrder.take(count).toList();+ final ids = buttonOrder+ .take(count)+ .where((id) => showChaptersAction || id != 'chapters')+ .toList();final n = ids.length;if (n == 0) return [];@@ -1835,7 +1840,10 @@ class CardActionDelegate {void showMoreMenu(Color accent, TextTheme tt) {final count = visibleButtonCount;- final overflowIds = buttonOrder.skip(count).where((id) => id != '_more').toList();+ final overflowIds = buttonOrder+ .skip(count)+ .where((id) => id != '_more' && (showChaptersAction || id != 'chapters'))+ .toList();showAdaptiveActionMenu(context: context,desktopWidth: 520,diff --git a/lib/widgets/desktop_now_playing_bar.dart b/lib/widgets/desktop_now_playing_bar.dartindex afbf9429..8f5e7e8b 100644--- a/lib/widgets/desktop_now_playing_bar.dart+++ b/lib/widgets/desktop_now_playing_bar.dart@@ -33,6 +33,7 @@ class _DesktopNowPlayingBarState extends State<DesktopNowPlayingBar> {List<double> _speedPresets = List<double>.from(PlayerSettings.defaultSpeedPresets,);+ bool _speedAdjustedTime = true;String? _lastItemId;String? _lastLibraryId;double? _dragPositionSeconds;@@ -90,12 +91,14 @@ class _DesktopNowPlayingBarState extends State<DesktopNowPlayingBar> {PlayerSettings.getEffectiveBackSkip(libraryId: libraryId),PlayerSettings.getEffectiveForwardSkip(libraryId: libraryId),PlayerSettings.getSpeedPresets(),+ PlayerSettings.getSpeedAdjustedTime(),]);if (!mounted) return;setState(() {_backSkip = results[0] as int;_forwardSkip = results[1] as int;_speedPresets = results[2] as List<double>;+ _speedAdjustedTime = results[3] as bool;});}@@ -146,6 +149,7 @@ class _DesktopNowPlayingBarState extends State<DesktopNowPlayingBar> {return _PositionControl(positionSeconds: positionSeconds,totalSeconds: totalSeconds,+ displaySpeed: _speedAdjustedTime ? player.speed : 1.0,enabled: totalSeconds > 0,accent: cs.primary,onChangeStart: (value) {@@ -403,6 +407,7 @@ class _DesktopNowPlayingBarState extends State<DesktopNowPlayingBar> {class _PositionControl extends StatelessWidget {final double positionSeconds;final double totalSeconds;+ final double displaySpeed;final bool enabled;final Color accent;final ValueChanged<double> onChangeStart;@@ -412,6 +417,7 @@ class _PositionControl extends StatelessWidget {const _PositionControl({required this.positionSeconds,required this.totalSeconds,+ required this.displaySpeed,required this.enabled,required this.accent,required this.onChangeStart,@@ -426,6 +432,12 @@ class _PositionControl extends StatelessWidget {final max = enabled ? totalSeconds : 1.0;final value = enabled ? positionSeconds.clamp(0.0, max).toDouble() : 0.0;final remaining = enabled ? totalSeconds - value : 0.0;+ final speed = displaySpeed.isFinite && displaySpeed > 0+ ? displaySpeed+ : 1.0;+ final displayValue = value / speed;+ final displayRemaining = remaining / speed;+ final displayTotal = totalSeconds / speed;final timeStyle = tt.labelSmall?.copyWith(color: cs.onSurfaceVariant,fontSize: 10,@@ -438,7 +450,8 @@ class _PositionControl extends StatelessWidget {SizedBox(width: 50,child: Text(- _formatTime(value),+ _formatTime(displayValue),+ key: const ValueKey('desktop-now-playing-elapsed'),textAlign: TextAlign.right,style: timeStyle,),@@ -460,13 +473,17 @@ class _PositionControl extends StatelessWidget {onChanged: enabled ? onChanged : null,onChangeEnd: enabled ? onChangeEnd : null,semanticFormatterCallback: (value) =>- '${_formatTime(value)} of ${_formatTime(totalSeconds)}',+ '${_formatTime(value / speed)} of ${_formatTime(displayTotal)}',),),),SizedBox(width: 50,- child: Text('-${_formatTime(remaining)}', style: timeStyle),+ child: Text(+ '-${_formatTime(displayRemaining)}',+ key: const ValueKey('desktop-now-playing-remaining'),+ style: timeStyle,+ ),),const SizedBox(width: 12),],diff --git a/lib/widgets/edit_metadata_sheet.dart b/lib/widgets/edit_metadata_sheet.dartindex a900aabc..867a092c 100644--- a/lib/widgets/edit_metadata_sheet.dart+++ b/lib/widgets/edit_metadata_sheet.dart@@ -12,6 +12,8 @@ import 'overlay_toast.dart';enum _ETab { details, cover, chapters, match, encode, embed }+const double _metadataDetailsWideBreakpoint = 700;+/// The unified per-book editor body: one swipeable tab bar over Details, Cover,/// Chapters, Match and Encode (in Audiobookshelf web order). Hosted full-screen/// by BookEditScreen. The Chapters tab embeds [ChapterEditBody]; the rest are@@ -20,6 +22,7 @@ enum _ETab { details, cover, chapters, match, encode, embed }class MetadataEditView extends StatefulWidget {static const quickMatchButtonKey = Key('metadataQuickMatchButton');static const filePathsSectionKey = Key('metadataFilePathsSection');+ static const descriptionFieldKey = Key('metadataDescriptionField');final String itemId;final String bookTitle;@@ -1312,6 +1315,17 @@ class _MetadataEditViewState extends State<MetadataEditView>// ─── Custom Tab ─────────────────────────────────────────────Widget _buildCustomTab(ColorScheme cs, TextTheme tt, AppLocalizations l) {+ return LayoutBuilder(+ builder: (context, constraints) => _buildCustomTabLayout(+ cs,+ tt,+ l,+ wide: constraints.maxWidth >= _metadataDetailsWideBreakpoint,+ ),+ );+ }++ Widget _buildCustomTabLayout(ColorScheme cs, TextTheme tt, AppLocalizations l, {required bool wide}) {final filePaths = fullLibraryFilePaths(widget.libraryFiles);return Column(children: [// Save button bar@@ -1347,10 +1361,23 @@ class _MetadataEditViewState extends State<MetadataEditView>controller: _detailsScroll,padding: EdgeInsets.fromLTRB(20, 8, 20, 32 + MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).viewPadding.bottom),children: [- _field(l.titleLabel, _titleCtrl, tt),- _field(l.subtitleLabel, _subtitleCtrl, tt),- _field(l.authorLabel, _authorCtrl, tt),- _field(l.narratorLabel, _narratorCtrl, tt),+ if (wide) ...[+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Expanded(child: _field(l.titleLabel, _titleCtrl, tt)),+ const SizedBox(width: 16),+ Expanded(child: _field(l.subtitleLabel, _subtitleCtrl, tt)),+ ]),+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Expanded(child: _field(l.authorLabel, _authorCtrl, tt)),+ const SizedBox(width: 16),+ Expanded(child: _field(l.narratorLabel, _narratorCtrl, tt)),+ ]),+ ] else ...[+ _field(l.titleLabel, _titleCtrl, tt),+ _field(l.subtitleLabel, _subtitleCtrl, tt),+ _field(l.authorLabel, _authorCtrl, tt),+ _field(l.narratorLabel, _narratorCtrl, tt),+ ],for (int i = 0; i < _seriesRows.length; i++) ...[Row(crossAxisAlignment: CrossAxisAlignment.start, children: [Expanded(child: _field(l.seriesLabel, _seriesRows[i].name, tt)),@@ -1390,13 +1417,30 @@ class _MetadataEditViewState extends State<MetadataEditView>),),),- _field(l.descriptionLabel, _descCtrl, tt, maxLines: 5),- _field(l.publisherLabel, _publisherCtrl, tt),- Row(children: [- Expanded(child: _field(l.yearLabel, _yearCtrl, tt, keyboardType: TextInputType.number)),- const SizedBox(width: 12),- Expanded(child: _field(l.languageLabel, _languageCtrl, tt)),- ]),+ _field(+ l.descriptionLabel,+ _descCtrl,+ tt,+ maxLines: wide ? null : 5,+ minLines: wide ? 10 : null,+ fieldKey: MetadataEditView.descriptionFieldKey,+ ),+ if (wide)+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Expanded(flex: 2, child: _field(l.publisherLabel, _publisherCtrl, tt)),+ const SizedBox(width: 16),+ Expanded(child: _field(l.yearLabel, _yearCtrl, tt, keyboardType: TextInputType.number)),+ const SizedBox(width: 16),+ Expanded(child: _field(l.languageLabel, _languageCtrl, tt)),+ ])+ else ...[+ _field(l.publisherLabel, _publisherCtrl, tt),+ Row(children: [+ Expanded(child: _field(l.yearLabel, _yearCtrl, tt, keyboardType: TextInputType.number)),+ const SizedBox(width: 12),+ Expanded(child: _field(l.languageLabel, _languageCtrl, tt)),+ ]),+ ],_field(l.genresLabel, _genresCtrl, tt, hint: l.commaSeparated),_suggestionChips(_genresCtrl, _allGenres, multi: true),_field(l.tagsLabel, _tagsCtrl, tt, hint: l.commaSeparated),@@ -1448,7 +1492,6 @@ class _MetadataEditViewState extends State<MetadataEditView>color: cs.onSurfaceVariant, height: 1.35)),),],-],),),@@ -1775,12 +1818,14 @@ class _MetadataEditViewState extends State<MetadataEditView>}}- Widget _field(String label, TextEditingController ctrl, TextTheme tt, {int maxLines = 1, String? hint, TextInputType? keyboardType}) {+ Widget _field(String label, TextEditingController ctrl, TextTheme tt, {int? maxLines = 1, int? minLines, String? hint, TextInputType? keyboardType, Key? fieldKey}) {return Padding(padding: const EdgeInsets.only(bottom: 12),child: TextField(+ key: fieldKey,controller: ctrl,maxLines: maxLines,+ minLines: minLines,keyboardType: keyboardType,decoration: InputDecoration(labelText: label,