@onekeyfe/react-native-image-crop-picker 3.0.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +83 -0
  3. package/ReactNativeImageCropPicker.podspec +40 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +144 -0
  6. package/android/gradle.properties +4 -0
  7. package/android/src/main/AndroidManifest.xml +24 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/reactnativeimagecroppicker/ImageCropPickerException.kt +45 -0
  10. package/android/src/main/java/com/margelo/nitro/reactnativeimagecroppicker/ImageCropPickerImageProcessor.kt +308 -0
  11. package/android/src/main/java/com/margelo/nitro/reactnativeimagecroppicker/ImageCropPickerSession.kt +297 -0
  12. package/android/src/main/java/com/margelo/nitro/reactnativeimagecroppicker/ReactNativeImageCropPicker.kt +69 -0
  13. package/android/src/main/java/com/margelo/nitro/reactnativeimagecroppicker/ReactNativeImageCropPickerPackage.kt +24 -0
  14. package/ios/ImageCropPickerError.swift +57 -0
  15. package/ios/ImageCropPickerImageProcessor.swift +343 -0
  16. package/ios/ImageCropPickerSession.swift +407 -0
  17. package/ios/ReactNativeImageCropPicker.swift +65 -0
  18. package/ios/TOCropViewController/Categories/UIImage+CropRotate.h +39 -0
  19. package/ios/TOCropViewController/Categories/UIImage+CropRotate.m +94 -0
  20. package/ios/TOCropViewController/Constants/TOCropViewConstants.h +63 -0
  21. package/ios/TOCropViewController/LICENSE +21 -0
  22. package/ios/TOCropViewController/Models/TOActivityCroppedImageProvider.h +38 -0
  23. package/ios/TOCropViewController/Models/TOActivityCroppedImageProvider.m +73 -0
  24. package/ios/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.h +64 -0
  25. package/ios/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.m +121 -0
  26. package/ios/TOCropViewController/Models/TOCropViewControllerTransitioning.h +49 -0
  27. package/ios/TOCropViewController/Models/TOCropViewControllerTransitioning.m +125 -0
  28. package/ios/TOCropViewController/Models/TOCroppedImageAttributes.h +38 -0
  29. package/ios/TOCropViewController/Models/TOCroppedImageAttributes.m +45 -0
  30. package/ios/TOCropViewController/Resources/Base.lproj/TOCropViewControllerLocalizable.strings +8 -0
  31. package/ios/TOCropViewController/Resources/PrivacyInfo.xcprivacy +14 -0
  32. package/ios/TOCropViewController/Resources/ar.lproj/TOCropViewControllerLocalizable.strings +9 -0
  33. package/ios/TOCropViewController/Resources/ca.lproj/TOCropViewControllerLocalizable.strings +8 -0
  34. package/ios/TOCropViewController/Resources/cs.lproj/TOCropViewControllerLocalizable.strings +8 -0
  35. package/ios/TOCropViewController/Resources/da-DK.lproj/TOCropViewControllerLocalizable.strings +8 -0
  36. package/ios/TOCropViewController/Resources/de.lproj/TOCropViewControllerLocalizable.strings +8 -0
  37. package/ios/TOCropViewController/Resources/en.lproj/TOCropViewControllerLocalizable.strings +8 -0
  38. package/ios/TOCropViewController/Resources/es.lproj/TOCropViewControllerLocalizable.strings +8 -0
  39. package/ios/TOCropViewController/Resources/fa-IR.lproj/TOCropViewControllerLocalizable.strings +8 -0
  40. package/ios/TOCropViewController/Resources/fa.lproj/TOCropViewControllerLocalizable.strings +8 -0
  41. package/ios/TOCropViewController/Resources/fi.lproj/TOCropViewControllerLocalizable.strings +8 -0
  42. package/ios/TOCropViewController/Resources/fr.lproj/TOCropViewControllerLocalizable.strings +8 -0
  43. package/ios/TOCropViewController/Resources/hu.lproj/TOCropViewControllerLocalizable.strings +9 -0
  44. package/ios/TOCropViewController/Resources/id.lproj/TOCropViewControllerLocalizable.strings +8 -0
  45. package/ios/TOCropViewController/Resources/it.lproj/TOCropViewControllerLocalizable.strings +8 -0
  46. package/ios/TOCropViewController/Resources/ja.lproj/TOCropViewControllerLocalizable.strings +8 -0
  47. package/ios/TOCropViewController/Resources/ko.lproj/TOCropViewControllerLocalizable.strings +8 -0
  48. package/ios/TOCropViewController/Resources/ms.lproj/TOCropViewControllerLocalizable.strings +8 -0
  49. package/ios/TOCropViewController/Resources/nl.lproj/TOCropViewControllerLocalizable.strings +8 -0
  50. package/ios/TOCropViewController/Resources/pl.lproj/TOCropViewControllerLocalizable.strings +8 -0
  51. package/ios/TOCropViewController/Resources/pt-BR.lproj/TOCropViewControllerLocalizable.strings +8 -0
  52. package/ios/TOCropViewController/Resources/pt.lproj/TOCropViewControllerLocalizable.strings +8 -0
  53. package/ios/TOCropViewController/Resources/ro.lproj/TOCropViewControllerLocalizable.strings +8 -0
  54. package/ios/TOCropViewController/Resources/ru.lproj/TOCropViewControllerLocalizable.strings +8 -0
  55. package/ios/TOCropViewController/Resources/sk.lproj/TOCropViewControllerLocalizable.strings +8 -0
  56. package/ios/TOCropViewController/Resources/tr.lproj/TOCropViewControllerLocalizable.strings +9 -0
  57. package/ios/TOCropViewController/Resources/uk.lproj/TOCropViewControllerLocalizable.strings +8 -0
  58. package/ios/TOCropViewController/Resources/vi.lproj/TOCropViewControllerLocalizable.strings +9 -0
  59. package/ios/TOCropViewController/Resources/zh-Hans.lproj/TOCropViewControllerLocalizable.strings +9 -0
  60. package/ios/TOCropViewController/Resources/zh-Hant.lproj/TOCropViewControllerLocalizable.strings +9 -0
  61. package/ios/TOCropViewController/TOCropViewController.h +479 -0
  62. package/ios/TOCropViewController/TOCropViewController.m +1355 -0
  63. package/ios/TOCropViewController/Views/TOCropOverlayView.h +43 -0
  64. package/ios/TOCropViewController/Views/TOCropOverlayView.m +240 -0
  65. package/ios/TOCropViewController/Views/TOCropScrollView.h +39 -0
  66. package/ios/TOCropViewController/Views/TOCropScrollView.m +48 -0
  67. package/ios/TOCropViewController/Views/TOCropToolbar.h +104 -0
  68. package/ios/TOCropViewController/Views/TOCropToolbar.m +783 -0
  69. package/ios/TOCropViewController/Views/TOCropView.h +311 -0
  70. package/ios/TOCropViewController/Views/TOCropView.m +1787 -0
  71. package/lib/module/ReactNativeImageCropPicker.nitro.js +4 -0
  72. package/lib/module/ReactNativeImageCropPicker.nitro.js.map +1 -0
  73. package/lib/module/index.js +83 -0
  74. package/lib/module/index.js.map +1 -0
  75. package/lib/module/package.json +1 -0
  76. package/lib/typescript/package.json +1 -0
  77. package/lib/typescript/src/ReactNativeImageCropPicker.nitro.d.ts +54 -0
  78. package/lib/typescript/src/ReactNativeImageCropPicker.nitro.d.ts.map +1 -0
  79. package/lib/typescript/src/index.d.ts +31 -0
  80. package/lib/typescript/src/index.d.ts.map +1 -0
  81. package/nitro.json +23 -0
  82. package/nitrogen/generated/android/c++/JCropRect.hpp +69 -0
  83. package/nitrogen/generated/android/c++/JHybridReactNativeImageCropPickerSpec.cpp +125 -0
  84. package/nitrogen/generated/android/c++/JHybridReactNativeImageCropPickerSpec.hpp +66 -0
  85. package/nitrogen/generated/android/c++/JImageCropPickerOptions.hpp +154 -0
  86. package/nitrogen/generated/android/c++/JPickedImage.hpp +88 -0
  87. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeimagecroppicker/CropRect.kt +66 -0
  88. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeimagecroppicker/HybridReactNativeImageCropPickerSpec.kt +69 -0
  89. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeimagecroppicker/ImageCropPickerOptions.kt +171 -0
  90. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeimagecroppicker/PickedImage.kt +86 -0
  91. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeimagecroppicker/reactnativeimagecroppickerOnLoad.kt +35 -0
  92. package/nitrogen/generated/android/reactnativeimagecroppicker+autolinking.cmake +81 -0
  93. package/nitrogen/generated/android/reactnativeimagecroppicker+autolinking.gradle +27 -0
  94. package/nitrogen/generated/android/reactnativeimagecroppickerOnLoad.cpp +54 -0
  95. package/nitrogen/generated/android/reactnativeimagecroppickerOnLoad.hpp +34 -0
  96. package/nitrogen/generated/ios/ReactNativeImageCropPicker+autolinking.rb +62 -0
  97. package/nitrogen/generated/ios/ReactNativeImageCropPicker-Swift-Cxx-Bridge.cpp +57 -0
  98. package/nitrogen/generated/ios/ReactNativeImageCropPicker-Swift-Cxx-Bridge.hpp +221 -0
  99. package/nitrogen/generated/ios/ReactNativeImageCropPicker-Swift-Cxx-Umbrella.hpp +55 -0
  100. package/nitrogen/generated/ios/ReactNativeImageCropPickerAutolinking.mm +33 -0
  101. package/nitrogen/generated/ios/ReactNativeImageCropPickerAutolinking.swift +26 -0
  102. package/nitrogen/generated/ios/c++/HybridReactNativeImageCropPickerSpecSwift.cpp +11 -0
  103. package/nitrogen/generated/ios/c++/HybridReactNativeImageCropPickerSpecSwift.hpp +116 -0
  104. package/nitrogen/generated/ios/swift/CropRect.swift +44 -0
  105. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  106. package/nitrogen/generated/ios/swift/Func_void_PickedImage.swift +46 -0
  107. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  108. package/nitrogen/generated/ios/swift/HybridReactNativeImageCropPickerSpec.swift +58 -0
  109. package/nitrogen/generated/ios/swift/HybridReactNativeImageCropPickerSpec_cxx.swift +202 -0
  110. package/nitrogen/generated/ios/swift/ImageCropPickerOptions.swift +474 -0
  111. package/nitrogen/generated/ios/swift/PickedImage.swift +96 -0
  112. package/nitrogen/generated/shared/c++/CropRect.hpp +95 -0
  113. package/nitrogen/generated/shared/c++/HybridReactNativeImageCropPickerSpec.cpp +24 -0
  114. package/nitrogen/generated/shared/c++/HybridReactNativeImageCropPickerSpec.hpp +71 -0
  115. package/nitrogen/generated/shared/c++/ImageCropPickerOptions.hpp +180 -0
  116. package/nitrogen/generated/shared/c++/PickedImage.hpp +114 -0
  117. package/package.json +173 -0
  118. package/src/ReactNativeImageCropPicker.nitro.ts +72 -0
  119. package/src/index.tsx +134 -0
@@ -0,0 +1,38 @@
1
+ //
2
+ // TOActivityCroppedImageProvider.h
3
+ //
4
+ // Copyright 2015-2026 Timothy Oliver. All rights reserved.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to
8
+ // deal in the Software without restriction, including without limitation the
9
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ // sell copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21
+ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ #import <UIKit/UIKit.h>
24
+
25
+ NS_ASSUME_NONNULL_BEGIN
26
+
27
+ @interface TOActivityCroppedImageProvider : UIActivityItemProvider
28
+
29
+ @property (nonnull, nonatomic, readonly) UIImage *image;
30
+ @property (nonatomic, readonly) CGRect cropFrame;
31
+ @property (nonatomic, readonly) NSInteger angle;
32
+ @property (nonatomic, readonly) BOOL circular;
33
+
34
+ - (nonnull instancetype)initWithImage:(nonnull UIImage *)image cropFrame:(CGRect)cropFrame angle:(NSInteger)angle circular:(BOOL)circular;
35
+
36
+ @end
37
+
38
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,73 @@
1
+ //
2
+ // TOActivityCroppedImageProvider.m
3
+ //
4
+ // Copyright 2015-2026 Timothy Oliver. All rights reserved.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to
8
+ // deal in the Software without restriction, including without limitation the
9
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ // sell copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21
+ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ #import "TOActivityCroppedImageProvider.h"
24
+
25
+ #import "UIImage+CropRotate.h"
26
+
27
+ @interface TOActivityCroppedImageProvider ()
28
+
29
+ @property (nonatomic, strong, readwrite) UIImage *image;
30
+ @property (nonatomic, assign, readwrite) CGRect cropFrame;
31
+ @property (nonatomic, assign, readwrite) NSInteger angle;
32
+ @property (nonatomic, assign, readwrite) BOOL circular;
33
+
34
+ @property (atomic, strong) UIImage *croppedImage;
35
+
36
+ @end
37
+
38
+ @implementation TOActivityCroppedImageProvider
39
+
40
+ - (instancetype)initWithImage:(UIImage *)image cropFrame:(CGRect)cropFrame angle:(NSInteger)angle circular:(BOOL)circular {
41
+ if (self = [super initWithPlaceholderItem:[UIImage new]]) {
42
+ _image = image;
43
+ _cropFrame = cropFrame;
44
+ _angle = angle;
45
+ _circular = circular;
46
+ }
47
+
48
+ return self;
49
+ }
50
+
51
+ #pragma mark - UIActivity Protocols -
52
+ - (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
53
+ return [[UIImage alloc] init];
54
+ }
55
+
56
+ - (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
57
+ return self.croppedImage;
58
+ }
59
+
60
+ #pragma mark - Image Generation -
61
+ - (id)item {
62
+ // If the user didn't touch the image, just forward along the original
63
+ if (self.angle == 0 && CGRectEqualToRect(self.cropFrame, (CGRect){CGPointZero, self.image.size})) {
64
+ self.croppedImage = self.image;
65
+ return self.croppedImage;
66
+ }
67
+
68
+ UIImage *image = [self.image croppedImageWithFrame:self.cropFrame angle:self.angle circularClip:self.circular];
69
+ self.croppedImage = image;
70
+ return self.croppedImage;
71
+ }
72
+
73
+ @end
@@ -0,0 +1,64 @@
1
+ //
2
+ // TOCropViewControllerAspectRatioPreset.h
3
+ //
4
+ // Copyright 2015-2026 Timothy Oliver. All rights reserved.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to
8
+ // deal in the Software without restriction, including without limitation the
9
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ // sell copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21
+ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ #import <Foundation/Foundation.h>
24
+ #import <UIKit/UIKit.h>
25
+
26
+ NS_ASSUME_NONNULL_BEGIN
27
+
28
+ @interface TOCropViewControllerAspectRatioPreset : NSObject
29
+
30
+ @property (nonatomic, readonly) CGSize size;
31
+ @property (nonatomic, readonly) NSString *title;
32
+
33
+ /// The original aspect ratio of the image (CGSizeZero)
34
+ @property (class, nonatomic, readonly) CGSize original;
35
+
36
+ /// A square aspect ratio (1:1)
37
+ @property (class, nonatomic, readonly) CGSize square;
38
+
39
+ /// A 3:2 aspect ratio
40
+ @property (class, nonatomic, readonly) CGSize ratio3x2;
41
+
42
+ /// A 5:3 aspect ratio
43
+ @property (class, nonatomic, readonly) CGSize ratio5x3;
44
+
45
+ /// A 4:3 aspect ratio
46
+ @property (class, nonatomic, readonly) CGSize ratio4x3;
47
+
48
+ /// A 5:4 aspect ratio
49
+ @property (class, nonatomic, readonly) CGSize ratio5x4;
50
+
51
+ /// A 7:5 aspect ratio
52
+ @property (class, nonatomic, readonly) CGSize ratio7x5;
53
+
54
+ /// A 16:9 aspect ratio
55
+ @property (class, nonatomic, readonly) CGSize ratio16x9;
56
+
57
+ + (NSArray<TOCropViewControllerAspectRatioPreset *> *)portraitPresets;
58
+ + (NSArray<TOCropViewControllerAspectRatioPreset *> *)landscapePresets;
59
+
60
+ - (nonnull instancetype)initWithSize:(CGSize)size title:(NSString *)title;
61
+
62
+ @end
63
+
64
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,121 @@
1
+ //
2
+ // TOCropViewControllerAspectRatioPreset.m
3
+ //
4
+ // Copyright 2015-2026 Timothy Oliver. All rights reserved.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to
8
+ // deal in the Software without restriction, including without limitation the
9
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ // sell copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21
+ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ #import "TOCropViewControllerAspectRatioPreset.h"
24
+ #if !__has_include(<TOCropViewController/TOCropViewConstants.h>)
25
+ #import "TOCropViewConstants.h"
26
+ #else
27
+ #import <TOCropViewController/TOCropViewConstants.h>
28
+ #endif
29
+
30
+ @interface TOCropViewControllerAspectRatioPreset ()
31
+
32
+ @property (nonatomic, strong, readwrite) NSString *title;
33
+
34
+ @end
35
+
36
+ @implementation TOCropViewControllerAspectRatioPreset
37
+
38
+ + (CGSize)original { return CGSizeZero; }
39
+ + (CGSize)square { return CGSizeMake(1.0f, 1.0f); }
40
+ + (CGSize)ratio3x2 { return CGSizeMake(3.0f, 2.0f); }
41
+ + (CGSize)ratio5x3 { return CGSizeMake(5.0f, 3.0f); }
42
+ + (CGSize)ratio4x3 { return CGSizeMake(4.0f, 3.0f); }
43
+ + (CGSize)ratio5x4 { return CGSizeMake(5.0f, 4.0f); }
44
+ + (CGSize)ratio7x5 { return CGSizeMake(7.0f, 5.0f); }
45
+ + (CGSize)ratio16x9 { return CGSizeMake(16.0f, 9.0f); }
46
+
47
+ - (instancetype)initWithSize:(CGSize)size title:(NSString *)title {
48
+ self = [super init];
49
+ if (self) {
50
+ _size = size;
51
+ _title = title;
52
+ }
53
+ return self;
54
+ }
55
+
56
+ - (BOOL)isEqual:(id)object {
57
+ if (self == object) {
58
+ return YES;
59
+ }
60
+ if (![object isKindOfClass:[TOCropViewControllerAspectRatioPreset class]]) {
61
+ return NO;
62
+ }
63
+ TOCropViewControllerAspectRatioPreset *other = (TOCropViewControllerAspectRatioPreset *)object;
64
+ return CGSizeEqualToSize(self.size, other.size) && [self.title isEqualToString:other.title];
65
+ }
66
+
67
+ - (NSUInteger)hash {
68
+ // Mix rather than XOR so symmetric sizes (eg 1:1, or 16:9 vs 9:16) don't collide
69
+ NSUInteger hash = 17;
70
+ hash = (hash * 31) + @(self.size.width).hash;
71
+ hash = (hash * 31) + @(self.size.height).hash;
72
+ hash = (hash * 31) + self.title.hash;
73
+ return hash;
74
+ }
75
+
76
+ + (NSArray<TOCropViewControllerAspectRatioPreset *> *)portraitPresets {
77
+ TOCropViewControllerAspectRatioPreset *object = [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeZero title:@"Original"];
78
+ NSBundle *resourceBundle = TO_CROP_VIEW_RESOURCE_BUNDLE_FOR_OBJECT(object);
79
+ return @[
80
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeZero
81
+ title:NSLocalizedStringFromTableInBundle(@"Original", @"TOCropViewControllerLocalizable", resourceBundle, nil)],
82
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(1.0f, 1.0f)
83
+ title:NSLocalizedStringFromTableInBundle(@"Square", @"TOCropViewControllerLocalizable", resourceBundle, nil)],
84
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(2.0f, 3.0f)
85
+ title:@"2:3"],
86
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(3.0f, 5.0f)
87
+ title:@"3:5"],
88
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(3.0f, 4.0f)
89
+ title:@"3:4"],
90
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(4.0f, 5.0f)
91
+ title:@"4:5"],
92
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(5.0f, 7.0f)
93
+ title:@"5:7"],
94
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(9.0f, 16.0f)
95
+ title:@"9:16"],
96
+ ];
97
+ }
98
+
99
+ + (NSArray<TOCropViewControllerAspectRatioPreset *> *)landscapePresets {
100
+ TOCropViewControllerAspectRatioPreset *object = [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeZero title:@"Original"];
101
+ NSBundle *resourceBundle = TO_CROP_VIEW_RESOURCE_BUNDLE_FOR_OBJECT(object);
102
+ return @[
103
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeZero
104
+ title:NSLocalizedStringFromTableInBundle(@"Original", @"TOCropViewControllerLocalizable", resourceBundle, nil)],
105
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(1.0f, 1.0f)
106
+ title:NSLocalizedStringFromTableInBundle(@"Square", @"TOCropViewControllerLocalizable", resourceBundle, nil)],
107
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(3.0f, 2.0f)
108
+ title:@"3:2"],
109
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(5.0f, 3.0f)
110
+ title:@"5:3"],
111
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(4.0f, 3.0f)
112
+ title:@"4:3"],
113
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(5.0f, 4.0f)
114
+ title:@"5:4"],
115
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(7.0f, 5.0f)
116
+ title:@"7:5"],
117
+ [[TOCropViewControllerAspectRatioPreset alloc] initWithSize:CGSizeMake(16.0f, 9.0f)
118
+ title:@"16:9"],
119
+ ];
120
+ }
121
+ @end
@@ -0,0 +1,49 @@
1
+ //
2
+ // TOCropViewControllerTransitioning.h
3
+ //
4
+ // Copyright 2015-2026 Timothy Oliver. All rights reserved.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to
8
+ // deal in the Software without restriction, including without limitation the
9
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ // sell copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21
+ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ #import <Foundation/Foundation.h>
24
+ #import <UIKit/UIKit.h>
25
+
26
+ NS_ASSUME_NONNULL_BEGIN
27
+
28
+ @interface TOCropViewControllerTransitioning : NSObject <UIViewControllerAnimatedTransitioning>
29
+
30
+ /* State Tracking */
31
+ @property (nonatomic, assign) BOOL isDismissing; // Whether this animation is presenting or dismissing
32
+ @property (nullable, nonatomic, strong) UIImage *image; // The image that will be used in this animation
33
+
34
+ /* Destination/Origin points */
35
+ @property (nullable, nonatomic, strong) UIView *fromView; // The origin view who's frame the image will be animated from
36
+ @property (nullable, nonatomic, strong) UIView *toView; // The destination view who's frame the image will animate to
37
+
38
+ @property (nonatomic, assign) CGRect fromFrame; // An origin frame that the image will be animated from
39
+ @property (nonatomic, assign) CGRect toFrame; // A destination frame the image will aniamte to
40
+
41
+ /* A block called just before the transition to perform any last-second UI configuration */
42
+ @property (nullable, nonatomic, copy) void (^prepareForTransitionHandler)(void);
43
+
44
+ /* Empties all of the properties in this object */
45
+ - (void)reset;
46
+
47
+ @end
48
+
49
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,125 @@
1
+ //
2
+ // TOCropViewControllerTransitioning.m
3
+ //
4
+ // Copyright 2015-2026 Timothy Oliver. All rights reserved.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to
8
+ // deal in the Software without restriction, including without limitation the
9
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ // sell copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21
+ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ #import "TOCropViewControllerTransitioning.h"
24
+
25
+ #import <QuartzCore/QuartzCore.h>
26
+
27
+ @implementation TOCropViewControllerTransitioning
28
+
29
+ - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
30
+ return 0.45f;
31
+ }
32
+
33
+ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
34
+ // Get the master view where the animation takes place
35
+ UIView *containerView = [transitionContext containerView];
36
+
37
+ // Get the origin/destination view controllers
38
+ UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
39
+ UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
40
+
41
+ // Work out which one is the crop view controller
42
+ UIViewController *cropViewController = (self.isDismissing == NO) ? toViewController : fromViewController;
43
+ UIViewController *previousController = (self.isDismissing == NO) ? fromViewController : toViewController;
44
+
45
+ // Just in case, match up the frame sizes
46
+ cropViewController.view.frame = containerView.bounds;
47
+ if (self.isDismissing) {
48
+ previousController.view.frame = containerView.bounds;
49
+ }
50
+
51
+ // Add the view layers beforehand as this will trigger the initial sets of layouts
52
+ if (self.isDismissing == NO) {
53
+ [containerView addSubview:cropViewController.view];
54
+
55
+ // Force a relayout now that the view is in the view hierarchy (so things like the safe area insets are now valid)]
56
+ [cropViewController.view setNeedsLayout];
57
+ [cropViewController.view layoutIfNeeded];
58
+ [cropViewController viewDidLayoutSubviews];
59
+ } else {
60
+ [containerView insertSubview:previousController.view belowSubview:cropViewController.view];
61
+ }
62
+
63
+ // Perform any last UI updates now so we can potentially factor them into our calculations, but after
64
+ // the container views have been set up
65
+ if (self.prepareForTransitionHandler) {
66
+ self.prepareForTransitionHandler();
67
+ }
68
+
69
+ // If origin/destination views were supplied, use them to supplant the
70
+ // frames
71
+ if (!self.isDismissing && self.fromView) {
72
+ self.fromFrame = [self.fromView.superview convertRect:self.fromView.frame toView:containerView];
73
+ } else if (self.isDismissing && self.toView) {
74
+ self.toFrame = [self.toView.superview convertRect:self.toView.frame toView:containerView];
75
+ }
76
+
77
+ UIImageView *imageView = nil;
78
+ if ((self.isDismissing && !CGRectIsEmpty(self.toFrame)) || (!self.isDismissing && !CGRectIsEmpty(self.fromFrame))) {
79
+ imageView = [[UIImageView alloc] initWithImage:self.image];
80
+ imageView.frame = self.fromFrame;
81
+ imageView.accessibilityIgnoresInvertColors = YES;
82
+ [containerView addSubview:imageView];
83
+ }
84
+
85
+ cropViewController.view.alpha = (self.isDismissing ? 1.0f : 0.0f);
86
+ if (imageView) {
87
+ [UIView animateWithDuration:[self transitionDuration:transitionContext]
88
+ delay:0.0f
89
+ usingSpringWithDamping:1.0f
90
+ initialSpringVelocity:0.7f
91
+ options:0
92
+ animations:^{
93
+ imageView.frame = self.toFrame;
94
+ }
95
+ completion:^(BOOL complete) {
96
+ [UIView animateWithDuration:0.25f
97
+ animations:^{
98
+ imageView.alpha = 0.0f;
99
+ }
100
+ completion:^(BOOL complete) {
101
+ [imageView removeFromSuperview];
102
+ }];
103
+ }];
104
+ }
105
+
106
+ [UIView animateWithDuration:[self transitionDuration:transitionContext]
107
+ animations:^{
108
+ cropViewController.view.alpha = (self.isDismissing ? 0.0f : 1.0f);
109
+ }
110
+ completion:^(BOOL complete) {
111
+ [self reset];
112
+ [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
113
+ }];
114
+ }
115
+
116
+ - (void)reset {
117
+ self.image = nil;
118
+ self.toView = nil;
119
+ self.fromView = nil;
120
+ self.fromFrame = CGRectZero;
121
+ self.toFrame = CGRectZero;
122
+ self.prepareForTransitionHandler = nil;
123
+ }
124
+
125
+ @end
@@ -0,0 +1,38 @@
1
+ //
2
+ // TOCroppedImageAttributes.h
3
+ //
4
+ // Copyright 2015-2026 Timothy Oliver. All rights reserved.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to
8
+ // deal in the Software without restriction, including without limitation the
9
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ // sell copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21
+ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ #import <Foundation/Foundation.h>
24
+ #import <UIKit/UIKit.h>
25
+
26
+ NS_ASSUME_NONNULL_BEGIN
27
+
28
+ @interface TOCroppedImageAttributes : NSObject
29
+
30
+ @property (nonatomic, readonly) NSInteger angle;
31
+ @property (nonatomic, readonly) CGRect croppedFrame;
32
+ @property (nonatomic, readonly) CGSize originalImageSize;
33
+
34
+ - (instancetype)initWithCroppedFrame:(CGRect)croppedFrame angle:(NSInteger)angle originalImageSize:(CGSize)originalSize;
35
+
36
+ @end
37
+
38
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,45 @@
1
+ //
2
+ // TOCroppedImageAttributes.m
3
+ //
4
+ // Copyright 2015-2026 Timothy Oliver. All rights reserved.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to
8
+ // deal in the Software without restriction, including without limitation the
9
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ // sell copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21
+ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ #import "TOCroppedImageAttributes.h"
24
+
25
+ @interface TOCroppedImageAttributes ()
26
+
27
+ @property (nonatomic, assign, readwrite) NSInteger angle;
28
+ @property (nonatomic, assign, readwrite) CGRect croppedFrame;
29
+ @property (nonatomic, assign, readwrite) CGSize originalImageSize;
30
+
31
+ @end
32
+
33
+ @implementation TOCroppedImageAttributes
34
+
35
+ - (instancetype)initWithCroppedFrame:(CGRect)croppedFrame angle:(NSInteger)angle originalImageSize:(CGSize)originalSize {
36
+ if (self = [super init]) {
37
+ _angle = angle;
38
+ _croppedFrame = croppedFrame;
39
+ _originalImageSize = originalSize;
40
+ }
41
+
42
+ return self;
43
+ }
44
+
45
+ @end
@@ -0,0 +1,8 @@
1
+ "Done" = "Done";
2
+ "Cancel" = "Cancel";
3
+ "Reset" = "Reset";
4
+ "Original" = "Original";
5
+ "Square" = "Square";
6
+ "Delete Changes" = "Delete Changes";
7
+ "Yes" = "Yes";
8
+ "No" = "No";
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>NSPrivacyTracking</key>
6
+ <false/>
7
+ <key>NSPrivacyTrackingDomains</key>
8
+ <array/>
9
+ <key>NSPrivacyCollectedDataTypes</key>
10
+ <array/>
11
+ <key>NSPrivacyAccessedAPITypes</key>
12
+ <array/>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,9 @@
1
+ "Done" = "تم";
2
+ "Cancel" = "إلغاء";
3
+ "Reset" = "إعادة تعيين";
4
+ "Original" = "أصلي";
5
+ "Square" = "مربع";
6
+ "Delete Changes" = "حذف التغييرات";
7
+ "Yes" = "نعم";
8
+ "No" = "لا";
9
+
@@ -0,0 +1,8 @@
1
+ "Done" = "Fet";
2
+ "Cancel" = "Cancel·lar";
3
+ "Reset" = "Restablir";
4
+ "Original" = "Original";
5
+ "Square" = "Quadrat";
6
+ "Delete Changes" = "Esborrar Canvis";
7
+ "Yes" = "Si";
8
+ "No" = "No";
@@ -0,0 +1,8 @@
1
+ "Done" = "Hotovo";
2
+ "Cancel" = "Zrušit";
3
+ "Reset" = "Reset";
4
+ "Original" = "Originál";
5
+ "Square" = "Čtverec";
6
+ "Delete Changes" = "Smazat změny";
7
+ "Yes" = "Ano";
8
+ "No" = "Ne";
@@ -0,0 +1,8 @@
1
+ "Done" = "OK";
2
+ "Cancel" = "Annuller";
3
+ "Reset" = "Nulstil";
4
+ "Original" = "Original";
5
+ "Square" = "Firkantet";
6
+ "Delete Changes" = "Slet ændringer";
7
+ "Yes" = "Ja";
8
+ "No" = "Nej";
@@ -0,0 +1,8 @@
1
+ "Done" = "Fertig";
2
+ "Cancel" = "Abbrechen";
3
+ "Reset" = "Zurücksetzen";
4
+ "Original" = "Original";
5
+ "Square" = "Quadrat";
6
+ "Delete Changes" = "Änderungen löschen";
7
+ "Yes" = "Ja";
8
+ "No" = "Nein";
@@ -0,0 +1,8 @@
1
+ "Done" = "Done";
2
+ "Cancel" = "Cancel";
3
+ "Reset" = "Reset";
4
+ "Original" = "Original";
5
+ "Square" = "Square";
6
+ "Delete Changes" = "Delete Changes";
7
+ "Yes" = "Yes";
8
+ "No" = "No";
@@ -0,0 +1,8 @@
1
+ "Done" = "Aceptar";
2
+ "Cancel" = "Cancelar";
3
+ "Reset" = "Cambiar";
4
+ "Original" = "Original";
5
+ "Square" = "Cuadrada";
6
+ "Delete Changes" = "Eliminar cambios";
7
+ "Yes" = "Sí";
8
+ "No" = "No";
@@ -0,0 +1,8 @@
1
+ "Done" = "انجام شد";
2
+ "Cancel" = "انصراف";
3
+ "Reset" = "بازنشانی";
4
+ "Original" = "اصلی";
5
+ "Square" = "مربع";
6
+ "Delete Changes" = "حذف تغییرات";
7
+ "Yes" = "آری";
8
+ "No" = "نه";