Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

## [0.6.5] #87

Merged
merged 1 commit into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [0.6.5]

* Features:
Add completedWidget for ExtendedImageState, it is include gesture or editor, so that you would't miss them
* Improve:
improve documents about Load State

## [0.6.4]

* Issues:
Expand Down
15 changes: 15 additions & 0 deletions README-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ loadStateChanged 不仅仅只在网络图片中可以使用, 如果你的图片

![img](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_image/custom.gif)

注意:

* 如果你不想重写某个状态,那么请返回null

* 如果你想重写完成图片的 size 或者 soucreRect, 你可以通过使用 ExtendedRawImage 来完成

* 如果你想增加一些新效果 (比如动画), 你可以重写并且使用ExtendedImageState.completedWidget

* ExtendedImageState.completedWidget 包含手势或者裁剪, 这样你不会丢失它们

```dart
/// custom load state widget if you want
final LoadStateChanged loadStateChanged;
Expand Down Expand Up @@ -132,6 +142,7 @@ ExtendedImageState 状态回调
| invertColors | 是否反转颜色 | - |
| imageStreamKey | 图片流的唯一键 | - |
| reLoadImage() | 如果图片加载失败,你可以通过调用这个方法来重新加载图片 | - |
| completedWidget | 返回图片完成的Widget,它包含手势以及裁剪 | - |

```dart
abstract class ExtendedImageState {
Expand Down Expand Up @@ -168,6 +179,10 @@ ExtendedImage.network(
fit: BoxFit.fill,
);
break;
///if you don't want override completed widget
///please return null or state.completedWidget
//return null;
//return state.completedWidget;
case LoadState.completed:
_controller.forward();
return FadeTransition(
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ you can set enableLoadState(default value is ture for network and others are fal

![img](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/extended_image/custom.gif)

Notice:

* if you don't want to override any state, please return null in this case

* if you want to override size or soucreRect, you can override it with ExtendedRawImage at completed state

* if you want to add something (like animation) at completed state, you can override it with ExtendedImageState.completedWidget

* ExtendedImageState.completedWidget is include gesture or editor, so that you would't miss them


```dart
/// custom load state widget if you want
final LoadStateChanged loadStateChanged;
Expand Down Expand Up @@ -128,6 +139,7 @@ ExtendedImageState(LoadStateChanged call back)
| invertColors | invertColors | - |
| imageStreamKey | key of image | - |
| reLoadImage() | if image load failed,you can reload image by call it | - |
| completedWidget | return completed widget include gesture or editor | - |

```dart
abstract class ExtendedImageState {
Expand All @@ -143,6 +155,8 @@ abstract class ExtendedImageState {
bool get invertColors;

Object get imageStreamKey;

Widget get completedWidget;
}
```

Expand All @@ -164,6 +178,11 @@ ExtendedImage.network(
fit: BoxFit.fill,
);
break;

///if you don't want override completed widget
///please return null or state.completedWidget
//return null;
//return state.completedWidget;
case LoadState.completed:
_controller.forward();
return FadeTransition(
Expand Down
20 changes: 10 additions & 10 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
buildscript {
repositories {
// google()
// jcenter()
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
google()
jcenter()
// maven { url 'https://maven.aliyun.com/repository/google' }
// maven { url 'https://maven.aliyun.com/repository/jcenter' }
// maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}

dependencies {
Expand All @@ -25,11 +25,11 @@ maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }

allprojects {
repositories {
// google()
// jcenter()
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
google()
jcenter()
// maven { url 'https://maven.aliyun.com/repository/google' }
// maven { url 'https://maven.aliyun.com/repository/jcenter' }
// maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
}

Expand Down
5 changes: 5 additions & 0 deletions example/lib/common/crop_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class CropImage extends StatelessWidget {
//image will not to be limited by size which you set for ExtendedImage first time.
state.returnLoadStateChangedWidget = !knowImageSize;

///if you don't want override completed widget
///please return null or state.completedWidget
//return null;
//return state.completedWidget;

widget = Hero(
tag: item.imageUrl + index.toString(),
child:
Expand Down
5 changes: 5 additions & 0 deletions example/lib/pages/custom_image_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ class _CustomImageDemoState extends State<CustomImageDemo>
break;
case LoadState.completed:
_controller.forward();

///if you don't want override completed widget
///please return null or state.completedWidget
//return null;
//return state.completedWidget;
return FadeTransition(
opacity: _controller,
child: ExtendedRawImage(
Expand Down
40 changes: 21 additions & 19 deletions lib/src/extended_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -845,16 +845,7 @@ class _ExtendedImageState extends State<ExtendedImage>
);
break;
case LoadState.completed:
if (widget.mode == ExtendedImageMode.gesture) {
current = ExtendedImageGesture(this, _slidePageState);
} else if (widget.mode == ExtendedImageMode.editor) {
current = ExtendedImageEditor(
extendedImageState: this,
key: widget.extendedImageEditorKey,
);
} else {
current = _buildExtendedRawImage();
}
current = _getCompletedWidget();
break;
case LoadState.failed:
current = Container(
Expand All @@ -869,15 +860,8 @@ class _ExtendedImageState extends State<ExtendedImage>
break;
}
} else {
if (_loadState == LoadState.completed &&
widget.mode == ExtendedImageMode.gesture) {
current = ExtendedImageGesture(this, _slidePageState);
} else if (_loadState == LoadState.completed &&
widget.mode == ExtendedImageMode.editor) {
current = ExtendedImageEditor(
extendedImageState: this,
key: widget.extendedImageEditorKey,
);
if (_loadState == LoadState.completed) {
current = _getCompletedWidget();
} else {
current = _buildExtendedRawImage();
}
Expand Down Expand Up @@ -934,6 +918,21 @@ class _ExtendedImageState extends State<ExtendedImage>
);
}

Widget _getCompletedWidget() {
Widget current;
if (widget.mode == ExtendedImageMode.gesture) {
current = ExtendedImageGesture(this, _slidePageState);
} else if (widget.mode == ExtendedImageMode.editor) {
current = ExtendedImageEditor(
extendedImageState: this,
key: widget.extendedImageEditorKey,
);
} else {
current = _buildExtendedRawImage();
}
return current;
}

Widget _getIndicator(BuildContext context) {
return Theme.of(context).platform == TargetPlatform.iOS
? CupertinoActivityIndicator(
Expand Down Expand Up @@ -996,4 +995,7 @@ class _ExtendedImageState extends State<ExtendedImage>

@override
ExtendedImage get imageWidget => this.widget;

@override
Widget get completedWidget => _getCompletedWidget();
}
2 changes: 2 additions & 0 deletions lib/src/extended_image_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ abstract class ExtendedImageState {
Object get imageStreamKey;

ExtendedImage get imageWidget;

Widget get completedWidget;
}

enum ExtendedImageMode {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: extended_image
description: Official extension image, support placeholder(loading)/ failed state, cache network, zoom/pan, photo view, slide out page, editor(crop,rotate,flip), painting etc.
version: 0.6.4
version: 0.6.5
author: zmtzawqlp <[email protected]>
homepage: https://github.com/fluttercandies/extended_image

Expand Down