Skip to content
Permalink
Browse files

Merge pull request #213 from ruslanskorb/develop

Version 2.2.3
  • Loading branch information...
ruslanskorb committed Jul 25, 2019
2 parents 4f69983 + 3494d29 commit 63e36bd74f848fe133a9eb6a6506b4655fa33401
Showing with 133 additions and 84 deletions.
  1. +1 −1 Example/RSKImageCropperExample/RSKImageCropperExample-Info.plist
  2. +81 −33 Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m
  3. BIN ...ViewControllerSpec/crop_image_crop_image_with_any_image_orientation_UIImageOrientationDown@2x.png
  4. BIN ...rollerSpec/crop_image_crop_image_with_any_image_orientation_UIImageOrientationDownMirrored@2x.png
  5. BIN ...ViewControllerSpec/crop_image_crop_image_with_any_image_orientation_UIImageOrientationLeft@2x.png
  6. BIN ...rollerSpec/crop_image_crop_image_with_any_image_orientation_UIImageOrientationLeftMirrored@2x.png
  7. BIN ...iewControllerSpec/crop_image_crop_image_with_any_image_orientation_UIImageOrientationRight@2x.png
  8. BIN ...ollerSpec/crop_image_crop_image_with_any_image_orientation_UIImageOrientationRightMirrored@2x.png
  9. BIN ...ntrollerSpec/crop_image_crop_image_with_any_image_orientation_UIImageOrientationUpMirrored@2x.png
  10. BIN ...op_mode_is_RSKImageCropModeCircle_correctly_crop_the_image_when_all_properties_are_default@2x.png
  11. BIN ...ode_is_RSKImageCropModeCircle_correctly_crop_the_image_when_applyMaskToCroppedImage_is_YES@2x.png
  12. BIN ...e_is_RSKImageCropModeCircle_correctly_crop_the_image_when_content_offset_is_not_equal_to_0@2x.png
  13. BIN ...eCircle_correctly_crop_the_image_when_rotation_angle_and_content_offset_are_not_equal_to_0@2x.png
  14. BIN ...e_is_RSKImageCropModeCircle_correctly_crop_the_image_when_rotation_angle_is_not_equal_to_0@2x.png
  15. BIN ...op_mode_is_RSKImageCropModeCustom_correctly_crop_the_image_when_all_properties_are_default@2x.png
  16. BIN ...ode_is_RSKImageCropModeCustom_correctly_crop_the_image_when_applyMaskToCroppedImage_is_YES@2x.png
  17. BIN ..._is_RSKImageCropModeCustom_correctly_crop_the_image_when_content_offset_are_not_equal_to_0@2x.png
  18. BIN ...eCustom_correctly_crop_the_image_when_rotation_angle_and_content_offset_are_not_equal_to_0@2x.png
  19. BIN ...e_is_RSKImageCropModeCustom_correctly_crop_the_image_when_rotation_angle_is_not_equal_to_0@2x.png
  20. BIN ...op_mode_is_RSKImageCropModeSquare_correctly_crop_the_image_when_all_properties_are_default@2x.png
  21. BIN ...ode_is_RSKImageCropModeSquare_correctly_crop_the_image_when_applyMaskToCroppedImage_is_YES@2x.png
  22. BIN ..._is_RSKImageCropModeSquare_correctly_crop_the_image_when_content_offset_are_not_equal_to_0@2x.png
  23. BIN ...eSquare_correctly_crop_the_image_when_rotation_angle_and_content_offset_are_not_equal_to_0@2x.png
  24. BIN ...e_is_RSKImageCropModeSquare_correctly_crop_the_image_when_rotation_angle_is_not_equal_to_0@2x.png
  25. BIN ...leTests/ReferenceImages/RSKImageScrollViewSpec/visuals_looks_right_with_minimum_zoom_scale@2x.png
  26. +1 −1 Framework/Info.plist
  27. +1 −1 RSKImageCropper.podspec
  28. +6 −6 RSKImageCropper.xcodeproj/project.pbxproj
  29. +29 −7 RSKImageCropper/RSKImageCropViewController.m
  30. +14 −35 RSKImageCropper/RSKImageScrollView.m
@@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.2.2</string>
<string>2.2.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
@@ -131,7 +131,6 @@ - (void)onChooseButtonTouch:(UIBarButtonItem *)sender;
- (void)layoutImageScrollView;
- (void)reset:(BOOL)animated;
- (void)resetContentOffset;
- (void)resetFrame;
- (void)resetRotation;
- (void)resetZoomScale;

@@ -219,17 +218,24 @@ - (void)resetZoomScale;
});

describe(@"crop image", ^{
__block UIImageView *croppedImageImageView = nil;

dispatch_block_t sharedIt = ^{
UIImage *croppedImage = [imageCropViewController croppedImage:imageCropViewController.originalImage cropMode:imageCropViewController.cropMode cropRect:imageCropViewController.cropRect imageRect:imageCropViewController.imageRect rotationAngle:imageCropViewController.rotationAngle zoomScale:imageCropViewController.zoomScale maskPath:imageCropViewController.maskPath applyMaskToCroppedImage:imageCropViewController.applyMaskToCroppedImage];

expect(croppedImage).notTo.beNil();
expect(croppedImage.imageOrientation).to.equal(UIImageOrientationUp);
expect(croppedImage.scale).to.equal(imageCropViewController.originalImage.scale);

croppedImageImageView.image = croppedImage;
expect(croppedImageImageView).haveValidSnapshot();
};

describe(@"crop mode is `RSKImageCropModeCircle`", ^{
before(^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];
croppedImageImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 130.0, 130.0)];
croppedImageImageView.contentMode = UIViewContentModeScaleAspectFit;

sharedLoadView();
});
@@ -244,6 +250,19 @@ - (void)resetZoomScale;
sharedIt();
});

it(@"correctly crop the image when content offset is not equal to 0", ^{
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when rotation angle and content offset are not equal to 0", ^{
imageCropViewController.rotationAngle = M_PI_4;
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when `applyMaskToCroppedImage` is `YES`", ^{
imageCropViewController.applyMaskToCroppedImage = YES;

@@ -272,6 +291,19 @@ - (void)resetZoomScale;
sharedIt();
});

it(@"correctly crop the image when content offset are not equal to 0", ^{
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when rotation angle and content offset are not equal to 0", ^{
imageCropViewController.rotationAngle = M_PI_4;
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when `applyMaskToCroppedImage` is `YES`", ^{
imageCropViewController.applyMaskToCroppedImage = YES;

@@ -284,8 +316,10 @@ - (void)resetZoomScale;
});

describe(@"crop mode is `RSKImageCropModeCustom`", ^{
__block id <RSKImageCropViewControllerDataSource> dataSourceObject = nil;

before(^{
RSKImageCropViewControllerDataSourceObject1 *dataSourceObject = [[RSKImageCropViewControllerDataSourceObject1 alloc] init];
dataSourceObject = [[RSKImageCropViewControllerDataSourceObject1 alloc] init];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCustom];
imageCropViewController.dataSource = dataSourceObject;
@@ -303,76 +337,87 @@ - (void)resetZoomScale;
sharedIt();
});

it(@"correctly crop the image when content offset are not equal to 0", ^{
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when rotation angle and content offset are not equal to 0", ^{
imageCropViewController.rotationAngle = M_PI_4;
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when `applyMaskToCroppedImage` is `YES`", ^{
imageCropViewController.applyMaskToCroppedImage = YES;

sharedIt();
});

after(^{
dataSourceObject = nil;
imageCropViewController = nil;
});
});

describe(@"crop image with any image orientation", ^{
before(^{
imageCropViewController = [[RSKImageCropViewController alloc] init];
});

it(@"UIImageOrientationDown", ^{
UIImage *downImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationDown];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:downImage];
imageCropViewController.originalImage = downImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationLeft", ^{
UIImage *leftImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationLeft];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:leftImage];
imageCropViewController.originalImage = leftImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationRight", ^{
UIImage *rightImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationRight];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:rightImage];
imageCropViewController.originalImage = rightImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationUpMirrored", ^{
UIImage *upMirroredImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationUpMirrored];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:upMirroredImage];
imageCropViewController.originalImage = upMirroredImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationDownMirrored", ^{
UIImage *downMirroredImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationDownMirrored];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:downMirroredImage];
imageCropViewController.originalImage = downMirroredImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationLeftMirrored", ^{
UIImage *leftMirroredImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationLeftMirrored];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:leftMirroredImage];
imageCropViewController.originalImage = leftMirroredImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationRightMirrored", ^{
UIImage *rightMirroredImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationRightMirrored];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:rightMirroredImage];
imageCropViewController.originalImage = rightMirroredImage;

sharedLoadView();
sharedIt();
@@ -523,30 +568,28 @@ - (void)resetZoomScale;
});

describe(@"crop view", ^{
dispatch_block_t sharedIt = ^{
sharedLoadView();

expect(imageCropViewController.view).to.haveValidSnapshot();
};

describe(@"portrait", ^{
dispatch_block_t sharedPortraitIt = ^{
imageCropViewController.view.frame = CGRectMake(0, 0, 320, 568);

sharedIt();
sharedLoadView();
};

describe(@"crop mode", ^{
it(@"looks right when crop mode is `RSKImageCropModeCircle`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];

sharedPortraitIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});

it(@"looks right when crop mode is `RSKImageCropModeSquare`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];

sharedPortraitIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});

it(@"looks right when crop mode is `RSKImageCropModeCustom`", ^{
@@ -556,6 +599,8 @@ - (void)resetZoomScale;
imageCropViewController.dataSource = dataSourceObject;

sharedPortraitIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});
});

@@ -565,6 +610,8 @@ - (void)resetZoomScale;
imageCropViewController.maskLayerStrokeColor = [UIColor whiteColor];

sharedPortraitIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});
});
});
@@ -573,20 +620,24 @@ - (void)resetZoomScale;
dispatch_block_t sharedLandscapeIt = ^{
imageCropViewController.view.frame = CGRectMake(0, 0, 568, 320);

sharedIt();
sharedLoadView();
};

describe(@"crop mode", ^{
it(@"looks right when crop mode is `RSKImageCropModeCircle`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];

sharedLandscapeIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});

it(@"looks right when crop mode is `RSKImageCropModeSquare`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];

sharedLandscapeIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});

it(@"looks right when crop mode is `RSKImageCropModeCustom`", ^{
@@ -596,6 +647,8 @@ - (void)resetZoomScale;
imageCropViewController.dataSource = dataSourceObject;

sharedLandscapeIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});
});

@@ -605,6 +658,8 @@ - (void)resetZoomScale;
imageCropViewController.maskLayerStrokeColor = [UIColor whiteColor];

sharedLandscapeIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});
});
});
@@ -824,14 +879,6 @@ - (void)resetZoomScale;
expect(imageCropViewController.rotationAngle).to.equal(initialRotationAngle);
});

it(@"should reset frame", ^{
CGRect initialFrame = imageCropViewController.imageScrollView.frame;
CGRect testFrame = CGRectOffset(imageCropViewController.maskRect, 100, 100);
imageCropViewController.imageScrollView.frame = testFrame;
[imageCropViewController resetFrame];
expect(imageCropViewController.imageScrollView.frame).to.equal(initialFrame);
});

it(@"should reset zoom scale", ^{
CGFloat initialZoomScale = imageCropViewController.zoomScale;
CGFloat testZoomScale = initialZoomScale + 0.1;
@@ -912,12 +959,13 @@ - (void)resetZoomScale;
imageCropViewController = [[RSKImageCropViewController alloc] init];
id mockImageCropViewController = [OCMockObject partialMockForObject:imageCropViewController];

[[mockImageCropViewController expect] setRotationAngle:testRotationAngle];
[[mockImageCropViewController expect] layoutImageScrollView];

[mockImageCropViewController handleRotation:mockRotationGestureRecognizer];

expect(imageCropViewController.rotationAngle).to.equal(testRotationAngle);
[mockImageCropViewController verifyWithDelay:kLayoutImageScrollViewAnimationDuration];

[mockImageCropViewController stopMocking];
});

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.2.2</string>
<string>2.2.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RSKImageCropper'
s.version = '2.2.2'
s.version = '2.2.3'
s.summary = 'An image cropper for iOS like in the Contacts app with support for landscape orientation.'
s.homepage = 'https://github.com/ruslanskorb/RSKImageCropper'
s.license = { :type => 'MIT', :file => 'LICENSE' }
@@ -238,7 +238,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2.2.2;
CURRENT_PROJECT_VERSION = 2.2.3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@@ -297,7 +297,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2.2.2;
CURRENT_PROJECT_VERSION = 2.2.3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -324,8 +324,8 @@
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.2.2;
DYLIB_CURRENT_VERSION = 2.2.2;
DYLIB_COMPATIBILITY_VERSION = 2.2.3;
DYLIB_CURRENT_VERSION = 2.2.3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Framework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
@@ -342,8 +342,8 @@
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.2.2;
DYLIB_CURRENT_VERSION = 2.2.2;
DYLIB_COMPATIBILITY_VERSION = 2.2.3;
DYLIB_CURRENT_VERSION = 2.2.3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Framework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";

0 comments on commit 63e36bd

Please sign in to comment.
You can’t perform that action at this time.