Improve gesture for continuous mode.

This commit is contained in:
2025-03-22 11:11:20 +08:00
parent 169676fd9e
commit 03628f2afa

View File

@@ -25,8 +25,8 @@ class _ReaderImagesState extends State<_ReaderImages> {
if (inProgress) return; if (inProgress) return;
inProgress = true; inProgress = true;
if (reader.type == ComicType.local || if (reader.type == ComicType.local ||
(LocalManager() (LocalManager().isDownloaded(
.isDownloaded(reader.cid, reader.type, reader.chapter, reader.widget.chapters))) { reader.cid, reader.type, reader.chapter, reader.widget.chapters))) {
try { try {
var images = await LocalManager() var images = await LocalManager()
.getImages(reader.cid, reader.type, reader.chapter); .getImages(reader.cid, reader.type, reader.chapter);
@@ -395,6 +395,8 @@ class _ContinuousModeState extends State<_ContinuousMode>
bool jumpToNextChapter = false; bool jumpToNextChapter = false;
bool jumpToPrevChapter = false; bool jumpToPrevChapter = false;
bool isZoomedIn = false;
@override @override
void initState() { void initState() {
reader = context.reader; reader = context.reader;
@@ -485,6 +487,16 @@ class _ContinuousModeState extends State<_ContinuousMode>
} }
} }
bool onScaleUpdate([double? scale]) {
var isZoomedIn = (scale ?? photoViewController.scale) != 1.0;
if (isZoomedIn != this.isZoomedIn) {
setState(() {
this.isZoomedIn = isZoomedIn;
});
}
return false;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget widget = ScrollablePositionedList.builder( Widget widget = ScrollablePositionedList.builder(
@@ -506,6 +518,8 @@ class _ContinuousModeState extends State<_ContinuousMode>
reverse: reader.mode == ReaderMode.continuousRightToLeft, reverse: reader.mode == ReaderMode.continuousRightToLeft,
physics: isCTRLPressed || _isMouseScrolling || disableScroll physics: isCTRLPressed || _isMouseScrolling || disableScroll
? const NeverScrollableScrollPhysics() ? const NeverScrollableScrollPhysics()
: isZoomedIn
? const ClampingScrollPhysics()
: const BouncingScrollPhysics(), : const BouncingScrollPhysics(),
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (index == 0 || index == reader.maxPage + 1) { if (index == 0 || index == reader.maxPage + 1) {
@@ -593,18 +607,9 @@ class _ContinuousModeState extends State<_ContinuousMode>
if (photoViewController.scale == 1 || fingers != 1) { if (photoViewController.scale == 1 || fingers != 1) {
return; return;
} }
if (scrollController.offset !=
scrollController.position.maxScrollExtent &&
scrollController.offset !=
scrollController.position.minScrollExtent) {
if (reader.mode == ReaderMode.continuousTopToBottom) {
value = Offset(value.dx, 0);
} else {
value = Offset(0, value.dy);
}
}
photoViewController.updateMultiple( photoViewController.updateMultiple(
position: photoViewController.position + value); position: photoViewController.position + Offset(value.dx, value.dy),
);
}, },
onPointerSignal: onPointerSignal, onPointerSignal: onPointerSignal,
child: widget, child: widget,
@@ -676,6 +681,7 @@ class _ContinuousModeState extends State<_ContinuousMode>
maxScale: 2.5, maxScale: 2.5,
strictScale: true, strictScale: true,
controller: photoViewController, controller: photoViewController,
onScaleUpdate: onScaleUpdate,
child: SizedBox( child: SizedBox(
width: width, width: width,
height: height, height: height,
@@ -731,6 +737,7 @@ class _ContinuousModeState extends State<_ContinuousMode>
target, target,
Offset(size.width / 2 - location.dx, size.height / 2 - location.dy), Offset(size.width / 2 - location.dx, size.height / 2 - location.dy),
); );
onScaleUpdate(target);
} }
@override @override
@@ -744,6 +751,7 @@ class _ContinuousModeState extends State<_ContinuousMode>
target, target,
Offset(size.width / 2 - location.dx, size.height / 2 - location.dy), Offset(size.width / 2 - location.dx, size.height / 2 - location.dy),
); );
onScaleUpdate(target);
} }
@override @override