mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
improve reader; fix #21
This commit is contained in:
@@ -22,6 +22,8 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
||||
|
||||
_DragListener? dragListener;
|
||||
|
||||
int fingers = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_tapGestureRecognizer = TapGestureRecognizer()
|
||||
@@ -38,6 +40,7 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
||||
return Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPointerDown: (event) {
|
||||
fingers++;
|
||||
_lastTapPointer = event.pointer;
|
||||
_lastTapMoveDistance = Offset.zero;
|
||||
_tapGestureRecognizer.addPointer(event);
|
||||
@@ -46,7 +49,7 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
||||
_dragInProgress = false;
|
||||
}
|
||||
Future.delayed(_kLongPressMinTime, () {
|
||||
if (_lastTapPointer == event.pointer) {
|
||||
if (_lastTapPointer == event.pointer && fingers == 1) {
|
||||
if(_lastTapMoveDistance!.distanceSquared < 20.0 * 20.0) {
|
||||
onLongPressedDown(event.position);
|
||||
_longPressInProgress = true;
|
||||
@@ -67,6 +70,19 @@ class _ReaderGestureDetectorState extends State<_ReaderGestureDetector> {
|
||||
}
|
||||
},
|
||||
onPointerUp: (event) {
|
||||
fingers--;
|
||||
if (_longPressInProgress) {
|
||||
onLongPressedUp(event.position);
|
||||
}
|
||||
if(_dragInProgress) {
|
||||
dragListener?.onEnd?.call();
|
||||
_dragInProgress = false;
|
||||
}
|
||||
_lastTapPointer = null;
|
||||
_lastTapMoveDistance = null;
|
||||
},
|
||||
onPointerCancel: (event) {
|
||||
fingers--;
|
||||
if (_longPressInProgress) {
|
||||
onLongPressedUp(event.position);
|
||||
}
|
||||
|
@@ -471,18 +471,24 @@ class _ContinuousModeState extends State<_ContinuousMode>
|
||||
},
|
||||
child: widget,
|
||||
);
|
||||
var width = MediaQuery.of(context).size.width;
|
||||
var height = MediaQuery.of(context).size.height;
|
||||
if(appdata.settings['limitImageWidth'] && width / height > 0.7) {
|
||||
width = height * 0.7;
|
||||
}
|
||||
|
||||
return PhotoView.customChild(
|
||||
backgroundDecoration: BoxDecoration(
|
||||
color: context.colorScheme.surface,
|
||||
),
|
||||
childSize: Size(width, height),
|
||||
minScale: 1.0,
|
||||
maxScale: 2.5,
|
||||
strictScale: true,
|
||||
controller: photoViewController,
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
width: width,
|
||||
height: height,
|
||||
child: widget,
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user