generated from dellevin/template
46 lines
1.1 KiB
Dart
46 lines
1.1 KiB
Dart
part of '../reader_screen.dart';
|
|
|
|
mixin _ProgressMixin on State<ReaderScreen> {
|
|
// === Borrowed state (provided by _ReaderScreenState fields) ===
|
|
int get totalPagesInChapter;
|
|
|
|
int get currentPageInChapter;
|
|
|
|
int get currentSpineItemIndex;
|
|
|
|
BookSession get bookSession;
|
|
|
|
bool get isWebViewLoading;
|
|
|
|
String get displayProgress;
|
|
set displayProgress(String v);
|
|
|
|
Timer? get progressDebouncer;
|
|
set progressDebouncer(Timer? v);
|
|
|
|
void updateProgressDebounced() {
|
|
progressDebouncer?.cancel();
|
|
progressDebouncer = Timer(const Duration(milliseconds: 150), () {
|
|
if (!mounted) return;
|
|
if (isWebViewLoading) return;
|
|
|
|
final pageInChapterStr =
|
|
'${currentPageInChapter + 1}/$totalPagesInChapter';
|
|
|
|
if (displayProgress != pageInChapterStr) {
|
|
setState(() {
|
|
displayProgress = pageInChapterStr;
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
void saveProgress() {
|
|
bookSession.saveProgress(
|
|
currentChapterIndex: currentSpineItemIndex,
|
|
currentPageInChapter: currentPageInChapter,
|
|
totalPagesInChapter: totalPagesInChapter,
|
|
);
|
|
}
|
|
}
|