Skip to content

Commit 3c61bd7

Browse files
committed
Update for 3.x
1 parent ff18256 commit 3c61bd7

File tree

5 files changed

+48
-155
lines changed

5 files changed

+48
-155
lines changed

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![ReScript Forum](https://img.shields.io/discourse/posts?color=e6484f&label=ReScript%20Forum&server=https%3A%2F%2Fforum.rescript-lang.org)](https://forum.rescript-lang.org/)
66

77
[ReScript](https://rescript-lang.org) bindings for
8-
[`react-native-image-picker`](https://github.com/react-native-community/react-native-image-picker).
8+
[`react-native-image-picker`](https://github.com/react-native-image-picker/react-native-image-picker).
99

1010
Exposed as `ReactNativeImagePicker` module.
1111

@@ -15,7 +15,7 @@ Exposed as `ReactNativeImagePicker` module.
1515
## Installation
1616

1717
When
18-
[`react-native-image-picker`](https://github.com/react-native-community/react-native-image-picker)
18+
[`react-native-image-picker`](https://github.com/react-native-image-picker/react-native-image-picker)
1919
is properly installed & configured by following their installation instructions,
2020
you can install the bindings:
2121

@@ -44,29 +44,17 @@ yarn add @rescript-react-native/image-picker
4444
## Usage
4545

4646
```rescript
47-
open ReactNativeImagePicker;
48-
49-
ImagePicker.(
50-
launchCamera(
51-
Options.make(
52-
~title="Take a picture",
53-
~cameraType=`back,
54-
~mediaType=`photo,
55-
~permissionDenied=
56-
Options.PermissionDenied.options(
57-
~title="Permission denied !",
58-
~text="text",
59-
~reTryTitle="Retry",
60-
~okTitle="Ok !",
61-
),
62-
(),
63-
),
64-
res => {
65-
Js.log(res##uri);
66-
Js.log(res##path);
67-
}
68-
)
69-
);
47+
open ReactNativeImagePicker
48+
49+
launchCamera(
50+
options(
51+
~cameraType=#back,
52+
~mediaType=#photo,
53+
()),
54+
res => {
55+
Js.log(res.uri)
56+
}
57+
)
7058
```
7159

7260
---

bsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@rescript-react-native/image-picker",
33
"reason": { "react-jsx": 3 },
4-
"namespace": false,
54
"package-specs": {
65
"module": "commonjs",
76
"in-source": true

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"access": "public"
77
},
88
"peerDependencies": {
9-
"react-native-image-picker": "^2.3.0"
9+
"react-native-image-picker": "^3.6.0"
1010
},
1111
"repository": "https://github.com/rescript-react-native/image-picker.git",
1212
"license": "MIT",

src/ReactNativeImagePicker.bs.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1 @@
1-
'use strict';
2-
3-
4-
var Button = {};
5-
6-
var PermissionDenied = {};
7-
8-
var $$Storage = {};
9-
10-
var Options = {
11-
Button: Button,
12-
PermissionDenied: PermissionDenied,
13-
$$Storage: $$Storage
14-
};
15-
16-
var ImagePicker = {
17-
Options: Options
18-
};
19-
20-
exports.ImagePicker = ImagePicker;
21-
/* No side effect */
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

src/ReactNativeImagePicker.res

Lines changed: 33 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,35 @@
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+
}
8430

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"
8733

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

Comments
 (0)