@react-native-ohos/react-native-image-crop-picker 0.40.4-rc.1
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.
- package/ COMMITTERS.md +9 -0
- package/.github/FUNDING.yml +1 -0
- package/CODE_OF_CONDUCT.md +0 -0
- package/CONTRIBUTING.md +68 -0
- package/ISSUE_TEMPLATE.md +34 -0
- package/LICENSE +21 -0
- package/OAT.xml +75 -0
- package/README.OpenSource +11 -0
- package/README.md +13 -0
- package/harmony/image_crop_picker/build-profile.json5 +8 -0
- package/harmony/image_crop_picker/hvigorfile.ts +1 -0
- package/harmony/image_crop_picker/index.ets +6 -0
- package/harmony/image_crop_picker/oh-package.json5 +10 -0
- package/harmony/image_crop_picker/src/main/cpp/CMakeLists.txt +9 -0
- package/harmony/image_crop_picker/src/main/cpp/ImageCropPickerPackage.h +19 -0
- package/harmony/image_crop_picker/src/main/cpp/generated/RNOH/generated/BaseReactNativeImageCropPickerPackage.h +66 -0
- package/harmony/image_crop_picker/src/main/cpp/generated/RNOH/generated/turbo_modules/ImageCropPicker.cpp +20 -0
- package/harmony/image_crop_picker/src/main/cpp/generated/RNOH/generated/turbo_modules/ImageCropPicker.h +16 -0
- package/harmony/image_crop_picker/src/main/ets/ImageCropPickerPackage.ts +28 -0
- package/harmony/image_crop_picker/src/main/ets/ImageCropPickerTurboModule.ts +1041 -0
- package/harmony/image_crop_picker/src/main/ets/Logger.ts +38 -0
- package/harmony/image_crop_picker/src/main/ets/generated/components/ts.ts +5 -0
- package/harmony/image_crop_picker/src/main/ets/generated/index.ets +5 -0
- package/harmony/image_crop_picker/src/main/ets/generated/ts.ts +6 -0
- package/harmony/image_crop_picker/src/main/ets/generated/turboModules/ImageCropPicker.ts +30 -0
- package/harmony/image_crop_picker/src/main/ets/generated/turboModules/ts.ts +5 -0
- package/harmony/image_crop_picker/src/main/ets/pages/ImageEditInfo.ets +862 -0
- package/harmony/image_crop_picker/src/main/ets/utils/Constants.ets +14 -0
- package/harmony/image_crop_picker/src/main/ets/utils/CropModel.ets +73 -0
- package/harmony/image_crop_picker/src/main/ets/utils/DecodeAndEncodeUtil.ets +54 -0
- package/harmony/image_crop_picker/src/main/ets/utils/EncodeUtil.ets +33 -0
- package/harmony/image_crop_picker/src/main/ets/utils/jul.ts +7 -0
- package/harmony/image_crop_picker/src/main/ets/utils/types.ets +94 -0
- package/harmony/image_crop_picker/src/main/ets/viewmodel/viewAndModel.ets +38 -0
- package/harmony/image_crop_picker/src/main/module.json5 +9 -0
- package/harmony/image_crop_picker/src/main/resources/base/element/string.json +20 -0
- package/harmony/image_crop_picker/src/main/resources/base/media/ic_anti_clockwise.png +0 -0
- package/harmony/image_crop_picker/src/main/resources/base/media/ic_clockwise.png +0 -0
- package/harmony/image_crop_picker/src/main/resources/base/media/ic_reset.png +0 -0
- package/harmony/image_crop_picker/src/main/resources/base/media/ic_save.png +0 -0
- package/harmony/image_crop_picker/src/main/resources/base/media/icon.png +0 -0
- package/harmony/image_crop_picker/src/main/resources/base/profile/main_pages.json +5 -0
- package/harmony/image_crop_picker/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/image_crop_picker/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/image_crop_picker/ts.ts +17 -0
- package/harmony/image_crop_picker.har +0 -0
- package/index.d.ts +512 -0
- package/js/NativeRNCImageCropPicker.ts +108 -0
- package/js/index.js +31 -0
- package/package.json +48 -0
- package/svg.svg +122 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
declare module "react-native-image-crop-picker" {
|
|
2
|
+
/**
|
|
3
|
+
* AVAssetExportPreset presets.
|
|
4
|
+
*
|
|
5
|
+
* @see https://developer.apple.com/documentation/avfoundation/avassetexportsession/export_preset_names_for_quicktime_files_of_a_given_size
|
|
6
|
+
*/
|
|
7
|
+
type CompressVideoPresets =
|
|
8
|
+
| '640x480'
|
|
9
|
+
| '960x540'
|
|
10
|
+
| '1280x720'
|
|
11
|
+
| '1920x1080'
|
|
12
|
+
| 'HEVC3840x2160'
|
|
13
|
+
| 'LowQuality'
|
|
14
|
+
| 'MediumQuality'
|
|
15
|
+
| 'HighestQuality'
|
|
16
|
+
| 'Passthrough';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* iOS smart album types
|
|
20
|
+
*
|
|
21
|
+
* @see https://developer.apple.com/documentation/photokit/phassetcollectionsubtype
|
|
22
|
+
*/
|
|
23
|
+
type SmartAlbums =
|
|
24
|
+
| 'Regular'
|
|
25
|
+
| 'SyncedEvent'
|
|
26
|
+
| 'SyncedFaces'
|
|
27
|
+
| 'SyncedAlbum'
|
|
28
|
+
| 'Imported'
|
|
29
|
+
| 'PhotoStream'
|
|
30
|
+
| 'CloudShared'
|
|
31
|
+
| 'Generic'
|
|
32
|
+
| 'Panoramas'
|
|
33
|
+
| 'Videos'
|
|
34
|
+
| 'Favorites'
|
|
35
|
+
| 'Timelapses'
|
|
36
|
+
| 'AllHidden'
|
|
37
|
+
| 'RecentlyAdded'
|
|
38
|
+
| 'Bursts'
|
|
39
|
+
| 'SlomoVideos'
|
|
40
|
+
| 'UserLibrary'
|
|
41
|
+
| 'Screenshots'
|
|
42
|
+
| 'SelfPortraits'
|
|
43
|
+
/** >= iOS 10.2 */
|
|
44
|
+
| 'DepthEffect'
|
|
45
|
+
/** >= iOS 10.3 */
|
|
46
|
+
| 'LivePhotos'
|
|
47
|
+
/** >= iOS 11 */
|
|
48
|
+
| 'Animated'
|
|
49
|
+
| 'LongExposure';
|
|
50
|
+
|
|
51
|
+
export interface CommonOptions {
|
|
52
|
+
/**
|
|
53
|
+
* Enable or disable multiple image selection.
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
multiple?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Min number of files to select when using `multiple` option.
|
|
61
|
+
*
|
|
62
|
+
* @platform iOS only
|
|
63
|
+
* @default 1
|
|
64
|
+
*/
|
|
65
|
+
minFiles?: number;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Max number of files to select when using `multiple` option.
|
|
69
|
+
*
|
|
70
|
+
* @platform iOS only
|
|
71
|
+
* @default 5
|
|
72
|
+
*/
|
|
73
|
+
maxFiles?: number;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Promise will resolve/reject once ViewController completion block is called.
|
|
77
|
+
*
|
|
78
|
+
* @platform iOS only
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
waitAnimationEnd?: boolean;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* List of smart albums to choose from.
|
|
85
|
+
*
|
|
86
|
+
* @platform iOS only
|
|
87
|
+
* @default ['UserLibrary', 'PhotoStream', 'Panoramas', 'Videos', 'Bursts']
|
|
88
|
+
*/
|
|
89
|
+
smartAlbums?: SmartAlbums[];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Whether to default to the front camera when opened. Please note that not all
|
|
93
|
+
* Android devices handle this parameter, see
|
|
94
|
+
* [issue #1058](https://github.com/ivpusic/react-native-image-crop-picker/issues/1058).
|
|
95
|
+
*
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
useFrontCamera?: boolean;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Text displayed while photo is loading in picker.
|
|
102
|
+
*
|
|
103
|
+
* @default 'Processing assets...'
|
|
104
|
+
*/
|
|
105
|
+
loadingLabelText?: string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Whether to show the number of selected assets.
|
|
109
|
+
*
|
|
110
|
+
* @default true
|
|
111
|
+
*/
|
|
112
|
+
showsSelectedCount?: boolean;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Applies a sort order on the creation date on how media is displayed within the
|
|
116
|
+
* albums/detail photo views when opening the image picker.
|
|
117
|
+
*
|
|
118
|
+
* @platform iOS only
|
|
119
|
+
* @default 'none'
|
|
120
|
+
*/
|
|
121
|
+
sortOrder?: 'none' | 'asc' | 'desc';
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Whether to display bottom controls.
|
|
125
|
+
*
|
|
126
|
+
* @platform Android only
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
hideBottomControls?: boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* When set to false, does not write temporary files for the selected images. This is useful
|
|
133
|
+
* to improve performance when you are retrieving file contents with the includeBase64 option
|
|
134
|
+
* and don't need to read files from disk.
|
|
135
|
+
*
|
|
136
|
+
* @platform iOS only
|
|
137
|
+
* @default true
|
|
138
|
+
*/
|
|
139
|
+
writeTempFile?: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
type ImageOptions = CommonOptions & {
|
|
143
|
+
mediaType: 'photo';
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Width of result image when used with `cropping` option.
|
|
147
|
+
*/
|
|
148
|
+
width?: number;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Height of result image when used with `cropping` option.
|
|
152
|
+
*/
|
|
153
|
+
height?: number;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* When set to true, the image file content will be available as a base64-encoded string in
|
|
157
|
+
* the data property. Hint: To use this string as an image source, use it like:
|
|
158
|
+
* <Image source={{uri: `data:${image.mime};base64,${image.data}`}} />
|
|
159
|
+
*
|
|
160
|
+
* @default false
|
|
161
|
+
*/
|
|
162
|
+
includeBase64?: boolean;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Include image exif data in the response.
|
|
166
|
+
*
|
|
167
|
+
* @default false
|
|
168
|
+
*/
|
|
169
|
+
includeExif?: boolean;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Whether to convert photos to JPG. This will also convert any Live Photo into its JPG representation.
|
|
173
|
+
*
|
|
174
|
+
* @default false
|
|
175
|
+
*/
|
|
176
|
+
forceJpg?: boolean;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Enable or disable cropping.
|
|
180
|
+
*
|
|
181
|
+
* @default false
|
|
182
|
+
*/
|
|
183
|
+
cropping?: boolean;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* When set to true, the image will always fill the mask space.
|
|
187
|
+
*
|
|
188
|
+
* @default true
|
|
189
|
+
*/
|
|
190
|
+
avoidEmptySpaceAroundImage?: boolean;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* When cropping image, determines ActiveWidget color.
|
|
194
|
+
*
|
|
195
|
+
* @platform Android only
|
|
196
|
+
* @default '#424242'
|
|
197
|
+
*/
|
|
198
|
+
cropperActiveWidgetColor?: string;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* When cropping image, determines the color of StatusBar.
|
|
202
|
+
*
|
|
203
|
+
* @platform Android only
|
|
204
|
+
* @default '#424242'
|
|
205
|
+
*/
|
|
206
|
+
cropperStatusBarColor?: string;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* When cropping image, determines the color of Toolbar.
|
|
210
|
+
*
|
|
211
|
+
* @platform Android only
|
|
212
|
+
* @default '#424242'
|
|
213
|
+
*/
|
|
214
|
+
cropperToolbarColor?: string;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* When cropping image, determines the color of Toolbar text and buttons.
|
|
218
|
+
*
|
|
219
|
+
* @platform Android only
|
|
220
|
+
* @default 'darker orange'
|
|
221
|
+
*/
|
|
222
|
+
cropperToolbarWidgetColor?: string;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* When cropping image, determines the title of Toolbar.
|
|
226
|
+
*
|
|
227
|
+
* @default 'Edit Photo'
|
|
228
|
+
*/
|
|
229
|
+
cropperToolbarTitle?: string;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Enables user to apply custom rectangle area for cropping.
|
|
233
|
+
*
|
|
234
|
+
* @platform iOS only
|
|
235
|
+
* @default false
|
|
236
|
+
*/
|
|
237
|
+
freeStyleCropEnabled?: boolean;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* cropperTintColor
|
|
241
|
+
*/
|
|
242
|
+
cropperTintColor?: string;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Enable or disable circular cropping mask.
|
|
246
|
+
*
|
|
247
|
+
* @default false
|
|
248
|
+
*/
|
|
249
|
+
cropperCircleOverlay?: boolean;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Cancel button text.
|
|
253
|
+
*
|
|
254
|
+
* @default 'Cancel'
|
|
255
|
+
*/
|
|
256
|
+
cropperCancelText?: string;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Cancel button color. HEX-like string color.
|
|
260
|
+
*
|
|
261
|
+
* @example '#ff00ee'
|
|
262
|
+
* @platform iOS only
|
|
263
|
+
*/
|
|
264
|
+
cropperCancelColor?: string;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Choose button text.
|
|
268
|
+
*
|
|
269
|
+
* @default 'Choose'
|
|
270
|
+
*/
|
|
271
|
+
cropperChooseText?: string;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Choose button color. HEX-like string color.
|
|
275
|
+
*
|
|
276
|
+
* @example '#EE00DD'
|
|
277
|
+
* @platform iOS only
|
|
278
|
+
*/
|
|
279
|
+
cropperChooseColor?: string;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Enable or disable cropper rotate buttons.
|
|
283
|
+
*
|
|
284
|
+
* @platform iOS only
|
|
285
|
+
* @default false
|
|
286
|
+
*/
|
|
287
|
+
cropperRotateButtonsHidden?: boolean
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Whether to show the 3x3 grid on top of the image during cropping.
|
|
291
|
+
*
|
|
292
|
+
* @platform Android only
|
|
293
|
+
* @default true
|
|
294
|
+
*/
|
|
295
|
+
showCropGuidelines?: boolean;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Whether to show the square crop frame during cropping
|
|
299
|
+
*
|
|
300
|
+
* @platform Android only
|
|
301
|
+
* @default true
|
|
302
|
+
*/
|
|
303
|
+
showCropFrame?: boolean;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Whether to enable rotating the image by hand gesture.
|
|
307
|
+
*
|
|
308
|
+
* @platform Android only
|
|
309
|
+
* @default false
|
|
310
|
+
*/
|
|
311
|
+
enableRotationGesture?: boolean;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* When cropping image, disables the color setters for cropping library.
|
|
315
|
+
*
|
|
316
|
+
* @platform Android only
|
|
317
|
+
* @default false
|
|
318
|
+
*/
|
|
319
|
+
disableCropperColorSetters?: boolean;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Compress image with maximum width.
|
|
323
|
+
*
|
|
324
|
+
* @default null
|
|
325
|
+
*/
|
|
326
|
+
compressImageMaxWidth?: number;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Compress image with maximum height.
|
|
330
|
+
*
|
|
331
|
+
* @default null
|
|
332
|
+
*/
|
|
333
|
+
compressImageMaxHeight?: number;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Compress image with quality (from 0 to 1, where 1 is best quality). On iOS, values larger
|
|
337
|
+
* than 0.8 don't produce a noticeable quality increase in most images, while a value of 0.8
|
|
338
|
+
* will reduce the file size by about half or less compared to a value of 1.
|
|
339
|
+
*
|
|
340
|
+
* @default Android: 1, iOS: 0.8
|
|
341
|
+
*/
|
|
342
|
+
compressImageQuality?: number;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
type CropperOptions = ImageOptions & {
|
|
346
|
+
/**
|
|
347
|
+
* Selected image location
|
|
348
|
+
*/
|
|
349
|
+
path: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
type VideoOptions = CommonOptions & {
|
|
353
|
+
mediaType: 'video';
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Choose which preset will be used for video compression.
|
|
357
|
+
*
|
|
358
|
+
* @platform iOS only
|
|
359
|
+
* @default 'MediumQuality'
|
|
360
|
+
*/
|
|
361
|
+
compressVideoPreset?: CompressVideoPresets;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
type AnyOptions = Omit<ImageOptions, 'mediaType'> & Omit<VideoOptions, 'mediaType'> & {
|
|
365
|
+
mediaType?: 'any';
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export type Options = AnyOptions | VideoOptions | ImageOptions;
|
|
369
|
+
|
|
370
|
+
interface ImageVideoCommon {
|
|
371
|
+
/**
|
|
372
|
+
* Selected image location. This is null when the `writeTempFile` option is set to `false`.
|
|
373
|
+
*/
|
|
374
|
+
path: string;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Selected image size in bytes.
|
|
378
|
+
*/
|
|
379
|
+
size: number;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Selected image/video width.
|
|
383
|
+
*/
|
|
384
|
+
width: number;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Selected image/video height.
|
|
388
|
+
*/
|
|
389
|
+
height: number;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Selected image MIME type (image/jpeg, image/png, etc).
|
|
393
|
+
*/
|
|
394
|
+
mime: string;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Extracted exif data from image. Response format is platform specific.
|
|
398
|
+
*/
|
|
399
|
+
exif?: any;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Selected image's localidentifier, used for PHAsset searching.
|
|
403
|
+
*
|
|
404
|
+
* @platform iOS only
|
|
405
|
+
*/
|
|
406
|
+
localIdentifier?: string;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Selected image's source path, do not have write access.
|
|
410
|
+
*
|
|
411
|
+
* @platform iOS only
|
|
412
|
+
*/
|
|
413
|
+
sourceURL?: string;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Selected image/video's filename.
|
|
417
|
+
*
|
|
418
|
+
* @platform iOS only
|
|
419
|
+
*/
|
|
420
|
+
filename?: string;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* UNIX timestamp when image was created.
|
|
424
|
+
*
|
|
425
|
+
* @platform iOS only
|
|
426
|
+
*/
|
|
427
|
+
creationDate?: string;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* UNIX timestamp when image was last modified.
|
|
431
|
+
*/
|
|
432
|
+
modificationDate?: string;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export interface Image extends ImageVideoCommon {
|
|
436
|
+
/**
|
|
437
|
+
* Optional base64 selected file representation.
|
|
438
|
+
*/
|
|
439
|
+
data?: string | null;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Cropped image rectangle (width, height, x, y).
|
|
443
|
+
*/
|
|
444
|
+
cropRect?: CropRect | null;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export interface Video extends ImageVideoCommon {
|
|
448
|
+
/**
|
|
449
|
+
* Video duration in milliseconds
|
|
450
|
+
*/
|
|
451
|
+
duration: number | null;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export type ImageOrVideo = Image | Video;
|
|
455
|
+
|
|
456
|
+
export interface CropRect {
|
|
457
|
+
x: number;
|
|
458
|
+
y: number;
|
|
459
|
+
width: number;
|
|
460
|
+
height: number;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
type PickerErrorCodeCommon =
|
|
464
|
+
| 'E_PICKER_CANCELLED'
|
|
465
|
+
| 'E_NO_IMAGE_DATA_FOUND'
|
|
466
|
+
| 'E_NO_LIBRARY_PERMISSION'
|
|
467
|
+
| 'E_NO_CAMERA_PERMISSION'
|
|
468
|
+
| 'E_ERROR_WHILE_CLEANING_FILES';
|
|
469
|
+
|
|
470
|
+
type PickerErrorCodeIOS =
|
|
471
|
+
| 'E_PICKER_CANNOT_RUN_CAMERA_ON_SIMULATOR'
|
|
472
|
+
| 'E_CROPPER_IMAGE_NOT_FOUND'
|
|
473
|
+
| 'E_CANNOT_SAVE_IMAGE'
|
|
474
|
+
| 'E_CANNOT_PROCESS_VIDEO';
|
|
475
|
+
|
|
476
|
+
type PickerErrorCodeAndroid =
|
|
477
|
+
| 'E_ACTIVITY_DOES_NOT_EXIST'
|
|
478
|
+
| 'E_CALLBACK_ERROR'
|
|
479
|
+
| 'E_FAILED_TO_SHOW_PICKER'
|
|
480
|
+
| 'E_FAILED_TO_OPEN_CAMERA'
|
|
481
|
+
| 'E_CAMERA_IS_NOT_AVAILABLE'
|
|
482
|
+
| 'E_CANNOT_LAUNCH_CAMERA';
|
|
483
|
+
|
|
484
|
+
export type PickerErrorCode = PickerErrorCodeCommon | PickerErrorCodeIOS | PickerErrorCodeAndroid;
|
|
485
|
+
|
|
486
|
+
/** Change return type based on `multiple` property. */
|
|
487
|
+
export type PossibleArray<O, T> = O extends { multiple: true; } ? T[] : T;
|
|
488
|
+
|
|
489
|
+
/** Isolate return type based on `mediaType` property. */
|
|
490
|
+
type MediaType<O> =
|
|
491
|
+
O extends { mediaType: 'photo'; } ? Image :
|
|
492
|
+
O extends { mediaType: 'video'; } ? Video :
|
|
493
|
+
ImageOrVideo;
|
|
494
|
+
|
|
495
|
+
export function openPicker<O extends Options>(options: O): Promise<PossibleArray<O, MediaType<O>>>;
|
|
496
|
+
export function openCamera<O extends Options>(options: O): Promise<PossibleArray<O, MediaType<O>>>;
|
|
497
|
+
export function openCropper(options: CropperOptions): Promise<Image>;
|
|
498
|
+
export function clean(): Promise<void>;
|
|
499
|
+
export function cleanSingle(path: string): Promise<void>;
|
|
500
|
+
|
|
501
|
+
export interface ImageCropPicker {
|
|
502
|
+
openPicker<O extends Options>(options: O): Promise<PossibleArray<O, MediaType<O>>>;
|
|
503
|
+
openCamera<O extends Options>(options: O): Promise<PossibleArray<O, MediaType<O>>>;
|
|
504
|
+
openCropper(options: CropperOptions): Promise<Image>;
|
|
505
|
+
clean(): Promise<void>;
|
|
506
|
+
cleanSingle(path: string): Promise<void>;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const ImageCropPicker: ImageCropPicker;
|
|
510
|
+
|
|
511
|
+
export default ImageCropPicker;
|
|
512
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { TurboModule } from "react-native/library/TurboModule/RCTExport";
|
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
|
3
|
+
|
|
4
|
+
type ImageOrVideo = Image | Video;
|
|
5
|
+
type SmartAlbums = | 'Regular' | 'SyncedEvent' | 'SyncedFaces';
|
|
6
|
+
type CompressVideoPresets = | 'LowQuality' | 'MediumQuality' | 'HighestQuality' | 'Passthrough';
|
|
7
|
+
type Options = AnyOptions | VideoOptions | ImageOptions;
|
|
8
|
+
type MediaType = 'photo' | 'video' | 'any';
|
|
9
|
+
type AnyOptions = Omit<ImageOptions, 'mediaType'> & Omit<VideoOptions, 'mediaType'> & {
|
|
10
|
+
mediaType?: 'any';
|
|
11
|
+
}
|
|
12
|
+
type VideoOptions = CommonOptions & {
|
|
13
|
+
mediaType: 'video';
|
|
14
|
+
compressVideoPreset?: CompressVideoPresets;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type CropperOptions = ImageOptions & {
|
|
18
|
+
path: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type ImageOptions = CommonOptions & {
|
|
22
|
+
mediaType: MediaType;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
includeBase64?: boolean;
|
|
26
|
+
includeExif?: boolean;
|
|
27
|
+
forceJpg?: boolean;
|
|
28
|
+
cropping?: boolean;
|
|
29
|
+
avoidEmptySpaceAroundImage?: boolean;
|
|
30
|
+
cropperActiveWidgetColor?: string;
|
|
31
|
+
cropperStatusBarColor?: string;
|
|
32
|
+
cropperToolbarColor?: string;
|
|
33
|
+
cropperToolbarWidgetColor?: string;
|
|
34
|
+
cropperToolbarTitle?: string;
|
|
35
|
+
freeStyleCropEnabled?: boolean;
|
|
36
|
+
cropperTintColor?: string;
|
|
37
|
+
cropperCircleOverlay?: boolean;
|
|
38
|
+
cropperCancelText?: string;
|
|
39
|
+
cropperCancelColor?: string;
|
|
40
|
+
cropperChooseText?: string;
|
|
41
|
+
cropperChooseColor?: string;
|
|
42
|
+
cropperRotateButtonHidden?: boolean
|
|
43
|
+
showCropGuidelines?: boolean;
|
|
44
|
+
showCropFrame?: boolean;
|
|
45
|
+
enableRotationGesture?: boolean;
|
|
46
|
+
disableCropperColorSetters?: boolean;
|
|
47
|
+
compressImageMaxWidth?: number;
|
|
48
|
+
compressImageMaxHeight?: number;
|
|
49
|
+
compressImageQuality?: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface CommonOptions {
|
|
53
|
+
multiple?: boolean;
|
|
54
|
+
minFiles?: number;
|
|
55
|
+
maxFiles?: number;
|
|
56
|
+
waitAnimationEnd?: boolean;
|
|
57
|
+
smartAlbums?: SmartAlbums[];
|
|
58
|
+
useFrontCamera?: boolean;
|
|
59
|
+
loadingLabelText?: string;
|
|
60
|
+
showsSelectedCount?: boolean;
|
|
61
|
+
sortOrder?: 'none' | 'asc' | 'desc';
|
|
62
|
+
hideBottomControls?: boolean;
|
|
63
|
+
writeTempFile?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface CropRect {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
width: number;
|
|
70
|
+
height: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface ImageVideoCommon {
|
|
74
|
+
path: string;
|
|
75
|
+
size: number;
|
|
76
|
+
width: number;
|
|
77
|
+
height: number;
|
|
78
|
+
mime: string;
|
|
79
|
+
exif?: Exif;
|
|
80
|
+
localIdentifier?: string;
|
|
81
|
+
sourceURL?: string;
|
|
82
|
+
filename?: string;
|
|
83
|
+
creationDate?: string;
|
|
84
|
+
modificationDate?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface Exif {
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface Image extends ImageVideoCommon {
|
|
92
|
+
data?: string | null;
|
|
93
|
+
cropRect?: CropRect | null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface Video extends ImageVideoCommon {
|
|
97
|
+
duration: number | null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface Spec extends TurboModule {
|
|
101
|
+
openPicker(options: Options): Promise<Video[] | Video | ImageOrVideo[] | ImageOrVideo | Image[] | Image>;
|
|
102
|
+
openCamera(options: Options): Promise<Video[] | Video | ImageOrVideo[] | ImageOrVideo | Image[] | Image>;
|
|
103
|
+
openCropper(options: CropperOptions): Promise<Image>;
|
|
104
|
+
clean(): Promise<void>;
|
|
105
|
+
cleanSingle(path: string): Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('ImageCropPicker')
|
package/js/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ImageCropPicker from './NativeRNCImageCropPicker';
|
|
3
|
+
|
|
4
|
+
const ImagePicker = {
|
|
5
|
+
async openPicker(options) {
|
|
6
|
+
const res = await ImageCropPicker.openPicker(options);
|
|
7
|
+
return res;
|
|
8
|
+
},
|
|
9
|
+
async openCamera(options) {
|
|
10
|
+
const res = await ImageCropPicker.openCamera(options);
|
|
11
|
+
return res;
|
|
12
|
+
},
|
|
13
|
+
async openCropper(options) {
|
|
14
|
+
const res = await ImageCropPicker.openCropper(options);
|
|
15
|
+
return res;
|
|
16
|
+
},
|
|
17
|
+
async cleanSingle(path) {
|
|
18
|
+
ImageCropPicker.cleanSingle(path);
|
|
19
|
+
},
|
|
20
|
+
async clean() {
|
|
21
|
+
ImageCropPicker.clean();
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default ImagePicker;
|
|
26
|
+
|
|
27
|
+
export const openPicker = ImagePicker.openPicker;
|
|
28
|
+
export const openCamera = ImagePicker.openCamera;
|
|
29
|
+
export const openCropper = ImagePicker.openCropper;
|
|
30
|
+
export const clean = ImagePicker.clean;
|
|
31
|
+
export const cleanSingle = ImagePicker.cleanSingle;
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-image-crop-picker",
|
|
3
|
+
"version": "0.40.4-rc.1",
|
|
4
|
+
"description": "Select single or multiple images, with cropping option",
|
|
5
|
+
"main": "js/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-image-crop-picker --cpp-output-path ./harmony/image_crop_picker/src/main/cpp/generated --ets-output-path ./harmony/image_crop_picker/src/main/ets/generated --turbo-modules-spec-paths ./js/NativeRNCImageCropPicker.ts"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://gitee.com/openharmony-sig/rntpc_react-native-image-crop-picker.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"react",
|
|
16
|
+
"native",
|
|
17
|
+
"react-native",
|
|
18
|
+
"image",
|
|
19
|
+
"picker",
|
|
20
|
+
"crop",
|
|
21
|
+
"cropping",
|
|
22
|
+
"multiple",
|
|
23
|
+
"camera",
|
|
24
|
+
"harmony"
|
|
25
|
+
],
|
|
26
|
+
"author": "Ivan Pusic",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://gitee.com/openharmony-sig/rntpc_react-native-image-crop-picker/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://gitee.com/openharmony-sig/rntpc_react-native-image-crop-picker#readme",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"react-native-image-crop-picker": "^0.40.3"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"react-native-harmony-cli": "npm:@react-native-oh/react-native-harmony-cli@^0.0.27"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react-native": ">=0.40.0"
|
|
40
|
+
},
|
|
41
|
+
"harmony": {
|
|
42
|
+
"alias": "react-native-image-crop-picker"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"registry": "https://registry.npmjs.org/",
|
|
46
|
+
"access": "public"
|
|
47
|
+
}
|
|
48
|
+
}
|