mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Improve reader gesture. Close #185
This commit is contained in:
@@ -335,6 +335,11 @@ class _GalleryModeState extends State<_GalleryMode>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool handleOnTap(Offset location) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const Set<PointerDeviceKind> _kTouchLikeDeviceTypes = <PointerDeviceKind>{
|
||||
@@ -366,6 +371,18 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
||||
var fingers = 0;
|
||||
bool disableScroll = false;
|
||||
|
||||
/// Whether the user was scrolling the page.
|
||||
/// The gesture detector has a delay to detect tap event.
|
||||
/// To handle the tap event, we need to know if the user was scrolling before the delay.
|
||||
bool delayedIsScrolling = false;
|
||||
|
||||
void delayedSetIsScrolling(bool value) {
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 300),
|
||||
() => delayedIsScrolling = value,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
reader = context.reader;
|
||||
@@ -374,6 +391,12 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
itemPositionsListener.itemPositions.removeListener(onPositionChanged);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void onPositionChanged() {
|
||||
var page = itemPositionsListener.itemPositions.value.first.index;
|
||||
page = page.clamp(1, reader.maxPage);
|
||||
@@ -516,8 +539,14 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
||||
child: widget,
|
||||
);
|
||||
|
||||
widget = NotificationListener<ScrollUpdateNotification>(
|
||||
widget = NotificationListener<ScrollNotification>(
|
||||
onNotification: (notification) {
|
||||
if (notification is ScrollStartNotification) {
|
||||
delayedSetIsScrolling(true);
|
||||
} else if (notification is ScrollEndNotification) {
|
||||
delayedSetIsScrolling(false);
|
||||
}
|
||||
|
||||
var length = reader.maxChapter;
|
||||
if (!scrollController.hasClients) return false;
|
||||
if (scrollController.position.pixels <=
|
||||
@@ -592,7 +621,7 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
||||
|
||||
@override
|
||||
void handleLongPressDown(Offset location) {
|
||||
if (!appdata.settings['enableLongPressToZoom']) {
|
||||
if (!appdata.settings['enableLongPressToZoom'] || delayedIsScrolling) {
|
||||
return;
|
||||
}
|
||||
double target = photoViewController.getInitialScale!.call()! * 1.75;
|
||||
@@ -667,6 +696,16 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool handleOnTap(Offset location) {
|
||||
if (delayedIsScrolling) {
|
||||
print('isScrolling');
|
||||
return true;
|
||||
}
|
||||
print('isNotScrolling');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ImageProvider _createImageProviderFromKey(
|
||||
|
Reference in New Issue
Block a user