feat: add updatePageCropImage method for chapter page cropping

This commit is contained in:
Moustapha Kodjo Amadou 2025-12-18 17:03:06 +01:00
parent 76645d97c1
commit 19a051b660
3 changed files with 15 additions and 6 deletions

View file

@ -192,6 +192,14 @@ class ChapterPreloadManager {
return true;
}
/// Updates the cropImage for a page at the given index.
void updatePageCropImage(int index, Uint8List? cropImage) {
if (index >= 0 && index < _pages.length) {
_pages[index].cropImage = cropImage;
onPagesUpdated?.call();
}
}
/// Gets a unique identifier for a chapter.
String? _getChapterIdentifier(Chapter? chapter) {
if (chapter == null) return null;

View file

@ -86,6 +86,11 @@ mixin ReaderMemoryManagement {
return _preloadManager.addLastChapterTransition(chapter);
}
/// Updates the cropImage for a page at the given index.
void updatePageCropImage(int index, Uint8List? cropImage) {
_preloadManager.updatePageCropImage(index, cropImage);
}
/// Disposes the preload manager and clears all cached data.
Future<void> disposePreloadManager() async {
if (!_isPreloadManagerInitialized) return;

View file

@ -1207,9 +1207,7 @@ class _MangaChapterPageGalleryState
cropBordersProvider(data: pages[index], cropBorder: true).future,
);
if (mounted) {
setState(() {
pages[index] = pages[index]..cropImage = value;
});
updatePageCropImage(index, value);
}
}
}
@ -1225,9 +1223,7 @@ class _MangaChapterPageGalleryState
cropBordersProvider(data: pages[i], cropBorder: true).future,
);
if (mounted) {
setState(() {
pages[i] = pages[i]..cropImage = value;
});
updatePageCropImage(i, value);
}
}
}