Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Merge main into lyrics-mode

Barnabas336f5e4ff129
diff --cc lib/widgets/ebook_reader_view.dart
index cf239aac,5376dc44..686467a0
--- a/lib/widgets/ebook_reader_view.dart
+++ b/lib/widgets/ebook_reader_view.dart
@@@ -20,9 -20,7 +20,10 @@@ import '../services/find_in_ebook.dart'
import '../services/progress_sync_service.dart';
import '../services/reader_font_service.dart';
import '../services/scoped_prefs.dart';
+import '../services/lyrics_service.dart';
+import '../services/read_along_script.dart';
+ import '../services/screen_wake.dart';
+import '../services/transcript_line_store.dart';
import '../services/transcription_service.dart';
import '../services/volume_key_service.dart';
import 'overlay_toast.dart';
@@@ -267,12 -253,14 +278,15 @@@ class EbookReaderViewState extends Stat
_bgCfi = null;
_bgDrifted = false;
if (drifted && cfi != null && cfi.isNotEmpty) {
- Future.delayed(const Duration(milliseconds: 350), () {
- if (mounted && _readerActive) _epubController?.display(cfi: cfi);
+ Future.delayed(const Duration(milliseconds: 350), () async {
+ if (!mounted || !_readerActive) return;
+ await _epubController?.display(cfi: cfi);
+ // The live page moved under the blind; re-seat it on the page after.
+ if (_autoScroll) await _epubController?.autoScrollResync();
});
}
- } else {
+ } else if (state == AppLifecycleState.paused ||
+ state == AppLifecycleState.hidden) {
// Leaving the foreground: snapshot the real page and stop trusting
// relocations until we're back (they'll be resize artifacts).
if (_readerActive) _bgCfi = _currentCfi;
@@@ -535,7 -526,11 +561,12 @@@
@override
void dispose() {
+ _stopReadAlong();
+ _speedToast?.dismiss();
+ if (_autoScroll) {
+ _epubController?.autoScrollStop();
+ ScreenWake.keepOn(false);
+ }
_quietLib.setReaderQuiet(false);
WidgetsBinding.instance.removeObserver(this);
_volumeNav.detach();
@@@ -2300,10 -2431,19 +2470,19 @@@
),
);
if (go != true || !mounted) return;
- await PlayerSettings.setFindInAudiobookGoToPlayer(goToPlayer);
+ await PlayerSettings.setFindInAudiobookAfter(after);
if (!mounted) return;
- showProgressDialog(context, l.findInAudiobookSearching);
+ final status = ValueNotifier<String>(l.findInAudiobookSearching);
+ showProgressDialogListenable(context, status);
+ // A long chapter can take a dozen ten-second probes; say so rather than
+ // spin in silence.
+ final slowTimer = Timer(const Duration(seconds: 10), () {
+ status.value = l.findInAudiobookStillSearching;
+ });
+ final longTimer = Timer(const Duration(seconds: 35), () {
+ status.value = l.findInAudiobookSearchingLong;
+ });
double? targetTime;
try {
targetTime = await _locateAudioForSelection(cfi, selText);
@@@ -4028,45 -3956,67 +4389,81 @@@
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
+ if (_readAlongOn)
+ Padding(
+ padding: const EdgeInsets.only(bottom: 6),
+ child: Center(child: _readAlongSyncPill(fg)),
+ ),
- _buildMediaBar(fg, accent),
- ClipRRect(
- borderRadius: BorderRadius.circular(2),
- child: LinearProgressIndicator(
- value: _progress.clamp(0.0, 1.0),
- minHeight: 3,
- backgroundColor: fg.withValues(alpha: 0.1),
- valueColor: AlwaysStoppedAnimation(accent),
- ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: _buildMediaBar(fg, accent),
),
- const SizedBox(height: 4),
+ // Equal cells: on a narrow phone they shrink below
+ // the buttons' 48dp instead of overflowing the row.
Row(
children: [
- if (_chapterPageTotal > 0)
- Text(
- '$_chapterPage / $_chapterPageTotal',
- style: TextStyle(color: fgDim, fontSize: 11),
+ Expanded(
+ child: IconButton(
+ icon: Icon(Icons.arrow_back_rounded, color: fg),
+ onPressed: _handleClose,
),
+ ),
Expanded(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: Text(
- _currentChapterTitle ?? '',
- textAlign: TextAlign.center,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(color: fgDim, fontSize: 11),
+ child: IconButton(
+ icon: Icon(
+ _hasBookmarkAtCurrent
+ ? Icons.bookmark_rounded
+ : Icons.bookmark_border_rounded,
+ color: _hasBookmarkAtCurrent ? accent : fg,
),
+ onPressed: _toggleBookmark,
),
),
- Text(
- '${(_progress * 100).toStringAsFixed(1)}%',
- style: TextStyle(color: fgDim, fontSize: 11),
+ Expanded(
+ child: IconButton(
+ icon: Icon(Icons.search_rounded, color: fg),
+ tooltip: AppLocalizations.of(context)!.readerTooltipSearch,
+ onPressed: _openSearchScreen,
+ ),
+ ),
++ if (_transcriptionOn)
++ Expanded(
++ child: IconButton(
++ icon: Icon(Icons.graphic_eq_rounded,
++ color: _readAlongOn ? accent : fg),
++ tooltip: AppLocalizations.of(context)!.readAlong,
++ onPressed: _toggleReadAlong,
++ ),
++ ),
+ Expanded(
+ child: IconButton(
+ icon: Icon(Icons.sticky_note_2_outlined, color: fg),
+ onPressed: _showAnnotationsSheet,
+ ),
),
+ Expanded(
+ child: IconButton(
+ icon: Icon(
+ Icons.swap_vert_rounded,
+ color: _autoScroll ? accent : fg,
+ ),
+ tooltip: AppLocalizations.of(context)!.readerAutoScroll,
+ onPressed: _toggleAutoScroll,
+ ),
+ ),
+ Expanded(
+ child: IconButton(
+ icon: Icon(Icons.text_fields_rounded, color: fg),
+ onPressed: _showSettingsSheet,
+ ),
+ ),
+ if (_chapters.isNotEmpty)
+ Expanded(
+ child: IconButton(
+ icon: Icon(Icons.list_rounded, color: fg),
+ onPressed: _showChapterList,
+ ),
+ ),
],
),
],