react-native-picture-selector 1.0.0

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 (99) hide show
  1. package/README.md +627 -0
  2. package/android/CMakeLists.txt +30 -0
  3. package/android/build.gradle +79 -0
  4. package/android/proguard-rules.pro +21 -0
  5. package/android/src/main/AndroidManifest.xml +39 -0
  6. package/android/src/main/kotlin/com/margelo/pictureselector/GlideEngine.kt +80 -0
  7. package/android/src/main/kotlin/com/margelo/pictureselector/HybridPictureSelector.kt +138 -0
  8. package/android/src/main/kotlin/com/margelo/pictureselector/LubanCompressEngine.kt +58 -0
  9. package/android/src/main/kotlin/com/margelo/pictureselector/MediaAssetMapper.kt +69 -0
  10. package/android/src/main/kotlin/com/margelo/pictureselector/NitroPictureSelectorPackage.kt +52 -0
  11. package/android/src/main/kotlin/com/margelo/pictureselector/PictureSelectorOptionsMapper.kt +105 -0
  12. package/android/src/main/kotlin/com/margelo/pictureselector/UCropEngine.kt +57 -0
  13. package/android/src/main/res/xml/file_paths.xml +8 -0
  14. package/ios/HybridPictureSelector.swift +386 -0
  15. package/ios/NitroPictureSelector.podspec +39 -0
  16. package/lib/commonjs/PictureSelector.js +74 -0
  17. package/lib/commonjs/PictureSelector.js.map +1 -0
  18. package/lib/commonjs/index.js +39 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/package.json +1 -0
  21. package/lib/commonjs/specs/PictureSelector.nitro.js +34 -0
  22. package/lib/commonjs/specs/PictureSelector.nitro.js.map +1 -0
  23. package/lib/commonjs/types.js +44 -0
  24. package/lib/commonjs/types.js.map +1 -0
  25. package/lib/commonjs/usePictureSelector.js +122 -0
  26. package/lib/commonjs/usePictureSelector.js.map +1 -0
  27. package/lib/module/PictureSelector.js +71 -0
  28. package/lib/module/PictureSelector.js.map +1 -0
  29. package/lib/module/index.js +6 -0
  30. package/lib/module/index.js.map +1 -0
  31. package/lib/module/package.json +1 -0
  32. package/lib/module/specs/PictureSelector.nitro.js +36 -0
  33. package/lib/module/specs/PictureSelector.nitro.js.map +1 -0
  34. package/lib/module/types.js +29 -0
  35. package/lib/module/types.js.map +1 -0
  36. package/lib/module/usePictureSelector.js +119 -0
  37. package/lib/module/usePictureSelector.js.map +1 -0
  38. package/lib/typescript/PictureSelector.d.ts +23 -0
  39. package/lib/typescript/PictureSelector.d.ts.map +1 -0
  40. package/lib/typescript/index.d.ts +6 -0
  41. package/lib/typescript/index.d.ts.map +1 -0
  42. package/lib/typescript/specs/PictureSelector.nitro.d.ts +96 -0
  43. package/lib/typescript/specs/PictureSelector.nitro.d.ts.map +1 -0
  44. package/lib/typescript/types.d.ts +16 -0
  45. package/lib/typescript/types.d.ts.map +1 -0
  46. package/lib/typescript/usePictureSelector.d.ts +26 -0
  47. package/lib/typescript/usePictureSelector.d.ts.map +1 -0
  48. package/nitro.json +11 -0
  49. package/nitrogen/generated/.gitattributes +1 -0
  50. package/nitrogen/generated/android/NitroPictureSelector+autolinking.cmake +81 -0
  51. package/nitrogen/generated/android/NitroPictureSelector+autolinking.gradle +27 -0
  52. package/nitrogen/generated/android/NitroPictureSelectorOnLoad.cpp +41 -0
  53. package/nitrogen/generated/android/NitroPictureSelectorOnLoad.hpp +34 -0
  54. package/nitrogen/generated/android/c++/JCompressOptions.hpp +69 -0
  55. package/nitrogen/generated/android/c++/JCropOptions.hpp +73 -0
  56. package/nitrogen/generated/android/c++/JHybridHybridPictureSelectorSpec.cpp +125 -0
  57. package/nitrogen/generated/android/c++/JHybridHybridPictureSelectorSpec.hpp +64 -0
  58. package/nitrogen/generated/android/c++/JMediaAsset.hpp +98 -0
  59. package/nitrogen/generated/android/c++/JMediaType.hpp +61 -0
  60. package/nitrogen/generated/android/c++/JPickerTheme.hpp +64 -0
  61. package/nitrogen/generated/android/c++/JPictureSelectorOptions.hpp +121 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/margelo/pictureselector/CompressOptions.kt +47 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/margelo/pictureselector/CropOptions.kt +50 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/margelo/pictureselector/HybridHybridPictureSelectorSpec.kt +59 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/margelo/pictureselector/MediaAsset.kt +68 -0
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/margelo/pictureselector/MediaType.kt +24 -0
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/margelo/pictureselector/NitroPictureSelectorOnLoad.kt +35 -0
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/margelo/pictureselector/PickerTheme.kt +25 -0
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/margelo/pictureselector/PictureSelectorOptions.kt +65 -0
  70. package/nitrogen/generated/ios/NitroPictureSelector+autolinking.rb +60 -0
  71. package/nitrogen/generated/ios/NitroPictureSelector-Swift-Cxx-Bridge.cpp +49 -0
  72. package/nitrogen/generated/ios/NitroPictureSelector-Swift-Cxx-Bridge.hpp +270 -0
  73. package/nitrogen/generated/ios/NitroPictureSelector-Swift-Cxx-Umbrella.hpp +65 -0
  74. package/nitrogen/generated/ios/c++/HybridHybridPictureSelectorSpecSwift.cpp +11 -0
  75. package/nitrogen/generated/ios/c++/HybridHybridPictureSelectorSpecSwift.hpp +110 -0
  76. package/nitrogen/generated/ios/swift/CompressOptions.swift +83 -0
  77. package/nitrogen/generated/ios/swift/CropOptions.swift +101 -0
  78. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  79. package/nitrogen/generated/ios/swift/Func_void_std__vector_MediaAsset_.swift +46 -0
  80. package/nitrogen/generated/ios/swift/HybridHybridPictureSelectorSpec.swift +56 -0
  81. package/nitrogen/generated/ios/swift/HybridHybridPictureSelectorSpec_cxx.swift +176 -0
  82. package/nitrogen/generated/ios/swift/MediaAsset.swift +118 -0
  83. package/nitrogen/generated/ios/swift/MediaType.swift +44 -0
  84. package/nitrogen/generated/ios/swift/PickerTheme.swift +48 -0
  85. package/nitrogen/generated/ios/swift/PictureSelectorOptions.swift +182 -0
  86. package/nitrogen/generated/shared/c++/CompressOptions.hpp +95 -0
  87. package/nitrogen/generated/shared/c++/CropOptions.hpp +99 -0
  88. package/nitrogen/generated/shared/c++/HybridHybridPictureSelectorSpec.cpp +22 -0
  89. package/nitrogen/generated/shared/c++/HybridHybridPictureSelectorSpec.hpp +69 -0
  90. package/nitrogen/generated/shared/c++/MediaAsset.hpp +124 -0
  91. package/nitrogen/generated/shared/c++/MediaType.hpp +80 -0
  92. package/nitrogen/generated/shared/c++/PickerTheme.hpp +84 -0
  93. package/nitrogen/generated/shared/c++/PictureSelectorOptions.hpp +132 -0
  94. package/package.json +76 -0
  95. package/src/PictureSelector.ts +72 -0
  96. package/src/index.ts +16 -0
  97. package/src/specs/PictureSelector.nitro.ts +121 -0
  98. package/src/types.ts +38 -0
  99. package/src/usePictureSelector.ts +102 -0
@@ -0,0 +1,182 @@
1
+ ///
2
+ /// PictureSelectorOptions.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `PictureSelectorOptions`, backed by a C++ struct.
12
+ */
13
+ public typealias PictureSelectorOptions = margelo.nitro.margelo.pictureselector.PictureSelectorOptions
14
+
15
+ public extension PictureSelectorOptions {
16
+ private typealias bridge = margelo.nitro.margelo.pictureselector.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `PictureSelectorOptions`.
20
+ */
21
+ init(mediaType: MediaType?, maxCount: Double?, enableCamera: Bool?, crop: CropOptions?, compress: CompressOptions?, maxVideoDuration: Double?, minVideoDuration: Double?, theme: PickerTheme?, themeColor: String?, selectedAssets: [String]?) {
22
+ self.init({ () -> bridge.std__optional_MediaType_ in
23
+ if let __unwrappedValue = mediaType {
24
+ return bridge.create_std__optional_MediaType_(__unwrappedValue)
25
+ } else {
26
+ return .init()
27
+ }
28
+ }(), { () -> bridge.std__optional_double_ in
29
+ if let __unwrappedValue = maxCount {
30
+ return bridge.create_std__optional_double_(__unwrappedValue)
31
+ } else {
32
+ return .init()
33
+ }
34
+ }(), { () -> bridge.std__optional_bool_ in
35
+ if let __unwrappedValue = enableCamera {
36
+ return bridge.create_std__optional_bool_(__unwrappedValue)
37
+ } else {
38
+ return .init()
39
+ }
40
+ }(), { () -> bridge.std__optional_CropOptions_ in
41
+ if let __unwrappedValue = crop {
42
+ return bridge.create_std__optional_CropOptions_(__unwrappedValue)
43
+ } else {
44
+ return .init()
45
+ }
46
+ }(), { () -> bridge.std__optional_CompressOptions_ in
47
+ if let __unwrappedValue = compress {
48
+ return bridge.create_std__optional_CompressOptions_(__unwrappedValue)
49
+ } else {
50
+ return .init()
51
+ }
52
+ }(), { () -> bridge.std__optional_double_ in
53
+ if let __unwrappedValue = maxVideoDuration {
54
+ return bridge.create_std__optional_double_(__unwrappedValue)
55
+ } else {
56
+ return .init()
57
+ }
58
+ }(), { () -> bridge.std__optional_double_ in
59
+ if let __unwrappedValue = minVideoDuration {
60
+ return bridge.create_std__optional_double_(__unwrappedValue)
61
+ } else {
62
+ return .init()
63
+ }
64
+ }(), { () -> bridge.std__optional_PickerTheme_ in
65
+ if let __unwrappedValue = theme {
66
+ return bridge.create_std__optional_PickerTheme_(__unwrappedValue)
67
+ } else {
68
+ return .init()
69
+ }
70
+ }(), { () -> bridge.std__optional_std__string_ in
71
+ if let __unwrappedValue = themeColor {
72
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
73
+ } else {
74
+ return .init()
75
+ }
76
+ }(), { () -> bridge.std__optional_std__vector_std__string__ in
77
+ if let __unwrappedValue = selectedAssets {
78
+ return bridge.create_std__optional_std__vector_std__string__({ () -> bridge.std__vector_std__string_ in
79
+ var __vector = bridge.create_std__vector_std__string_(__unwrappedValue.count)
80
+ for __item in __unwrappedValue {
81
+ __vector.push_back(std.string(__item))
82
+ }
83
+ return __vector
84
+ }())
85
+ } else {
86
+ return .init()
87
+ }
88
+ }())
89
+ }
90
+
91
+ @inline(__always)
92
+ var mediaType: MediaType? {
93
+ return self.__mediaType.value
94
+ }
95
+
96
+ @inline(__always)
97
+ var maxCount: Double? {
98
+ return { () -> Double? in
99
+ if bridge.has_value_std__optional_double_(self.__maxCount) {
100
+ let __unwrapped = bridge.get_std__optional_double_(self.__maxCount)
101
+ return __unwrapped
102
+ } else {
103
+ return nil
104
+ }
105
+ }()
106
+ }
107
+
108
+ @inline(__always)
109
+ var enableCamera: Bool? {
110
+ return { () -> Bool? in
111
+ if bridge.has_value_std__optional_bool_(self.__enableCamera) {
112
+ let __unwrapped = bridge.get_std__optional_bool_(self.__enableCamera)
113
+ return __unwrapped
114
+ } else {
115
+ return nil
116
+ }
117
+ }()
118
+ }
119
+
120
+ @inline(__always)
121
+ var crop: CropOptions? {
122
+ return self.__crop.value
123
+ }
124
+
125
+ @inline(__always)
126
+ var compress: CompressOptions? {
127
+ return self.__compress.value
128
+ }
129
+
130
+ @inline(__always)
131
+ var maxVideoDuration: Double? {
132
+ return { () -> Double? in
133
+ if bridge.has_value_std__optional_double_(self.__maxVideoDuration) {
134
+ let __unwrapped = bridge.get_std__optional_double_(self.__maxVideoDuration)
135
+ return __unwrapped
136
+ } else {
137
+ return nil
138
+ }
139
+ }()
140
+ }
141
+
142
+ @inline(__always)
143
+ var minVideoDuration: Double? {
144
+ return { () -> Double? in
145
+ if bridge.has_value_std__optional_double_(self.__minVideoDuration) {
146
+ let __unwrapped = bridge.get_std__optional_double_(self.__minVideoDuration)
147
+ return __unwrapped
148
+ } else {
149
+ return nil
150
+ }
151
+ }()
152
+ }
153
+
154
+ @inline(__always)
155
+ var theme: PickerTheme? {
156
+ return self.__theme.value
157
+ }
158
+
159
+ @inline(__always)
160
+ var themeColor: String? {
161
+ return { () -> String? in
162
+ if bridge.has_value_std__optional_std__string_(self.__themeColor) {
163
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__themeColor)
164
+ return String(__unwrapped)
165
+ } else {
166
+ return nil
167
+ }
168
+ }()
169
+ }
170
+
171
+ @inline(__always)
172
+ var selectedAssets: [String]? {
173
+ return { () -> [String]? in
174
+ if bridge.has_value_std__optional_std__vector_std__string__(self.__selectedAssets) {
175
+ let __unwrapped = bridge.get_std__optional_std__vector_std__string__(self.__selectedAssets)
176
+ return __unwrapped.map({ __item in String(__item) })
177
+ } else {
178
+ return nil
179
+ }
180
+ }()
181
+ }
182
+ }
@@ -0,0 +1,95 @@
1
+ ///
2
+ /// CompressOptions.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
+
32
+
33
+ #include <optional>
34
+
35
+ namespace margelo::nitro::margelo::pictureselector {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (CompressOptions).
39
+ */
40
+ struct CompressOptions final {
41
+ public:
42
+ bool enabled SWIFT_PRIVATE;
43
+ std::optional<double> quality SWIFT_PRIVATE;
44
+ std::optional<double> maxWidth SWIFT_PRIVATE;
45
+ std::optional<double> maxHeight SWIFT_PRIVATE;
46
+
47
+ public:
48
+ CompressOptions() = default;
49
+ explicit CompressOptions(bool enabled, std::optional<double> quality, std::optional<double> maxWidth, std::optional<double> maxHeight): enabled(enabled), quality(quality), maxWidth(maxWidth), maxHeight(maxHeight) {}
50
+
51
+ public:
52
+ friend bool operator==(const CompressOptions& lhs, const CompressOptions& rhs) = default;
53
+ };
54
+
55
+ } // namespace margelo::nitro::margelo::pictureselector
56
+
57
+ namespace margelo::nitro {
58
+
59
+ // C++ CompressOptions <> JS CompressOptions (object)
60
+ template <>
61
+ struct JSIConverter<margelo::nitro::margelo::pictureselector::CompressOptions> final {
62
+ static inline margelo::nitro::margelo::pictureselector::CompressOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
63
+ jsi::Object obj = arg.asObject(runtime);
64
+ return margelo::nitro::margelo::pictureselector::CompressOptions(
65
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enabled"))),
66
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quality"))),
67
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxWidth"))),
68
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxHeight")))
69
+ );
70
+ }
71
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::margelo::pictureselector::CompressOptions& arg) {
72
+ jsi::Object obj(runtime);
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "enabled"), JSIConverter<bool>::toJSI(runtime, arg.enabled));
74
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "quality"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.quality));
75
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxWidth"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxWidth));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxHeight"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxHeight));
77
+ return obj;
78
+ }
79
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
80
+ if (!value.isObject()) {
81
+ return false;
82
+ }
83
+ jsi::Object obj = value.getObject(runtime);
84
+ if (!nitro::isPlainObject(runtime, obj)) {
85
+ return false;
86
+ }
87
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enabled")))) return false;
88
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quality")))) return false;
89
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxWidth")))) return false;
90
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxHeight")))) return false;
91
+ return true;
92
+ }
93
+ };
94
+
95
+ } // namespace margelo::nitro
@@ -0,0 +1,99 @@
1
+ ///
2
+ /// CropOptions.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
+
32
+
33
+ #include <optional>
34
+
35
+ namespace margelo::nitro::margelo::pictureselector {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (CropOptions).
39
+ */
40
+ struct CropOptions final {
41
+ public:
42
+ bool enabled SWIFT_PRIVATE;
43
+ std::optional<bool> freeStyle SWIFT_PRIVATE;
44
+ std::optional<bool> circular SWIFT_PRIVATE;
45
+ std::optional<double> ratioX SWIFT_PRIVATE;
46
+ std::optional<double> ratioY SWIFT_PRIVATE;
47
+
48
+ public:
49
+ CropOptions() = default;
50
+ explicit CropOptions(bool enabled, std::optional<bool> freeStyle, std::optional<bool> circular, std::optional<double> ratioX, std::optional<double> ratioY): enabled(enabled), freeStyle(freeStyle), circular(circular), ratioX(ratioX), ratioY(ratioY) {}
51
+
52
+ public:
53
+ friend bool operator==(const CropOptions& lhs, const CropOptions& rhs) = default;
54
+ };
55
+
56
+ } // namespace margelo::nitro::margelo::pictureselector
57
+
58
+ namespace margelo::nitro {
59
+
60
+ // C++ CropOptions <> JS CropOptions (object)
61
+ template <>
62
+ struct JSIConverter<margelo::nitro::margelo::pictureselector::CropOptions> final {
63
+ static inline margelo::nitro::margelo::pictureselector::CropOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
64
+ jsi::Object obj = arg.asObject(runtime);
65
+ return margelo::nitro::margelo::pictureselector::CropOptions(
66
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enabled"))),
67
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "freeStyle"))),
68
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "circular"))),
69
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ratioX"))),
70
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ratioY")))
71
+ );
72
+ }
73
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::margelo::pictureselector::CropOptions& arg) {
74
+ jsi::Object obj(runtime);
75
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "enabled"), JSIConverter<bool>::toJSI(runtime, arg.enabled));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "freeStyle"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.freeStyle));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "circular"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.circular));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ratioX"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.ratioX));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ratioY"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.ratioY));
80
+ return obj;
81
+ }
82
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
83
+ if (!value.isObject()) {
84
+ return false;
85
+ }
86
+ jsi::Object obj = value.getObject(runtime);
87
+ if (!nitro::isPlainObject(runtime, obj)) {
88
+ return false;
89
+ }
90
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enabled")))) return false;
91
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "freeStyle")))) return false;
92
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "circular")))) return false;
93
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ratioX")))) return false;
94
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ratioY")))) return false;
95
+ return true;
96
+ }
97
+ };
98
+
99
+ } // namespace margelo::nitro
@@ -0,0 +1,22 @@
1
+ ///
2
+ /// HybridHybridPictureSelectorSpec.cpp
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
+ #include "HybridHybridPictureSelectorSpec.hpp"
9
+
10
+ namespace margelo::nitro::margelo::pictureselector {
11
+
12
+ void HybridHybridPictureSelectorSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("openPicker", &HybridHybridPictureSelectorSpec::openPicker);
18
+ prototype.registerHybridMethod("openCamera", &HybridHybridPictureSelectorSpec::openCamera);
19
+ });
20
+ }
21
+
22
+ } // namespace margelo::nitro::margelo::pictureselector
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// HybridHybridPictureSelectorSpec.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/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `MediaAsset` to properly resolve imports.
17
+ namespace margelo::nitro::margelo::pictureselector { struct MediaAsset; }
18
+ // Forward declaration of `PictureSelectorOptions` to properly resolve imports.
19
+ namespace margelo::nitro::margelo::pictureselector { struct PictureSelectorOptions; }
20
+
21
+ #include "MediaAsset.hpp"
22
+ #include <vector>
23
+ #include <NitroModules/Promise.hpp>
24
+ #include "PictureSelectorOptions.hpp"
25
+
26
+ namespace margelo::nitro::margelo::pictureselector {
27
+
28
+ using namespace margelo::nitro;
29
+
30
+ /**
31
+ * An abstract base class for `HybridPictureSelector`
32
+ * Inherit this class to create instances of `HybridHybridPictureSelectorSpec` in C++.
33
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
34
+ * @example
35
+ * ```cpp
36
+ * class HybridHybridPictureSelector: public HybridHybridPictureSelectorSpec {
37
+ * public:
38
+ * HybridHybridPictureSelector(...): HybridObject(TAG) { ... }
39
+ * // ...
40
+ * };
41
+ * ```
42
+ */
43
+ class HybridHybridPictureSelectorSpec: public virtual HybridObject {
44
+ public:
45
+ // Constructor
46
+ explicit HybridHybridPictureSelectorSpec(): HybridObject(TAG) { }
47
+
48
+ // Destructor
49
+ ~HybridHybridPictureSelectorSpec() override = default;
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ virtual std::shared_ptr<Promise<std::vector<MediaAsset>>> openPicker(const PictureSelectorOptions& options) = 0;
58
+ virtual std::shared_ptr<Promise<std::vector<MediaAsset>>> openCamera(const PictureSelectorOptions& options) = 0;
59
+
60
+ protected:
61
+ // Hybrid Setup
62
+ void loadHybridMethods() override;
63
+
64
+ protected:
65
+ // Tag for logging
66
+ static constexpr auto TAG = "HybridPictureSelector";
67
+ };
68
+
69
+ } // namespace margelo::nitro::margelo::pictureselector
@@ -0,0 +1,124 @@
1
+ ///
2
+ /// MediaAsset.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
+
32
+
33
+ #include <string>
34
+ #include <optional>
35
+
36
+ namespace margelo::nitro::margelo::pictureselector {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (MediaAsset).
40
+ */
41
+ struct MediaAsset final {
42
+ public:
43
+ std::string uri SWIFT_PRIVATE;
44
+ std::string type SWIFT_PRIVATE;
45
+ std::string mimeType SWIFT_PRIVATE;
46
+ double width SWIFT_PRIVATE;
47
+ double height SWIFT_PRIVATE;
48
+ double duration SWIFT_PRIVATE;
49
+ std::string fileName SWIFT_PRIVATE;
50
+ double fileSize SWIFT_PRIVATE;
51
+ std::optional<std::string> editedUri SWIFT_PRIVATE;
52
+ std::optional<bool> isOriginal SWIFT_PRIVATE;
53
+ std::optional<std::string> bucketName SWIFT_PRIVATE;
54
+
55
+ public:
56
+ MediaAsset() = default;
57
+ explicit MediaAsset(std::string uri, std::string type, std::string mimeType, double width, double height, double duration, std::string fileName, double fileSize, std::optional<std::string> editedUri, std::optional<bool> isOriginal, std::optional<std::string> bucketName): uri(uri), type(type), mimeType(mimeType), width(width), height(height), duration(duration), fileName(fileName), fileSize(fileSize), editedUri(editedUri), isOriginal(isOriginal), bucketName(bucketName) {}
58
+
59
+ public:
60
+ friend bool operator==(const MediaAsset& lhs, const MediaAsset& rhs) = default;
61
+ };
62
+
63
+ } // namespace margelo::nitro::margelo::pictureselector
64
+
65
+ namespace margelo::nitro {
66
+
67
+ // C++ MediaAsset <> JS MediaAsset (object)
68
+ template <>
69
+ struct JSIConverter<margelo::nitro::margelo::pictureselector::MediaAsset> final {
70
+ static inline margelo::nitro::margelo::pictureselector::MediaAsset fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
71
+ jsi::Object obj = arg.asObject(runtime);
72
+ return margelo::nitro::margelo::pictureselector::MediaAsset(
73
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri"))),
74
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
75
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType"))),
76
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
77
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height"))),
78
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration"))),
79
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileName"))),
80
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileSize"))),
81
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "editedUri"))),
82
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isOriginal"))),
83
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bucketName")))
84
+ );
85
+ }
86
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::margelo::pictureselector::MediaAsset& arg) {
87
+ jsi::Object obj(runtime);
88
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "uri"), JSIConverter<std::string>::toJSI(runtime, arg.uri));
89
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<std::string>::toJSI(runtime, arg.type));
90
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "mimeType"), JSIConverter<std::string>::toJSI(runtime, arg.mimeType));
91
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
92
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
93
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "duration"), JSIConverter<double>::toJSI(runtime, arg.duration));
94
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "fileName"), JSIConverter<std::string>::toJSI(runtime, arg.fileName));
95
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "fileSize"), JSIConverter<double>::toJSI(runtime, arg.fileSize));
96
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "editedUri"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.editedUri));
97
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "isOriginal"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isOriginal));
98
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "bucketName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.bucketName));
99
+ return obj;
100
+ }
101
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
102
+ if (!value.isObject()) {
103
+ return false;
104
+ }
105
+ jsi::Object obj = value.getObject(runtime);
106
+ if (!nitro::isPlainObject(runtime, obj)) {
107
+ return false;
108
+ }
109
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri")))) return false;
110
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
111
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType")))) return false;
112
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
113
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
114
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration")))) return false;
115
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileName")))) return false;
116
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileSize")))) return false;
117
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "editedUri")))) return false;
118
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isOriginal")))) return false;
119
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bucketName")))) return false;
120
+ return true;
121
+ }
122
+ };
123
+
124
+ } // namespace margelo::nitro
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// MediaType.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::margelo::pictureselector {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (MediaType).
30
+ */
31
+ enum class MediaType {
32
+ IMAGE SWIFT_NAME(image) = 0,
33
+ VIDEO SWIFT_NAME(video) = 1,
34
+ ALL SWIFT_NAME(all) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::margelo::pictureselector
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ MediaType <> JS MediaType (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::margelo::pictureselector::MediaType> final {
44
+ static inline margelo::nitro::margelo::pictureselector::MediaType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("image"): return margelo::nitro::margelo::pictureselector::MediaType::IMAGE;
48
+ case hashString("video"): return margelo::nitro::margelo::pictureselector::MediaType::VIDEO;
49
+ case hashString("all"): return margelo::nitro::margelo::pictureselector::MediaType::ALL;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum MediaType - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::margelo::pictureselector::MediaType arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::margelo::pictureselector::MediaType::IMAGE: return JSIConverter<std::string>::toJSI(runtime, "image");
57
+ case margelo::nitro::margelo::pictureselector::MediaType::VIDEO: return JSIConverter<std::string>::toJSI(runtime, "video");
58
+ case margelo::nitro::margelo::pictureselector::MediaType::ALL: return JSIConverter<std::string>::toJSI(runtime, "all");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert MediaType to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("image"):
71
+ case hashString("video"):
72
+ case hashString("all"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro