Skip to content

Commit

Permalink
Add chooseText and cancelText properties: rebased (#699)
Browse files Browse the repository at this point in the history
* Add cancel and choose buttons text properties

* Change props names to ‘cancelText’,’chooseText’

* Add cancel and choose buttons text props

* Fix properties names IOS

* Add cropper prefix and update readme
  • Loading branch information
Ivan Stroganov authored and ivpusic committed May 16, 2018
1 parent 73b09e1 commit dfa5e5d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ ImagePicker.clean().then(() => {
| showCropGuidelines (android only) | bool (default true) | Whether to show the 3x3 grid on top of the image during cropping |
| hideBottomControls (android only) | bool (default false) | Whether to display bottom controls |
| enableRotationGesture (android only) | bool (default false) | Whether to enable rotating the image by hand gesture |
| cropperChooseText (ios only)  |           string (default choose)        | Choose button text |
| cropperCancelText (ios only) | string (default Cancel) | Cancel button text |

#### Smart Album Types (ios)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
private boolean disableCropperColorSetters = false;
private ReadableMap options;


//Grey 800
private final String DEFAULT_TINT = "#424242";
private String cropperActiveWidgetColor = DEFAULT_TINT;
Expand Down Expand Up @@ -133,7 +132,7 @@ private void setConfiguration(final ReadableMap options) {
hideBottomControls = options.hasKey("hideBottomControls") ? options.getBoolean("hideBottomControls") : hideBottomControls;
enableRotationGesture = options.hasKey("enableRotationGesture") ? options.getBoolean("enableRotationGesture") : enableRotationGesture;
disableCropperColorSetters = options.hasKey("disableCropperColorSetters") ? options.getBoolean("disableCropperColorSetters") : disableCropperColorSetters;
this.options = options;
this.options = options;
}

private void deleteRecursive(File fileOrDirectory) {
Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ declare module "react-native-image-crop-picker" {
showCropGuidelines?: boolean;
hideBottomControls?: boolean;
enableRotationGesture?: boolean;
cropperCancelText?: string;
cropperChooseText?: string;
}

export interface Image {
Expand Down
8 changes: 7 additions & 1 deletion ios/src/ImageCropPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ - (instancetype)init
@"compressVideoPreset": @"MediumQuality",
@"loadingLabelText": @"Processing assets...",
@"mediaType": @"any",
@"showsSelectedCount": @YES
@"showsSelectedCount": @YES,
@"cropperCancelText": @"Cancel",
@"cropperChooseText": @"Choose"
};
self.compression = [[Compression alloc] init];
}
Expand Down Expand Up @@ -364,8 +366,12 @@ - (void)startCropping:(UIImage *)image {
imageCropVC.avoidEmptySpaceAroundImage = YES;
imageCropVC.dataSource = self;
imageCropVC.delegate = self;
NSString *cropperCancelText = [self.options objectForKey:@"cropperCancelText"];
NSString *cropperChooseText = [self.options objectForKey:@"cropperChooseText"];
[imageCropVC setModalPresentationStyle:UIModalPresentationCustom];
[imageCropVC setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[imageCropVC.cancelButton setTitle:cropperCancelText forState:UIControlStateNormal];
[imageCropVC.chooseButton setTitle:cropperChooseText forState:UIControlStateNormal];
dispatch_async(dispatch_get_main_queue(), ^{
[[self getRootVC] presentViewController:imageCropVC animated:YES completion:nil];
});
Expand Down

0 comments on commit dfa5e5d

Please sign in to comment.