fluttercandies / extended_image

A powerful official extension library of image, which support placeholder(loading)/ failed state, cache network, zoom pan image, photo view, slide out page, editor(crop,rotate,flip), paint custom etc.
https://fluttercandies.github.io/extended_image/
MIT License
1.94k stars 505 forks source link

使用FadeImage包裹ExtendedImage后,手势失效 #667

Closed iCytus closed 8 months ago

iCytus commented 8 months ago

Version

3.10.0

Platforms

dart

Device Model

iphone 12 pro

flutter info

[✓] Flutter (Channel stable, 3.16.3, on macOS 13.6.2 22G320 darwin-arm64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)

How to reproduce?

在示例demo里,example/lib/common/widget/pic_swiper.dart 文件 417行

使用FadeinImage包裹ExtendedImage.network 后,只能左右滑动,无法放大缩小以及双击等,请问有什么解决办法么?

```dart Widget image = FadeInImage( placeholder: const AssetImage('assets/black_bg_placeholder.jpg'), image: ExtendedImage.network( item, fit: BoxFit.contain, enableSlideOutPage: true, mode: ExtendedImageMode.gesture, imageCacheName: 'CropImage', //layoutInsets: EdgeInsets.all(20), initGestureConfigHandler: (ExtendedImageState state) { double? initialScale = 1.0; if (state.extendedImageInfo != null) { initialScale = initScale( size: size, initialScale: initialScale, imageSize: Size(state.extendedImageInfo!.image.width.toDouble(), state.extendedImageInfo!.image.height.toDouble())); } return GestureConfig( inPageView: true, initialScale: initialScale!, maxScale: max(initialScale, 5.0), animationMaxScale: max(initialScale, 5.0), initialAlignment: InitialAlignment.center, //you can cache gesture state even though page view page change. //remember call clearGestureDetailsCache() method at the right time.(for example,this page dispose) cacheGesture: false, ); }, onDoubleTap: (ExtendedImageGestureState state) { ///you can use define pointerDownPosition as you can, ///default value is double tap pointer down postion. final Offset? pointerDownPosition = state.pointerDownPosition; final double? begin = state.gestureDetails!.totalScale; double end; //remove old _doubleClickAnimation?.removeListener(_doubleClickAnimationListener); //stop pre _doubleClickAnimationController.stop(); //reset to use _doubleClickAnimationController.reset(); if (begin == doubleTapScales[0]) { end = doubleTapScales[1]; } else { end = doubleTapScales[0]; } _doubleClickAnimationListener = () { //print(_animation.value); state.handleDoubleTap( scale: _doubleClickAnimation!.value, doubleTapPosition: pointerDownPosition); }; _doubleClickAnimation = _doubleClickAnimationController.drive(Tween(begin: begin, end: end)); _doubleClickAnimation!.addListener(_doubleClickAnimationListener); _doubleClickAnimationController.forward(); }, loadStateChanged: (ExtendedImageState state) { if (state.extendedImageLoadState == LoadState.completed) { final Rect imageDRect = getDestinationRect( rect: Offset.zero & size, inputSize: Size( state.extendedImageInfo!.image.width.toDouble(), state.extendedImageInfo!.image.height.toDouble(), ), fit: BoxFit.contain, ); detailKeys[index] ??= ImageDetailInfo( imageDRect: imageDRect, pageSize: size, imageInfo: state.extendedImageInfo!, ); final ImageDetailInfo? imageDetailInfo = detailKeys[index]; return StreamBuilder( builder: (BuildContext context, AsyncSnapshot data) { return ExtendedImageGesture( state, canScaleImage: (_) => _imageDetailY == 0, imageBuilder: (Widget image) { return Stack( children: [ Positioned.fill( child: image, top: _imageDetailY, bottom: -_imageDetailY, ), Positioned( left: 0.0, right: 0.0, top: imageDetailInfo!.imageBottom + _imageDetailY, child: Opacity( opacity: _imageDetailY == 0 ? 0 : min( 1, _imageDetailY.abs() / (imageDetailInfo.maxImageDetailY / 4.0), ), child: ImageDetail( imageDetailInfo, index, widget.tuChongItem, ), ), ), ], ); }, ); }, initialData: _imageDetailY, stream: rebuildDetail.stream, ); } return null; }, ).image); ```

Logs

No response

Example code (optional)

No response

Contact

No response

zmtzawqlp commented 8 months ago

FadeIn 可以 extended_image里面写,看下demo

iCytus commented 8 months ago

OK,找到了谢谢