✨ Zoom image via mosue scroll
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:file_saver/file_saver.dart';
|
import 'package:file_saver/file_saver.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -89,6 +90,25 @@ class ImageFileContent extends HookConsumerWidget {
|
|||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
|
child: Listener(
|
||||||
|
onPointerSignal: (pointerSignal) {
|
||||||
|
try {
|
||||||
|
// Handle mouse wheel zoom - cast to dynamic to access scrollDelta
|
||||||
|
final delta =
|
||||||
|
(pointerSignal as dynamic).scrollDelta.dy as double?;
|
||||||
|
if (delta != null && delta != 0) {
|
||||||
|
final currentScale = photoViewController.scale ?? 1.0;
|
||||||
|
// Adjust scale based on scroll direction (invert for natural zoom)
|
||||||
|
final newScale =
|
||||||
|
delta > 0 ? currentScale * 0.9 : currentScale * 1.1;
|
||||||
|
// Clamp scale to reasonable bounds
|
||||||
|
final clampedScale = newScale.clamp(0.1, 10.0);
|
||||||
|
photoViewController.scale = clampedScale;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore non-scroll events
|
||||||
|
}
|
||||||
|
},
|
||||||
child: PhotoView(
|
child: PhotoView(
|
||||||
backgroundDecoration: BoxDecoration(
|
backgroundDecoration: BoxDecoration(
|
||||||
color: Colors.black.withOpacity(0.9),
|
color: Colors.black.withOpacity(0.9),
|
||||||
@@ -104,6 +124,7 @@ class ImageFileContent extends HookConsumerWidget {
|
|||||||
filterQuality: FilterQuality.high,
|
filterQuality: FilterQuality.high,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
// Controls overlay
|
// Controls overlay
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: MediaQuery.of(context).padding.bottom + 16,
|
bottom: MediaQuery.of(context).padding.bottom + 16,
|
||||||
|
|||||||
Reference in New Issue
Block a user