diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 477f21d..747f386 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -20,10 +20,10 @@ dev_dependencies: zhiying_comm: path: ../ - flutter_alibc: - git: - ref: 0.0.1 - url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_flutter_alibc.git +# flutter_alibc: +# git: +# ref: 0.0.1 +# url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_flutter_alibc.git # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/lib/util/photo_preview/photo_preview.dart b/lib/util/photo_preview/photo_preview.dart index 78f15bd..4e4d6f8 100644 --- a/lib/util/photo_preview/photo_preview.dart +++ b/lib/util/photo_preview/photo_preview.dart @@ -1,5 +1,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:loading_indicator/loading_indicator.dart'; import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view_gallery.dart'; @@ -9,16 +10,25 @@ import 'package:zhiying_comm/zhiying_comm.dart'; class PhotoPreview extends StatefulWidget { List previewImageDatas; int index; + String heroTagSuffix; - PhotoPreview({Key key, this.previewImageDatas, this.index = 0}) + PhotoPreview( + {Key key, + this.previewImageDatas, + this.index = 0, + this.heroTagSuffix = ""}) : super(key: key); PhotoPreview._showPhotoViewByData( - {Key key, this.previewImageDatas, this.index}) - : super(key: key); + {Key key, + this.previewImageDatas, + this.index = 0, + this.heroTagSuffix = ""}) + : super(key: key) { + } PhotoPreview._showPhotoViewByImages( - {Key key, List images, this.index}) + {Key key, List images, this.index = 0, this.heroTagSuffix = ""}) : super(key: key) { if (images != null) { previewImageDatas = List(); @@ -32,21 +42,23 @@ class PhotoPreview extends StatefulWidget { ///显示类型的一些预览 static showPhotoPreview( BuildContext context, List previewImageDatas, - {int currentIndex = 0}) { + {int currentIndex = 0, String heroTagSuffix}) { Navigator.of(context).push(new FadeRoute( page: PhotoPreview._showPhotoViewByData( previewImageDatas: previewImageDatas, index: currentIndex, + heroTagSuffix: heroTagSuffix, ))); } ///显示仅仅是一组list类型的图片预览 static showPhotoPreviewByimages(BuildContext context, List images, - {int currentIndex = 0}) { + {int currentIndex = 0, String heroTagSuffix = ""}) { Navigator.of(context).push(new FadeRoute( page: PhotoPreview._showPhotoViewByImages( images: images, index: currentIndex, + heroTagSuffix: heroTagSuffix, ))); } @@ -71,7 +83,7 @@ class _PhotoPreviewState extends State { images: widget.previewImageDatas, index: widget.index, controller: pageController, - heroTag: "", + heroTagSuffix: widget.heroTagSuffix ?? "", )); } } @@ -100,7 +112,7 @@ enum PreviewImageType { class PhotoViewGalleryScreen extends StatefulWidget { List images = []; int index = 0; - String heroTag; + String heroTagSuffix; PageController controller; PhotoViewGalleryScreen( @@ -108,7 +120,7 @@ class PhotoViewGalleryScreen extends StatefulWidget { @required this.images, this.index, this.controller, - this.heroTag}) + this.heroTagSuffix}) : super(key: key) { controller = PageController(initialPage: index); } @@ -143,8 +155,10 @@ class _PhotoViewGalleryScreenState extends State { builder: (BuildContext context, int index) { return PhotoViewGalleryPageOptions( imageProvider: _buildPage(context, index), - heroAttributes: widget.heroTag.isNotEmpty - ? PhotoViewHeroAttributes(tag: widget.heroTag) + heroAttributes: widget.heroTagSuffix.isNotEmpty + ? PhotoViewHeroAttributes( + tag: (widget.images[index].data ?? "") + + widget.heroTagSuffix) : null, ); }, @@ -152,6 +166,19 @@ class _PhotoViewGalleryScreenState extends State { loadFailedChild: Container( child: Text("加载失败"), ), + loadingBuilder: (context,event){ + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 48, + constraints: BoxConstraints(maxWidth: 48,maxHeight: 48), + height: 48, + child: LoadingIndicator(indicatorType: Indicator.ballSpinFadeLoader,color: Colors.white,) + ), + ], + ); + }, backgroundDecoration: BoxDecoration(color: Colors.black), pageController: widget.controller, enableRotation: true, @@ -220,12 +247,9 @@ class FadeRoute extends PageRouteBuilder { Animation secondaryAnimation, Widget child, ) => - ScaleTransition( - scale: animation, - child: FadeTransition( - opacity: animation, - child: child, - ), + FadeTransition( + opacity: animation, + child: child, ), ); }