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

Lock rotation option for Android #523

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ From v1.2.0, you need to migrate your android project to v2 embedding ([detail](
<summary>Click to view detail</summary>
<br/>

**Image Cropper** provides a helper class called `IOUiSettings` that wraps all properties can be used to customize UI in **TOCropViewController** library.
**Image Cropper** provides a helper class called `IOSUiSettings` that wraps all properties can be used to customize UI in **TOCropViewController** library.

| Property | Description | Type |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.yalantis.ucrop.UCrop;
import com.yalantis.ucrop.model.AspectRatio;
import com.yalantis.ucrop.view.CropImageView;
import com.yalantis.ucrop.UCropActivity;

import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -48,6 +49,8 @@ public void startCrop(MethodCall call, MethodChannel.Result result) {
ArrayList<Map<?, ?>> aspectRatioPresets = call.argument("android.aspect_ratio_presets");
String cropStyle = call.argument("android.crop_style");
String initAspectRatio = call.argument("android.init_aspect_ratio");
Boolean lockGestureRotation = call.argument("android.lock_gesture_rotation");


pendingResult = result;

Expand All @@ -65,6 +68,9 @@ public void startCrop(MethodCall call, MethodChannel.Result result) {
// uCrop.withMaxResultSize(1000, 1000);
options.setCompressionFormat("png".equals(compressFormat) ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG);
options.setCompressionQuality(compressQuality != null ? compressQuality : 90);
if(lockGestureRotation){
options.setAllowedGestures(UCropActivity.SCALE, UCropActivity.NONE, UCropActivity.SCALE);
}
options.setMaxBitmapSize(10000);

// UI customization settings
Expand Down Expand Up @@ -256,4 +262,4 @@ private AspectRatio parseAspectRatio(Map<?, ?> preset) {
}

}
}
}
2 changes: 1 addition & 1 deletion image_cropper/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
image_cropper_platform_interface: ^7.0.0
image_cropper_platform_interface: ^7.0.1
image_cropper_for_web: ^6.0.2

dev_dependencies:
Expand Down
5 changes: 5 additions & 0 deletions image_cropper_platform_interface/lib/src/models/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ class AndroidUiSettings extends PlatformUiSettings {
/// when starting the cropper
final CropAspectRatioPresetData? initAspectRatio;

/// Locks rotation of the image when gestures are used (default is false)
final bool lockGestureRotation;

AndroidUiSettings({
this.toolbarTitle,
this.toolbarColor,
Expand All @@ -217,6 +220,7 @@ class AndroidUiSettings extends PlatformUiSettings {
this.hideBottomControls,
this.initAspectRatio,
this.cropStyle = CropStyle.rectangle,
this.lockGestureRotation = false,
this.aspectRatioPresets = const [
CropAspectRatioPreset.original,
CropAspectRatioPreset.square,
Expand Down Expand Up @@ -247,6 +251,7 @@ class AndroidUiSettings extends PlatformUiSettings {
'android.hide_bottom_controls': this.hideBottomControls,
'android.init_aspect_ratio': this.initAspectRatio?.name,
'android.crop_style': this.cropStyle.name,
'android.lock_gesture_rotation': this.lockGestureRotation,
'android.aspect_ratio_presets': aspectRatioPresets
.map<Map<String, dynamic>>((item) => {
'name': item.name,
Expand Down
2 changes: 1 addition & 1 deletion image_cropper_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: image_cropper_platform_interface
description: A common platform interface for the image_cropper plugin.
repository: https://github.com/hnvn/flutter_image_cropper
version: 7.0.0
version: 7.0.1

environment:
sdk: '>=3.3.0 <4.0.0'
Expand Down