From 81a6d40b5447056c48f4d96adca6092f53dcc1ac Mon Sep 17 00:00:00 2001 From: Jonatan Lundin Date: Mon, 20 Jul 2015 13:38:31 +0200 Subject: [PATCH] Add cropMode option on iOS. Possible values: - module.CROP_MODE_SQUARE (default) - module.CROP_MODE_CIRCLE --- iphone/Classes/SeHyperlabImagecropperModule.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/iphone/Classes/SeHyperlabImagecropperModule.m b/iphone/Classes/SeHyperlabImagecropperModule.m index 4a7c3d4..f5b9b39 100644 --- a/iphone/Classes/SeHyperlabImagecropperModule.m +++ b/iphone/Classes/SeHyperlabImagecropperModule.m @@ -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;