Skip to content

Commit

Permalink
version up to 2.0.0-dev.2 including undo/redo feature
Browse files Browse the repository at this point in the history
  • Loading branch information
chooyan-eng committed Dec 8, 2024
1 parent 081aeb6 commit 708a0c8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [2.0.0-dev.2] - 2024.12.08
* Add undo / redo related features. See [README.md](README.md) for more details.

## [2.0.0-dev.1] - 2024.12.07
* `onMoved` callback passes additional `imageRect` parameter.
* Refactor the entire codebase
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Enjoy building your own cropping UI with __crop_your_image__!
- Fix __aspect ratio__
- Configure `Rect` of _crop rect_ programmatically
- Detect events of users' operation
- Undo / Redo operation
- (advanced) Cropping backend logics are also customizable

Note that this package _DON'T_
Expand Down Expand Up @@ -69,6 +70,31 @@ ElevatedButton(

Because `_controller.crop()` only kicks the cropping process, this method returns immediately without any cropped image data. You can obtain the result of cropping images via `onCropped` callback of `Crop` Widget.

### Undo / Redo


`CropController` also provides `undo` and `redo` methods.

```dart
ElevatedButton(
child: Text('Undo')
onPressed: () => _cropController.undo(),
),
```

You can also detect history of crop rect changes via `onHistoryChanged` callback of `Crop` Widget. This callback exposes `History` object, which contains `undoCount` and `redoCount`, that indicates how many times undo / redo operation is available.

```dart
Crop(
onHistoryChanged: (history) {
setState(() {
_undoEnabled = history.undoCount > 0;
_redoEnabled = history.redoCount > 0;
});
},
)
```

### List of configurations
All the arguments of `Crop` and usages are below.

Expand Down Expand Up @@ -128,6 +154,7 @@ Widget build(BuildContext context) {
|baseColor|Color?|Color of the base color of the cropping editor.|
|radius|double?|Corner radius of crop rect.|
|onMoved|void Function(Rect)?|Callback called when crop rect is moved regardless of its reasons. `newRect` of argument is current `Rect` of crop rect.|
|onHistoryChanged|void Function(History)?|Callback called when history of crop rect is changed. This history allows you to undo / redo feature is available or not.|
|onStatusChanged|void Function(CropStatus)?|Callback called when status of Crop is changed.|
|willUpdateScale|bool Function(double)?|Callback called before scale changes on _interactive_ mode. By returning `false` to this callback, updating scale will be canceled.|
|cornerDotBuilder|Widget Function(Size, EdgeAlignment)?|Builder function to build Widget placed at four corners used to move crop rect. The builder passes `size` which widget must follow and `edgeAlignment` which indicates the position.|
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: crop_your_image
description: crop_your_image helps your app to embed Widgets for cropping images.
version: 2.0.0-dev.1
version: 2.0.0-dev.2
homepage: https://github.com/chooyan-eng/crop_your_image
topics:
- crop
Expand Down

0 comments on commit 708a0c8

Please sign in to comment.