Skip to content

Commit 94b1e73

Browse files
jayuTrancever
authored andcommitted
feat: add typescript types (#13)
1 parent 4bf35bb commit 94b1e73

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "React Native Image Editing native modules for iOS & Android",
55
"main": "lib/ImageEditor.js",
6+
"typings": "typings/index.d.ts",
67
"author": "Dawid Urbaniak <dawidu@onet.pl>",
78
"contributors": [],
89
"homepage": "https://github.com/react-native-community/react-native-image-editor#readme",

typings/index.d.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
type $Maybe<T> = T | null | undefined;
2+
3+
export type ImageCropData = {
4+
/**
5+
* The top-left corner of the cropped image, specified in the original
6+
* image's coordinate space.
7+
*/
8+
offset: {
9+
x: number,
10+
y: number,
11+
},
12+
/**
13+
* The size (dimensions) of the cropped image, specified in the original
14+
* image's coordinate space.
15+
*/
16+
size: {
17+
width: number,
18+
height: number,
19+
},
20+
/**
21+
* (Optional) size to scale the cropped image to.
22+
*/
23+
displaySize?: $Maybe<{
24+
width: number,
25+
height: number,
26+
}>,
27+
/**
28+
* (Optional) the resizing mode to use when scaling the image. If the
29+
* `displaySize` param is not specified, this has no effect.
30+
*/
31+
resizeMode?: $Maybe<{
32+
contain: string,
33+
cover: string,
34+
stretch: string,
35+
}>,
36+
};
37+
38+
declare class ImageEditor {
39+
/**
40+
* Crop the image specified by the URI param. If URI points to a remote
41+
* image, it will be downloaded automatically. If the image cannot be
42+
* loaded/downloaded, the failure callback will be called. On Android, a
43+
* downloaded image may be cached in external storage, a publicly accessible
44+
* location, if it has more available space than internal storage.
45+
*
46+
* If the cropping process is successful, the resultant cropped image
47+
* will be stored in the ImageStore, and the URI returned in the success
48+
* callback will point to the image in the store. Remember to delete the
49+
* cropped image from the ImageStore when you are done with it.
50+
*/
51+
static cropImage: (
52+
uri: string,
53+
cropData: ImageCropData,
54+
success: (uri: string) => void,
55+
failure: (error: Object) => void,
56+
) => void
57+
}
58+
59+
export default ImageEditor

0 commit comments

Comments
 (0)