A cross platform Audiobookshelf client for Android and iOS
Dart
Fix the bookmark and clip export sheets: buttons now clear the nav bar, Save is the main button, and the clip preview stops at the end mark
Barnabas81ca812d96c4
diff --git a/lib/services/clip_editor_controller.dart b/lib/services/clip_editor_controller.dartindex f0b76d02..6a412fdf 100644--- a/lib/services/clip_editor_controller.dart+++ b/lib/services/clip_editor_controller.dart@@ -97,11 +97,12 @@ class ClipEditorController extends ChangeNotifier {_posSub = player.positionStream.listen((d) {if (_disposed) return;_position = _trackBase + d.inMilliseconds / 1000.0;- // Free-play to the window end (not the out point) so the user can hear- // past where they think the clip ends and place the out mark by ear.- if (_playing && _position >= _winEnd) {+ // Stop at the out point so the preview ends exactly where the clip does+ // and you can hear where it stops.+ if (_playing && _position >= _outPoint) {player.pause();- player.seek(Duration(milliseconds: ((_winEnd - _trackBase) * 1000).round()));+ _position = _outPoint;+ player.seek(Duration(milliseconds: ((_outPoint - _trackBase) * 1000).round()));}notifyListeners();});@@ -130,12 +131,23 @@ class ClipEditorController extends ChangeNotifier {if (p.playing) {await p.pause();} else {- // Replaying from the window end restarts at the in point.- if (_position >= _winEnd - 0.1) await seekToGlobal(_inPoint);+ // Once it's stopped at the out point, play restarts the clip from the in point.+ if (_position >= _outPoint - 0.1) await seekToGlobal(_inPoint);await p.play();}}+ /// Audition just the tail of the clip: jump a few seconds before the out+ /// point and play through to it. Playback stops at the out point, so this is+ /// the quick way to fine-tune where the clip ends.+ Future<void> previewEnd() async {+ final p = _player;+ if (p == null) return;+ final from = (_outPoint - 4).clamp(_inPoint, _outPoint);+ await seekToGlobal(from);+ await p.play();+ }+Future<void> seekToGlobal(double global) async {final p = _player;if (p == null) return;diff --git a/lib/widgets/bookmark_detail_dialog.dart b/lib/widgets/bookmark_detail_dialog.dartindex 679a9b92..8774e69f 100644--- a/lib/widgets/bookmark_detail_dialog.dart+++ b/lib/widgets/bookmark_detail_dialog.dart@@ -202,12 +202,18 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {final l = AppLocalizations.of(context)!;final tt = Theme.of(context).textTheme;final cs = Theme.of(context).colorScheme;+ final mq = MediaQuery.of(context);+ // Clear the keyboard when it's open, otherwise the system navigation bar+ // (3-button mode) so the buttons aren't hidden behind it.+ final bottomInset = mq.viewInsets.bottom > mq.viewPadding.bottom+ ? mq.viewInsets.bottom+ : mq.viewPadding.bottom;return Padding(padding: EdgeInsets.only(left: 20,right: 20,top: 4,- bottom: 20 + MediaQuery.of(context).viewInsets.bottom,+ bottom: 20 + bottomInset,),child: SingleChildScrollView(child: Column(@@ -302,16 +308,18 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {child: Text(l.bookmarksScreenClose),),const SizedBox(width: 8),- TextButton(+ // Jump is the secondary action; Save is the prominent primary+ // (rightmost, filled) so it's not easy to hit Jump by mistake.+ OutlinedButton(onPressed: _saving? null: () async {await _persist();if (mounted) {- Navigator.pop(context, (action: 'saved', position: _seconds));+ Navigator.pop(context, (action: 'jump', position: _seconds));}},- child: Text(l.save),+ child: Text(l.bookmarksJump),),const SizedBox(width: 8),FilledButton(@@ -320,10 +328,10 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {: () async {await _persist();if (mounted) {- Navigator.pop(context, (action: 'jump', position: _seconds));+ Navigator.pop(context, (action: 'saved', position: _seconds));}},- child: Text(l.bookmarksJump),+ child: Text(l.save),),],),diff --git a/lib/widgets/clip_editor_sheet.dart b/lib/widgets/clip_editor_sheet.dartindex 121dce5e..229c6b9c 100644--- a/lib/widgets/clip_editor_sheet.dart+++ b/lib/widgets/clip_editor_sheet.dart@@ -139,12 +139,18 @@ class _ClipEditorSheetState extends State<ClipEditorSheet> {final l = AppLocalizations.of(context)!;final tt = Theme.of(context).textTheme;final cs = Theme.of(context).colorScheme;+ final mq = MediaQuery.of(context);+ // Clear the keyboard when it's open, otherwise the system navigation bar+ // (3-button mode) so the buttons aren't hidden behind it.+ final bottomInset = mq.viewInsets.bottom > mq.viewPadding.bottom+ ? mq.viewInsets.bottom+ : mq.viewPadding.bottom;return Padding(padding: EdgeInsets.only(left: 20,right: 20,top: 4,- bottom: 20 + MediaQuery.of(context).viewInsets.bottom,+ bottom: 20 + bottomInset,),child: Column(mainAxisSize: MainAxisSize.min,@@ -242,7 +248,14 @@ class _ClipEditorSheetState extends State<ClipEditorSheet> {),],),- const SizedBox(height: 20),+ Center(+ child: TextButton.icon(+ icon: const Icon(Icons.play_circle_outline_rounded, size: 18),+ label: const Text('Preview ending'),+ onPressed: busy ? null : () => _c.previewEnd(),+ ),+ ),+ const SizedBox(height: 12),Row(children: [Expanded(