Skip to content

Commit

Permalink
fixed : Same hero tag causes black screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh.Lu authored and Josh.Lu committed Sep 18, 2020
1 parent a82ac41 commit 3c1ff5a
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 18 deletions.
33 changes: 22 additions & 11 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.3.3

1.修复相同图片地址Hero动画tag相同问题


## 1.3.2

1.图片Hero动画相同地址不能加载
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
```
dependencies:
...
nineold: ^1.3.2
nineold: ^1.3.3
```

关于如何运行flutter项目, 参考官方文档[documentation](https://flutter.io/).


# 版本更新

## 1.3.3

1.修复相同图片地址Hero动画tag相同问题

## 1.3.2

Expand Down
4 changes: 4 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class _MyHomePageState extends State<MyHomePage> {

List<String> getData() {
List<String> list = [];
list.add(
"http://t7.baidu.com/it/u=3616242789,1098670747&fm=79&app=86&f=JPEG?w=900&h=1350");
list.add(
"http://t7.baidu.com/it/u=3616242789,1098670747&fm=79&app=86&f=JPEG?w=900&h=1350");
list.add(
"http://t7.baidu.com/it/u=3616242789,1098670747&fm=79&app=86&f=JPEG?w=900&h=1350");
list.add(
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ packages:
name: uuid
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.4"
version: "2.2.2"
vector_math:
dependency: transitive
description:
Expand Down
4 changes: 3 additions & 1 deletion lib/watcher/gallery_watcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class GalleryPhotoViewWrapper extends StatefulWidget {
this.maxScale,
this.initialIndex,
@required this.thumbGalleryItems,
@required this.tagItems,
this.originGalleryItems,
this.scrollDirection = Axis.horizontal,
this.onLongPressListener,
Expand All @@ -26,6 +27,7 @@ class GalleryPhotoViewWrapper extends StatefulWidget {
final PageController pageController;
final List<String> thumbGalleryItems;
final List<String> originGalleryItems;
final List<String> tagItems;
final Axis scrollDirection;

final OnLongPressCallback onLongPressListener;
Expand Down Expand Up @@ -116,7 +118,7 @@ class _GalleryPhotoViewWrapperState extends State<GalleryPhotoViewWrapper> {
} else {
item = widget.originGalleryItems[index];
}
var tag = item + index.toString();
var tag = item + widget.tagItems[index];
return PhotoViewGalleryPageOptions(
imageProvider: CachedNetworkImageProvider(item),
initialScale: PhotoViewComputedScale.contained,
Expand Down
10 changes: 9 additions & 1 deletion lib/widget/nine_old_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:nineold/loader/image_with_loader.dart';
import 'package:nineold/watcher/gallery_watcher.dart';
import 'package:uuid/uuid.dart';

class NineOldWidget extends StatelessWidget {
final List<String> images;
Expand All @@ -12,6 +13,9 @@ class NineOldWidget extends StatelessWidget {

final OnLongPressCallback onLongPressListener;

final List<String> tagItems = [];


NineOldWidget(
{@required this.images,
this.moreStyle,
Expand All @@ -27,6 +31,9 @@ class NineOldWidget extends StatelessWidget {
Widget build(BuildContext context) {
width = MediaQuery.of(context).size.width;
height = MediaQuery.of(context).size.height;
images.forEach((element) {
tagItems.add(Uuid().v1());
});
return _buildImagesFrame(context);
}

Expand Down Expand Up @@ -389,7 +396,7 @@ class NineOldWidget extends StatelessWidget {
child: AspectRatio(
aspectRatio: aspectRatio,
child: Hero(
tag: images[index] + index.toString(),
tag: images[index] + tagItems[index],
child: ImageWithLoader(
url: images[index],
backgroundColor: backgroundColor,
Expand All @@ -408,6 +415,7 @@ class NineOldWidget extends StatelessWidget {
MaterialPageRoute(
builder: (context) => GalleryPhotoViewWrapper(
thumbGalleryItems: images,
tagItems: tagItems,
backgroundDecoration: const BoxDecoration(
color: Colors.black,
),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ packages:
source: hosted
version: "1.2.0"
uuid:
dependency: transitive
dependency: "direct main"
description:
name: uuid
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.4"
version: "2.2.2"
vector_math:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nineold
description: Nineoldwidget is a component used to encapsulate the nine palace display of pictures.
version: 1.3.2
version: 1.3.3
homepage: https://github.com/lanzhu1993/flutter_nineold

environment:
Expand All @@ -13,6 +13,7 @@ dependencies:
transparent_image: ^1.0.0
photo_view: ^0.10.2
cached_network_image: ^2.3.2+1
uuid: ^2.2.2

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 3c1ff5a

Please sign in to comment.