diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..88359b2 --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '11.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/lib/main.dart b/example/lib/main.dart index 17c2242..a8a1bdb 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -31,6 +31,12 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { + + // this is used to enable and disable scroll of the listview + // we can disable the listview scroll if the number of touch is 2 or more + // this will trigger zoom if the image is touched with two finger. + bool isZooming = false; + Widget listRow(int profile, int image, int likes, String name, String text) { return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -50,7 +56,7 @@ class _MyHomePageState extends State { modalBarrierColor: Colors.black12, // optional minScale: 0.5, // optional maxScale: 3.0, // optional - twoTouchOnly: true, + twoTouchOnly: false, animationDuration: Duration(milliseconds: 300), animationCurve: Curves.fastOutSlowIn, onScaleStart: () { @@ -59,6 +65,11 @@ class _MyHomePageState extends State { onScaleStop: () { debugPrint('zooming ended!'); }, // optional + onTouchCountChanged: (count) { + setState(() { + isZooming = count > 1; + }); + }, child: CachedNetworkImage( imageUrl: 'https://picsum.photos/800?image=$image')), Padding( @@ -129,6 +140,8 @@ class _MyHomePageState extends State { fontSize: 38)), systemOverlayStyle: SystemUiOverlayStyle.dark), body: ListView( + // this disables the scroll which makes it easier for image to zoom. + physics: isZooming ? NeverScrollableScrollPhysics() : ScrollPhysics(), children: [ listRow(1027, 1062, 36, 'mary.porter', 'Lucy doesnt want to get out of bed today, its far too cold for the little darling.'), diff --git a/lib/zoom_pinch_overlay.dart b/lib/zoom_pinch_overlay.dart index 4b57d27..e7d818f 100644 --- a/lib/zoom_pinch_overlay.dart +++ b/lib/zoom_pinch_overlay.dart @@ -53,6 +53,7 @@ class ZoomOverlay extends StatefulWidget { this.modalBarrierColor, this.onScaleStart, this.onScaleStop, + this.onTouchCountChanged, }) : super(key: key); /// A widget to make zoomable. @@ -83,6 +84,10 @@ class ZoomOverlay extends StatefulWidget { final VoidCallback? onScaleStart; final VoidCallback? onScaleStop; + /// callback when the touch pointer changes + /// the parameter gives the number of current touch + final Function(int)? onTouchCountChanged; + @override _ZoomOverlayState createState() => _ZoomOverlayState(); } @@ -254,7 +259,13 @@ class _ZoomOverlayState extends State _overlayEntry = null; } - void _incrementEnter(PointerEvent details) => _touchCount++; + void _incrementEnter(PointerEvent details) { + _touchCount++; + widget.onTouchCountChanged?.call(_touchCount); + } - void _incrementExit(PointerEvent details) => _touchCount--; + void _incrementExit(PointerEvent details) { + _touchCount--; + widget.onTouchCountChanged?.call(_touchCount); + } }