mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Do not switch chapters if the current chapter is the first or last chapter in the chapter group.
This commit is contained in:
@@ -381,7 +381,7 @@ class ComicChapters {
|
||||
return _groupedChapters!.values.elementAt(index);
|
||||
}
|
||||
|
||||
/// Get a chapter by index
|
||||
/// Get total number of chapters
|
||||
int get length {
|
||||
return isGrouped
|
||||
? _groupedChapters!.values.map((e) => e.length).reduce((a, b) => a + b)
|
||||
|
@@ -131,11 +131,11 @@ class _ReaderGestureDetectorState extends AutomaticGlobalState<_ReaderGestureDet
|
||||
}
|
||||
if (context.reader.mode.key.startsWith('gallery')) {
|
||||
if (forward) {
|
||||
if (!context.reader.toNextPage()) {
|
||||
if (!context.reader.toNextPage() && !context.reader.isLastChapterOfGroup) {
|
||||
context.reader.toNextChapter();
|
||||
}
|
||||
} else {
|
||||
if (!context.reader.toPrevPage()) {
|
||||
if (!context.reader.toPrevPage() && !context.reader.isFirstChapterOfGroup) {
|
||||
context.reader.toPrevChapter();
|
||||
}
|
||||
}
|
||||
|
@@ -206,11 +206,11 @@ class _GalleryModeState extends State<_GalleryMode>
|
||||
),
|
||||
onPageChanged: (i) {
|
||||
if (i == 0) {
|
||||
if (!reader.toPrevChapter()) {
|
||||
if (reader.isFirstChapterOfGroup || !reader.toPrevChapter()) {
|
||||
reader.toPage(1);
|
||||
}
|
||||
} else if (i == totalPages + 1) {
|
||||
if (!reader.toNextChapter()) {
|
||||
if (reader.isLastChapterOfGroup || !reader.toNextChapter()) {
|
||||
reader.toPage(totalPages);
|
||||
}
|
||||
} else {
|
||||
@@ -575,15 +575,14 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
||||
}
|
||||
|
||||
if (notification is ScrollUpdateNotification) {
|
||||
var length = reader.maxChapter;
|
||||
if (!scrollController.hasClients) return false;
|
||||
if (scrollController.position.pixels <=
|
||||
scrollController.position.minScrollExtent &&
|
||||
reader.chapter != 1) {
|
||||
!reader.isFirstChapterOfGroup) {
|
||||
context.readerScaffold.setFloatingButton(-1);
|
||||
} else if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent &&
|
||||
reader.chapter < length) {
|
||||
!reader.isLastChapterOfGroup) {
|
||||
context.readerScaffold.setFloatingButton(1);
|
||||
} else {
|
||||
context.readerScaffold.setFloatingButton(0);
|
||||
|
@@ -265,6 +265,40 @@ class _ReaderState extends State<Reader>
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bool get isFirstChapterOfGroup {
|
||||
if (widget.chapters?.isGrouped ?? false) {
|
||||
int c = chapter - 1;
|
||||
int g = 1;
|
||||
while (c > 0) {
|
||||
c -= widget.chapters!.getGroupByIndex(g - 1).length;
|
||||
g++;
|
||||
}
|
||||
if (c == 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return chapter == 1;
|
||||
}
|
||||
|
||||
bool get isLastChapterOfGroup {
|
||||
if (widget.chapters?.isGrouped ?? false) {
|
||||
int c = chapter;
|
||||
int g = 1;
|
||||
while (c > 0) {
|
||||
c -= widget.chapters!.getGroupByIndex(g - 1).length;
|
||||
g++;
|
||||
}
|
||||
if (c == 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return chapter == maxChapter;
|
||||
}
|
||||
}
|
||||
|
||||
abstract mixin class _ImagePerPageHandler {
|
||||
|
Reference in New Issue
Block a user