|
1 |
| -module ImagePicker = { |
2 |
| - module Options = { |
3 |
| - type t |
4 |
| - |
5 |
| - module Button = { |
6 |
| - type t |
7 |
| - |
8 |
| - @obj external make: (~title: string=?, ~name: string=?, unit) => t = "" |
9 |
| - } |
10 |
| - |
11 |
| - module PermissionDenied = { |
12 |
| - type t |
13 |
| - |
14 |
| - @obj |
15 |
| - external options: ( |
16 |
| - ~title: string, |
17 |
| - ~text: string, |
18 |
| - ~reTryTitle: string, |
19 |
| - ~okTitle: string, |
20 |
| - ) => t = "" |
21 |
| - } |
22 |
| - |
23 |
| - module Storage = { |
24 |
| - type t |
25 |
| - |
26 |
| - @obj |
27 |
| - external options: ( |
28 |
| - ~skipBackup: bool=?, |
29 |
| - ~path: string=?, |
30 |
| - ~cameraRoll: bool=?, |
31 |
| - ~waitUntilSaved: bool=?, |
32 |
| - unit, |
33 |
| - ) => t = "" |
34 |
| - } |
35 |
| - |
36 |
| - @obj |
37 |
| - external make: ( |
38 |
| - ~title: string=?, |
39 |
| - ~cancelButtonTitle: string=?, |
40 |
| - ~takePhotoButtonTitle: string=?, |
41 |
| - ~chooseFromLibraryButtonTitle: string=?, |
42 |
| - ~chooseWhichLibraryTitle: string=?, |
43 |
| - ~tintColor: string=?, |
44 |
| - ~cameraType: [#front | #back]=?, |
45 |
| - ~mediaType: [#photo | #video | #mixed]=?, |
46 |
| - ~maxWidth: float=?, |
47 |
| - ~maxHeight: float=?, |
48 |
| - ~quality: float=?, |
49 |
| - ~durationLimit: int=?, |
50 |
| - ~rotation: float=?, |
51 |
| - ~allowsEditing: bool=?, |
52 |
| - ~noData: bool=?, |
53 |
| - ~videoQuality: [#low | #medium | #high]=?, |
54 |
| - ~storageOptions: Storage.t=?, |
55 |
| - ~permissionDenied: PermissionDenied.t=?, |
56 |
| - ~customButtons: array<Button.t>=?, |
57 |
| - unit, |
58 |
| - ) => t = "" |
59 |
| - } |
60 |
| - |
61 |
| - type response = { |
62 |
| - didCancel: bool, |
63 |
| - error: option<string>, |
64 |
| - customButton: string, |
65 |
| - data: option<string>, |
66 |
| - uri: string, |
67 |
| - origURL: option<string>, |
68 |
| - isVertical: bool, |
69 |
| - width: int, |
70 |
| - height: int, |
71 |
| - fileSize: int, |
72 |
| - @as("type") |
73 |
| - type_: option<string>, |
74 |
| - fileName: option<string>, |
75 |
| - path: option<string>, |
76 |
| - latitude: option<float>, |
77 |
| - longitude: option<float>, |
78 |
| - timestamp: int, |
79 |
| - originalRotation: float, |
80 |
| - } |
81 |
| - |
82 |
| - @module("react-native-image-picker") |
83 |
| - external launchCamera: (Options.t, response => unit) => unit = "launchCamera" |
| 1 | +type options |
| 2 | + |
| 3 | +@obj |
| 4 | +external options: ( |
| 5 | + ~cameraType: [#front | #back]=?, |
| 6 | + ~durationLimit: int=?, |
| 7 | + ~includeBase64: bool=?, |
| 8 | + ~maxHeight: float=?, |
| 9 | + ~maxWidth: float=?, |
| 10 | + ~mediaType: [#photo | #video]=?, |
| 11 | + ~quality: float=?, |
| 12 | + ~saveToPhotos: bool=?, |
| 13 | + ~videoQuality: [#low | #medium | #high]=?, |
| 14 | + unit, |
| 15 | +) => options = "" |
| 16 | + |
| 17 | +type response = { |
| 18 | + base64: option<string>, |
| 19 | + didCancel: option<bool>, |
| 20 | + duration: option<float>, |
| 21 | + errorCode: option<[#camera_unavailable | #permission | #others]>, |
| 22 | + errorMessage: option<string>, |
| 23 | + fileName: option<string>, |
| 24 | + fileSize: option<float>, |
| 25 | + height: option<float>, |
| 26 | + uri: option<string>, |
| 27 | + width: option<float>, |
| 28 | + @as("type") type_: option<string>, |
| 29 | +} |
84 | 30 |
|
85 |
| - @module("react-native-image-picker") |
86 |
| - external showImagePicker: (Options.t, response => unit) => unit = "showImagePicker" |
| 31 | +@module("react-native-image-picker") |
| 32 | +external launchCamera: (options, response => unit) => unit = "launchCamera" |
87 | 33 |
|
88 |
| - @module("react-native-image-picker") |
89 |
| - external launchImageLibrary: (Options.t, response => unit) => unit = "launchImageLibrary" |
90 |
| -} |
91 |
| -/* |
92 |
| - ImagePicker.( |
93 |
| - launchCamera( |
94 |
| - Options.make( |
95 |
| - ~title="Take a picture", |
96 |
| - ~cameraType=`back, |
97 |
| - ~mediaType=`photo, |
98 |
| - ~permissionDenied= |
99 |
| - Options.PermissionDenied.options( |
100 |
| - ~title="Permission denied !", |
101 |
| - ~text="text", |
102 |
| - ~reTryTitle="Retry", |
103 |
| - ~okTitle="Ok !", |
104 |
| - ), |
105 |
| - (), |
106 |
| - ), |
107 |
| - ) |
108 |
| - ); |
109 |
| - */ |
| 34 | +@module("react-native-image-picker") |
| 35 | +external launchImageLibrary: (options, response => unit) => unit = "launchImageLibrary" |
0 commit comments