Skip to content

Commit

Permalink
Add cropMode option on iOS.
Browse files Browse the repository at this point in the history
Possible values:
- module.CROP_MODE_SQUARE (default)
- module.CROP_MODE_CIRCLE
  • Loading branch information
jonatansberg committed Jul 20, 2015
1 parent 15e4be7 commit 81a6d40
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion iphone/Classes/SeHyperlabImagecropperModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,34 @@ -(void)didReceiveMemoryWarning:(NSNotification*)notification

#pragma Public APIs

MAKE_SYSTEM_PROP(CROP_MODE_SQUARE, RSKImageCropModeSquare);
MAKE_SYSTEM_PROP(CROP_MODE_CIRCLE, RSKImageCropModeCircle);

-(void)open:(id)args
{
TiThreadPerformOnMainThread(^{
TiBlob *blob;
NSDictionary *dict;
NSNumber *cropModeArg;

ENSURE_ARG_OR_NIL_AT_INDEX(dict, args, 0, NSDictionary);

ENSURE_ARG_FOR_KEY(blob, dict, @"image", TiBlob);
ENSURE_ARG_FOR_KEY(doneCallback, dict, @"success", KrollCallback);
ENSURE_ARG_OR_NIL_FOR_KEY(cancelCallback, dict, @"cancel", KrollCallback);
ENSURE_ARG_OR_NIL_FOR_KEY(cropModeArg, dict, @"cropMode", NSNumber);

maxSize = [TiUtils intValue:@"size" properties:dict def:-1];

RSKImageCropMode cropMode = RSKImageCropModeSquare;
if (cropModeArg != nil) {
cropMode = (RSKImageCropMode)[cropModeArg integerValue];
}

UIImage* image = [blob image];

RSKImageCropViewController *controller = [[RSKImageCropViewController alloc] initWithImage:image
cropMode:RSKImageCropModeSquare];
cropMode:cropMode];
controller.delegate = self;
controller.rotationEnabled = YES;
controller.avoidEmptySpaceAroundImage = YES;
Expand Down

0 comments on commit 81a6d40

Please sign in to comment.