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

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 (34) hide show
  1. package/README.md +48 -5
  2. package/ReactNativeImageCropPicker.podspec +5 -3
  3. package/android/src/main/AndroidManifest.xml +2 -2
  4. package/android/src/main/java/com/margelo/nitro/reactnativeimagecroppicker/ImageCropPickerImageProcessor.kt +8 -18
  5. package/android/src/main/java/com/margelo/nitro/reactnativeimagecroppicker/ImageCropPickerSession.kt +21 -46
  6. package/android/src/main/java/com/margelo/nitro/reactnativeimagecroppicker/ImageCropperActivity.kt +636 -0
  7. package/android/src/main/java/com/margelo/nitro/reactnativeimagecroppicker/ImageCropperTheme.kt +188 -0
  8. package/android/src/main/res/drawable/image_crop_picker_rotate.xml +11 -0
  9. package/ios/ImageCropPickerImageProcessor.swift +8 -4
  10. package/ios/ImageCropPickerSession.swift +43 -46
  11. package/ios/ImageCropperTheme.swift +155 -0
  12. package/ios/ImageCropperViewController.swift +462 -0
  13. package/ios/TOCropViewController/Views/TOCropOverlayView.h +9 -0
  14. package/ios/TOCropViewController/Views/TOCropOverlayView.m +47 -3
  15. package/lib/typescript/src/ReactNativeImageCropPicker.nitro.d.ts +17 -11
  16. package/lib/typescript/src/ReactNativeImageCropPicker.nitro.d.ts.map +1 -1
  17. package/nitrogen/generated/android/c++/JHybridReactNativeImageCropPickerSpec.cpp +8 -0
  18. package/nitrogen/generated/android/c++/JImageCropPickerOptions.hpp +9 -45
  19. package/nitrogen/generated/android/c++/JImageCropperAppearance.hpp +108 -0
  20. package/nitrogen/generated/android/c++/JImageCropperColorScheme.hpp +58 -0
  21. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeimagecroppicker/ImageCropPickerOptions.kt +5 -55
  22. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeimagecroppicker/ImageCropperAppearance.kt +111 -0
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeimagecroppicker/ImageCropperColorScheme.kt +23 -0
  24. package/nitrogen/generated/ios/ReactNativeImageCropPicker-Swift-Cxx-Bridge.hpp +36 -0
  25. package/nitrogen/generated/ios/ReactNativeImageCropPicker-Swift-Cxx-Umbrella.hpp +6 -0
  26. package/nitrogen/generated/ios/c++/HybridReactNativeImageCropPickerSpecSwift.hpp +6 -0
  27. package/nitrogen/generated/ios/swift/ImageCropPickerOptions.swift +6 -193
  28. package/nitrogen/generated/ios/swift/ImageCropperAppearance.swift +251 -0
  29. package/nitrogen/generated/ios/swift/ImageCropperColorScheme.swift +40 -0
  30. package/nitrogen/generated/shared/c++/ImageCropPickerOptions.hpp +8 -46
  31. package/nitrogen/generated/shared/c++/ImageCropperAppearance.hpp +134 -0
  32. package/nitrogen/generated/shared/c++/ImageCropperColorScheme.hpp +76 -0
  33. package/package.json +1 -1
  34. package/src/ReactNativeImageCropPicker.nitro.ts +29 -13
@@ -0,0 +1,134 @@
1
+ ///
2
+ /// ImageCropperAppearance.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `ImageCropperColorScheme` to properly resolve imports.
32
+ namespace margelo::nitro::reactnativeimagecroppicker { enum class ImageCropperColorScheme; }
33
+
34
+ #include "ImageCropperColorScheme.hpp"
35
+ #include <optional>
36
+ #include <string>
37
+
38
+ namespace margelo::nitro::reactnativeimagecroppicker {
39
+
40
+ /**
41
+ * A struct which can be represented as a JavaScript object (ImageCropperAppearance).
42
+ */
43
+ struct ImageCropperAppearance final {
44
+ public:
45
+ std::optional<ImageCropperColorScheme> colorScheme SWIFT_PRIVATE;
46
+ std::optional<std::string> backgroundColor SWIFT_PRIVATE;
47
+ std::optional<std::string> titleColor SWIFT_PRIVATE;
48
+ std::optional<std::string> iconColor SWIFT_PRIVATE;
49
+ std::optional<std::string> cancelButtonColor SWIFT_PRIVATE;
50
+ std::optional<std::string> cancelButtonPressedColor SWIFT_PRIVATE;
51
+ std::optional<std::string> cancelButtonTextColor SWIFT_PRIVATE;
52
+ std::optional<std::string> confirmButtonColor SWIFT_PRIVATE;
53
+ std::optional<std::string> confirmButtonPressedColor SWIFT_PRIVATE;
54
+ std::optional<std::string> confirmButtonTextColor SWIFT_PRIVATE;
55
+ std::optional<std::string> titleFontFamily SWIFT_PRIVATE;
56
+ std::optional<std::string> buttonFontFamily SWIFT_PRIVATE;
57
+ std::optional<double> scale SWIFT_PRIVATE;
58
+
59
+ public:
60
+ ImageCropperAppearance() = default;
61
+ explicit ImageCropperAppearance(std::optional<ImageCropperColorScheme> colorScheme, std::optional<std::string> backgroundColor, std::optional<std::string> titleColor, std::optional<std::string> iconColor, std::optional<std::string> cancelButtonColor, std::optional<std::string> cancelButtonPressedColor, std::optional<std::string> cancelButtonTextColor, std::optional<std::string> confirmButtonColor, std::optional<std::string> confirmButtonPressedColor, std::optional<std::string> confirmButtonTextColor, std::optional<std::string> titleFontFamily, std::optional<std::string> buttonFontFamily, std::optional<double> scale): colorScheme(colorScheme), backgroundColor(backgroundColor), titleColor(titleColor), iconColor(iconColor), cancelButtonColor(cancelButtonColor), cancelButtonPressedColor(cancelButtonPressedColor), cancelButtonTextColor(cancelButtonTextColor), confirmButtonColor(confirmButtonColor), confirmButtonPressedColor(confirmButtonPressedColor), confirmButtonTextColor(confirmButtonTextColor), titleFontFamily(titleFontFamily), buttonFontFamily(buttonFontFamily), scale(scale) {}
62
+
63
+ public:
64
+ friend bool operator==(const ImageCropperAppearance& lhs, const ImageCropperAppearance& rhs) = default;
65
+ };
66
+
67
+ } // namespace margelo::nitro::reactnativeimagecroppicker
68
+
69
+ namespace margelo::nitro {
70
+
71
+ // C++ ImageCropperAppearance <> JS ImageCropperAppearance (object)
72
+ template <>
73
+ struct JSIConverter<margelo::nitro::reactnativeimagecroppicker::ImageCropperAppearance> final {
74
+ static inline margelo::nitro::reactnativeimagecroppicker::ImageCropperAppearance fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
75
+ jsi::Object obj = arg.asObject(runtime);
76
+ return margelo::nitro::reactnativeimagecroppicker::ImageCropperAppearance(
77
+ JSIConverter<std::optional<margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "colorScheme"))),
78
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "backgroundColor"))),
79
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "titleColor"))),
80
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "iconColor"))),
81
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelButtonColor"))),
82
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelButtonPressedColor"))),
83
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelButtonTextColor"))),
84
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confirmButtonColor"))),
85
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confirmButtonPressedColor"))),
86
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confirmButtonTextColor"))),
87
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "titleFontFamily"))),
88
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "buttonFontFamily"))),
89
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scale")))
90
+ );
91
+ }
92
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativeimagecroppicker::ImageCropperAppearance& arg) {
93
+ jsi::Object obj(runtime);
94
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "colorScheme"), JSIConverter<std::optional<margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme>>::toJSI(runtime, arg.colorScheme));
95
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "backgroundColor"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.backgroundColor));
96
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "titleColor"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.titleColor));
97
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "iconColor"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.iconColor));
98
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "cancelButtonColor"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.cancelButtonColor));
99
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "cancelButtonPressedColor"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.cancelButtonPressedColor));
100
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "cancelButtonTextColor"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.cancelButtonTextColor));
101
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "confirmButtonColor"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.confirmButtonColor));
102
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "confirmButtonPressedColor"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.confirmButtonPressedColor));
103
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "confirmButtonTextColor"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.confirmButtonTextColor));
104
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "titleFontFamily"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.titleFontFamily));
105
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "buttonFontFamily"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.buttonFontFamily));
106
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "scale"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.scale));
107
+ return obj;
108
+ }
109
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
110
+ if (!value.isObject()) {
111
+ return false;
112
+ }
113
+ jsi::Object obj = value.getObject(runtime);
114
+ if (!nitro::isPlainObject(runtime, obj)) {
115
+ return false;
116
+ }
117
+ if (!JSIConverter<std::optional<margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "colorScheme")))) return false;
118
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "backgroundColor")))) return false;
119
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "titleColor")))) return false;
120
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "iconColor")))) return false;
121
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelButtonColor")))) return false;
122
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelButtonPressedColor")))) return false;
123
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cancelButtonTextColor")))) return false;
124
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confirmButtonColor")))) return false;
125
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confirmButtonPressedColor")))) return false;
126
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confirmButtonTextColor")))) return false;
127
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "titleFontFamily")))) return false;
128
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "buttonFontFamily")))) return false;
129
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scale")))) return false;
130
+ return true;
131
+ }
132
+ };
133
+
134
+ } // namespace margelo::nitro
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// ImageCropperColorScheme.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::reactnativeimagecroppicker {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (ImageCropperColorScheme).
30
+ */
31
+ enum class ImageCropperColorScheme {
32
+ LIGHT SWIFT_NAME(light) = 0,
33
+ DARK SWIFT_NAME(dark) = 1,
34
+ } CLOSED_ENUM;
35
+
36
+ } // namespace margelo::nitro::reactnativeimagecroppicker
37
+
38
+ namespace margelo::nitro {
39
+
40
+ // C++ ImageCropperColorScheme <> JS ImageCropperColorScheme (union)
41
+ template <>
42
+ struct JSIConverter<margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme> final {
43
+ static inline margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
44
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
45
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
46
+ case hashString("light"): return margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme::LIGHT;
47
+ case hashString("dark"): return margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme::DARK;
48
+ default: [[unlikely]]
49
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ImageCropperColorScheme - invalid value!");
50
+ }
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme arg) {
53
+ switch (arg) {
54
+ case margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme::LIGHT: return JSIConverter<std::string>::toJSI(runtime, "light");
55
+ case margelo::nitro::reactnativeimagecroppicker::ImageCropperColorScheme::DARK: return JSIConverter<std::string>::toJSI(runtime, "dark");
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert ImageCropperColorScheme to JS - invalid value: "
58
+ + std::to_string(static_cast<int>(arg)) + "!");
59
+ }
60
+ }
61
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
62
+ if (!value.isString()) {
63
+ return false;
64
+ }
65
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
66
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
67
+ case hashString("light"):
68
+ case hashString("dark"):
69
+ return true;
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-image-crop-picker",
3
- "version": "3.0.147",
3
+ "version": "3.0.148",
4
4
  "description": "Single photo picker and cropper Nitro module for OneKey, replacing react-native-image-crop-picker",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -20,6 +20,32 @@ export interface PickedImage {
20
20
  filename?: string;
21
21
  }
22
22
 
23
+ export type ImageCropperColorScheme = 'light' | 'dark';
24
+
25
+ // Colors and fonts of the cropper screen, which is identical on iOS and
26
+ // Android. Colors are CSS hex strings (#RGB, #RRGGBB or #RRGGBBAA). Anything
27
+ // left out falls back to OneKey's own palette for `colorScheme`.
28
+ export interface ImageCropperAppearance {
29
+ // Defaults to the system appearance.
30
+ colorScheme?: ImageCropperColorScheme;
31
+ // Page background. The area outside the crop box is this color, 70% opaque.
32
+ backgroundColor?: string;
33
+ // Title, and the crop box border.
34
+ titleColor?: string;
35
+ // The rotate button.
36
+ iconColor?: string;
37
+ cancelButtonColor?: string;
38
+ cancelButtonPressedColor?: string;
39
+ cancelButtonTextColor?: string;
40
+ confirmButtonColor?: string;
41
+ confirmButtonPressedColor?: string;
42
+ confirmButtonTextColor?: string;
43
+ titleFontFamily?: string;
44
+ buttonFontFamily?: string;
45
+ // Multiplies every size and spacing, for apps that scale their UI.
46
+ scale?: number;
47
+ }
48
+
23
49
  export interface ImageCropPickerOptions {
24
50
  // Target size of the cropped image. Also defines the crop aspect ratio.
25
51
  width?: number;
@@ -29,26 +55,16 @@ export interface ImageCropPickerOptions {
29
55
  compressImageQuality?: number;
30
56
  compressImageMaxWidth?: number;
31
57
  compressImageMaxHeight?: number;
58
+ // Lets the user resize the crop box to any aspect ratio.
32
59
  freeStyleCropEnabled?: boolean;
33
60
  cropperCircleOverlay?: boolean;
34
61
  cropperToolbarTitle?: string;
35
62
  cropperChooseText?: string;
36
63
  cropperCancelText?: string;
37
- // iOS only
38
- cropperChooseColor?: string;
39
- cropperCancelColor?: string;
40
64
  cropperRotateButtonsHidden?: boolean;
41
- // Android only
42
- cropperActiveWidgetColor?: string;
43
- cropperToolbarColor?: string;
44
- cropperToolbarWidgetColor?: string;
45
- cropperStatusBarLight?: boolean;
46
- cropperNavigationBarLight?: boolean;
65
+ // Shows the rule-of-thirds grid inside the crop box.
47
66
  showCropGuidelines?: boolean;
48
- showCropFrame?: boolean;
49
- enableRotationGesture?: boolean;
50
- hideBottomControls?: boolean;
51
- disableCropperColorSetters?: boolean;
67
+ cropperAppearance?: ImageCropperAppearance;
52
68
  }
53
69
 
54
70
  export interface ReactNativeImageCropPicker